From d36fc3b8f88cc3108ffff6151e376b619b9abb01 Mon Sep 17 00:00:00 2001 From: kinitrupti Date: Fri, 12 May 2017 18:40:35 +0530 Subject: Revised list of TBCs --- .../ABHISHEKAGRAWAL_version_backup/chapter2.ipynb | 149 ++ sample_notebooks/ABHISHEKAGRAWAL/chapter2.ipynb | 149 -- .../Chapter_11.ipynb | 2636 +++++++++++++++++++ .../Chapter_11_Inheritance_1.ipynb | 2636 +++++++++++++++++++ .../Chapter_11_Inheritance_2.ipynb | 2661 ++++++++++++++++++++ .../AJEET KUMARSINGH/Chapter_11_Inheritance.ipynb | 2636 ------------------- .../Chapter_11_Inheritance_(1).ipynb | 2636 ------------------- .../Chapter_11_Inheritance_1.ipynb | 2636 ------------------- .../Chapter_11_Inheritance_2.ipynb | 2661 -------------------- .../ARIJITCHATTERJEE_version_backup/chapter1.ipynb | 904 +++++++ sample_notebooks/ARIJITCHATTERJEE/chapter1.ipynb | 904 ------- sample_notebooks/Abu BakkerSiddik/Functions.ipynb | 1441 +++++++++++ sample_notebooks/Abu BakkerSiddik/Functions_.ipynb | 1441 ----------- .../AdityaAnand_version_backup/Chapter_8.ipynb | 390 +++ .../AdityaAnand_version_backup/Chapter_8_-.ipynb | 390 +++ .../Chapter_8_-_Gravitation_1.ipynb | 390 +++ sample_notebooks/AdityaAnand/Chapter_8.ipynb | 390 --- .../AdityaAnand/Chapter_8_-_Gravitation.ipynb | 390 --- .../AdityaAnand/Chapter_8_-_Gravitation_1.ipynb | 390 --- .../AdityaR_version_backup/Chapter_5-Sample.ipynb | 279 ++ .../AdityaR/Chapter_5-Sample_Notebook.ipynb | 279 -- .../Sample.S._Fogler.ipynb | 231 ++ .../Sample.S._Fogler_UPDATED.ipynb | 231 ++ .../Sample.S._Fogler_UPDATED_(1).ipynb | 191 ++ .../AjaySatish/Sample_H.S._Fogler.ipynb | 231 -- .../AjaySatish/Sample_H.S._Fogler_UPDATED.ipynb | 231 -- .../Sample_H.S._Fogler_UPDATED_(1).ipynb | 191 -- .../Akshay Ghogare/AKSHAY_GHOGARE.ipynb | 249 -- .../Akshay Ghogare_version_backup/AKSHAY.ipynb | 249 ++ .../AkshayPatil_version_backup/chapter1.ipynb | 190 ++ sample_notebooks/AkshayPatil/chapter1.ipynb | 190 -- .../AkshayShende_version_backup/chapter2.ipynb | 65 + sample_notebooks/AkshayShende/chapter2.ipynb | 65 - sample_notebooks/AlokDadlani/ALOK_DADLANI.ipynb | 181 -- .../AlokDadlani_version_backup/ALOK.ipynb | 181 ++ .../Chapter_6_Objects_and.ipynb | 934 +++++++ .../Chapter_6_Objects_and_Classes.ipynb | 934 ------- .../AnaySonawane/Solid_State_electronics.ipynb | 971 +++++++ .../AnaySonawane/Solid_State_electronics_Ch1.ipynb | 971 ------- .../AnkitKumar_version_backup/Ch16.ipynb | 364 +++ sample_notebooks/AnkitKumar/Ch16.ipynb | 364 --- .../Anshulkhare_version_backup/Chapter9.ipynb | 388 +++ sample_notebooks/Anshulkhare/Chapter9.ipynb | 388 --- .../ApurvaBhushan_version_backup/Chapter_3.ipynb | 195 ++ .../ApurvaBhushan_version_backup/Chapter_3_1.ipynb | 212 ++ sample_notebooks/ApurvaBhushan/Chapter_3.ipynb | 195 -- sample_notebooks/ApurvaBhushan/Chapter_3_1.ipynb | 212 -- sample_notebooks/Ashish KumarSingh/Chapter.ipynb | 243 ++ .../Ashish KumarSingh/Chapter_First.ipynb | 243 -- .../AumkarRane_version_backup/Chapter9.ipynb | 194 ++ sample_notebooks/AumkarRane/Chapter9.ipynb | 194 -- .../AviralYadav_version_backup/Chapter9.ipynb | 144 ++ sample_notebooks/AviralYadav/Chapter9.ipynb | 144 -- .../AzagumozhiMadhaiyan/Chapter8.ipynb | 71 + .../AzagumozhiMadhaiyan/Chapter_8_.ipynb | 71 - .../BhavithaInnamuri/Chapter_1_CRYSTAL.ipynb | 677 +++++ .../Chapter_1_CRYSTAL_STRUCTURES.ipynb | 677 ----- .../DanishAnsari_version_backup/chapter_1.ipynb | 111 + sample_notebooks/DanishAnsari/chapter_1.ipynb | 111 - .../DaudIbrahir Saifi/Chapter_07.ipynb | 341 --- .../Chapter_07.ipynb | 341 +++ .../DeepTrambadia_version_backup/sc201.ipynb | 53 + sample_notebooks/DeepTrambadia/Diode.ipynb | 679 +++++ .../DeepTrambadia/Diode_Applications.ipynb | 679 ----- sample_notebooks/DeepTrambadia/sc201.ipynb | 53 - ...ter_1_Introduction_to_Radio_Communication.ipynb | 102 + ...troduction_to_Radio_Communication_Systems.ipynb | 102 - .../chapter1.ipynb | 1 + sample_notebooks/Dileep KumarShakya/chapter1.ipynb | 1 - .../DivyangGandhi_version_backup/ch2.ipynb | 80 + sample_notebooks/DivyangGandhi/ch2.ipynb | 80 - .../Chapter_3_Semoconductor_Devices.ipynb | 223 ++ ...pter_3_Semoconductor_Devices_Fundamentals.ipynb | 223 -- .../chapter1.ipynb | 556 ++++ .../Ershad AhamedChemmalasseri/chapter1.ipynb | 556 ---- .../GauravMittal_version_backup/chapter2.ipynb | 349 +++ sample_notebooks/GauravMittal/chapter2.ipynb | 349 --- .../GirishVora/GirishVora_version_backup/ch2.ipynb | 428 ++++ sample_notebooks/GirishVora/ch2.ipynb | 428 ---- .../Chapter2Electrostatics.ipynb | 281 +++ .../Gopi KrishnaManchukonda/Chapter8.ipynb | 286 --- .../Chapter_2_Electrostatics_.ipynb | 281 --- .../Chapter8.ipynb | 286 +++ sample_notebooks/GudePrithvi/Chapter_3.ipynb | 536 ---- .../GudePrithvi_version_backup/Chapter_3.ipynb | 536 ++++ ...ation_and_Deionization_Processes_in_gases.ipynb | 656 ----- ..._Ionization_and_Deionization_Processes_in.ipynb | 656 +++++ .../J.B.Gupta_Chapter_6_(1).ipynb | 196 ++ .../J.B.Gupta_Chapter_6_(1).ipynb | 196 -- ...er_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS_.ipynb | 223 -- ..._1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb | 366 --- .../Chapter1-INTRODUCTIONTOMECHANICSOFSOLIDS.ipynb | 223 ++ ..._1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb | 366 +++ .../HeminChheda_version_backup/chapter1.ipynb | 281 +++ sample_notebooks/HeminChheda/chapter1.ipynb | 281 --- sample_notebooks/Hrituraj/Ch-6.ipynb | 540 ---- .../Hrituraj/Hrituraj_version_backup/Ch-6.ipynb | 540 ++++ sample_notebooks/Hrituraj/Various_types_of.ipynb | 318 +++ .../Hrituraj/Various_types_of_tarrifs.ipynb | 318 --- .../InnamuriBhavitha/Chapter_1_CRYSTAL.ipynb | 234 ++ .../Chapter_1_CRYSTAL_STRUCTURES.ipynb | 234 -- .../chapter1.ipynb | 292 +++ .../JagadeeshwarGoshika/chapter1.ipynb | 292 --- .../JaiMathur/JaiMathur_version_backup/ch2.ipynb | 309 +++ sample_notebooks/JaiMathur/ch2.ipynb | 309 --- sample_notebooks/JayDadlani/SAMPLE_NB_KI.ipynb | 220 ++ .../JayDadlani/SAMPLE_NB_KI_KAPOOR.ipynb | 220 -- sample_notebooks/Jaya Sravya/Chapter10.ipynb | 694 ----- .../Jaya Sravya_version_backup/Chapter10.ipynb | 694 +++++ sample_notebooks/KARTHIKEYAN S/CHAPTER_1.ipynb | 104 - .../KARTHIKEYAN S_version_backup/CHAPTER_1.ipynb | 104 + sample_notebooks/KAVANA B/CHAPTER.ipynb | 175 -- .../KAVANA B/KAVANA B_version_backup/CHAPTER.ipynb | 175 ++ .../Chapter_11__Impulse_and_Reaction.ipynb | 345 +++ ...Chapter_11__Impulse_and_Reaction_Turbines.ipynb | 345 --- ...Chapter_8_FREQUENCY_EFFECTS_IN_AMPLIFIERS.ipynb | 120 - .../Chapter_8_FREQUENCY_EFFECTS_IN.ipynb | 120 + .../KhushbuPattani_version_backup/chapter1.ipynb | 53 + sample_notebooks/KhushbuPattani/chapter1.ipynb | 53 - .../KonasaniSai Dheeraj/sample(chapter.ipynb | 236 ++ .../KonasaniSai Dheeraj/sample(chapter_1).ipynb | 236 -- .../KonasaniSai Dheeraj/sample_(chapter.ipynb | 256 ++ .../KonasaniSai Dheeraj/sample_(chapter_6).ipynb | 256 -- .../LalitKumar_version_backup/chapter2.ipynb | 347 +++ sample_notebooks/LalitKumar/chapter2.ipynb | 347 --- .../Pinciples_of_electronic_Instrumentation.ipynb | 406 +++ ...nciples_of_electronic_Instrumentation_Ch1.ipynb | 406 --- .../ManchukondaGopi Krishna/Chapter_7_Wave.ipynb | 299 +++ .../Chapter_7_Wave_Guides.ipynb | 299 --- .../ManchukondaLalitha Pujitha/Chpater_1.ipynb | 176 ++ .../Chpater_1_Gravity.ipynb | 176 -- ..._and_Functional_Descriptions_of_Measuring.ipynb | 109 + ...nal_Descriptions_of_Measuring_Instruments.ipynb | 109 - .../MandalaManoj pruthvi/Chapter_4_Radian.ipynb | 658 +++++ .../Chapter_4_Radian_Measure.ipynb | 658 ----- .../Chapter_2_Light_propagation_in_optical.ipynb | 430 ++++ ...pter_2_Light_propagation_in_optical_fiber.ipynb | 430 ---- .../Chapter_2_Motion_in_a_straight.ipynb | 825 ++++++ .../Chapter_2_Motion_in_a_straight_line.ipynb | 825 ------ sample_notebooks/ManikandanD/chapter1.ipynb | 256 ++ sample_notebooks/ManikandanD/chapter_1_.ipynb | 256 -- .../MaulikRathod_version_backup/ch11.ipynb | 745 ++++++ sample_notebooks/MaulikRathod/ch11.ipynb | 745 ------ sample_notebooks/MayankSahu/Chapter1.ipynb | 1 + sample_notebooks/MayankSahu/Chapter1_.ipynb | 1 - sample_notebooks/MayankSahu/Chapter5.ipynb | 1 + sample_notebooks/MayankSahu/Chapter5_.ipynb | 1 - .../Mayur Phadtare_version_backup/chapter.3.ipynb | 589 +++++ sample_notebooks/Mayur Phadtare/chapter_no.3.ipynb | 589 ----- sample_notebooks/MeenaChandrupatla/Chapter2.ipynb | 187 ++ .../MeenaChandrupatla/Chapter2_Gases.ipynb | 187 -- .../MeenaChandrupatla/Chapter_1_Magnetic.ipynb | 289 +++ .../Chapter_1_Magnetic_Circuits.ipynb | 289 --- .../MeenaChandrupatla/Chapter_2_The.ipynb | 249 ++ .../MeenaChandrupatla/Chapter_2_The_Device.ipynb | 249 -- .../MohdAnwar_version_backup/chapter1.ipynb | 443 ++++ sample_notebooks/MohdAnwar/chapter1.ipynb | 443 ---- .../MohdAsif/Chapter2,_Measurement.ipynb | 257 ++ .../MohdAsif/Chapter2,_Measurement_Errors.ipynb | 257 -- .../MohdAsif/Chapter2_-_Measurement.ipynb | 1549 ++++++++++++ .../MohdAsif/Chapter2_-_Measurement_Errors.ipynb | 1549 ------------ .../MohdAsif/MohdAsif_version_backup/ch2.ipynb | 387 +++ .../MohdAsif_version_backup/chapter1.ipynb | 389 +++ .../MohdAsif_version_backup/chapter2.ipynb | 349 +++ sample_notebooks/MohdAsif/ch2.ipynb | 387 --- sample_notebooks/MohdAsif/chapter1.ipynb | 389 --- sample_notebooks/MohdAsif/chapter2.ipynb | 349 --- .../MohdGufran_version_backup/chapter_10.ipynb | 355 +++ sample_notebooks/MohdGufran/chapter_10.ipynb | 355 --- sample_notebooks/MohdRizwan/Chapter8.ipynb | 253 -- .../MohdRizwan_version_backup/Chapter8.ipynb | 253 ++ .../MukteshChaudhary_version_backup/ch2.ipynb | 150 ++ sample_notebooks/MukteshChaudhary/ch2.ipynb | 150 -- ...ION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb | 462 ---- ..._BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb | 462 ---- ..._BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb | 462 ---- ..._BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb | 462 ---- ...N_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb | 462 ---- ...ATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb | 462 ++++ ...ON_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb | 462 ++++ ...ON_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb | 462 ++++ ...ON_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb | 462 ++++ ...ION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb | 462 ++++ .../NagadeviPriya_version_backup/Sample.ipynb | 67 + .../NagadeviPriya/Sample_Notebook.ipynb | 67 - sample_notebooks/Namratha Reddy/chapter3.ipynb | 4 +- sample_notebooks/Namratha Reddy/chapter3_(1).ipynb | 907 ------- .../Chapter_4_BJT_Fundamentals.ipynb | 544 ---- .../Chapter_4_BJT.ipynb | 544 ++++ .../chapter1.ipynb | 78 + .../NarayaniGurumoorthy/chapter1.ipynb | 78 - .../NeerajBaunthiyal_version_backup/chapter1.ipynb | 570 +++++ sample_notebooks/NeerajBaunthiyal/chapter1.ipynb | 570 ----- .../NirenNegandhi_version_backup/ch2.ipynb | 507 ++++ .../NirenNegandhi_version_backup/ch2_1.ipynb | 505 ++++ sample_notebooks/NirenNegandhi/ch2.ipynb | 507 ---- sample_notebooks/NirenNegandhi/ch2_1.ipynb | 505 ---- .../NitamoniDas/Chapter_8_Data_Abstraction.ipynb | 809 ------ ...rough_Classes_and_User-Defined_Data_Types.ipynb | 809 ------ ...rough_Classes_and_User_Defined_Data_Types.ipynb | 809 ------ ...ugh_Classes_and_User_Defined_Data_Types_1.ipynb | 809 ------ ...ugh_Classes_and_User_Defined_Data_Types_2.ipynb | 809 ------ ...ugh_Classes_and_User_Defined_Data_Types_3.ipynb | 809 ------ ...ugh_Classes_and_User_Defined_Data_Types_4.ipynb | 809 ------ ...ugh_Classes_and_User_Defined_Data_Types_5.ipynb | 809 ------ .../Chapter_8_Data.ipynb | 809 ++++++ ...ion_through_Classes_and_User-Defined_Data.ipynb | 809 ++++++ ...ion_through_Classes_and_User_Defined_Data.ipynb | 809 ++++++ ...ugh_Classes_and_User_Defined_Data_Types_1.ipynb | 809 ++++++ ...ugh_Classes_and_User_Defined_Data_Types_2.ipynb | 809 ++++++ ...ugh_Classes_and_User_Defined_Data_Types_3.ipynb | 809 ++++++ ...ugh_Classes_and_User_Defined_Data_Types_4.ipynb | 809 ++++++ ...ugh_Classes_and_User_Defined_Data_Types_5.ipynb | 809 ++++++ .../chapter_8_Data_Abstraction_through.ipynb | 809 ++++++ ...ion_through_Classes_and_User-Defined_Data.ipynb | 809 ++++++ ...rough_Classes_and_User-Defined_Data_Types.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_1.ipynb | 809 ++++++ ...gh_Classes_and_User-Defined_Data_Types_10.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_2.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_3.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_4.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_5.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_7.ipynb | 809 ++++++ ...ugh_Classes_and_User-Defined_Data_Types_8.ipynb | 809 ++++++ ...hapter_8_Data_Abstraction_through_Classes.ipynb | 809 ------ ...rough_Classes_and_User-Defined_Data_Types.ipynb | 809 ------ ...h_Classes_and_User-Defined_Data_Types_(1).ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_1.ipynb | 809 ------ ...gh_Classes_and_User-Defined_Data_Types_10.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_2.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_3.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_4.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_5.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_7.ipynb | 809 ------ ...ugh_Classes_and_User-Defined_Data_Types_8.ipynb | 809 ------ .../Nitin Kumar_version_backup/chapter2.ipynb | 680 +++++ sample_notebooks/Nitin Kumar/chapter2.ipynb | 680 ----- .../NityaL_version_backup/Sample-Chapter_26.ipynb | 226 ++ .../NityaL/NityaL_version_backup/Sample.ipynb | 236 ++ sample_notebooks/NityaL/Sample-Chapter_26.ipynb | 226 -- sample_notebooks/NityaL/Sample.ipynb | 236 -- .../NivethaChezhian_version_backup/Sample.ipynb | 68 + .../NivethaChezhian/Sample_Notebook.ipynb | 68 - sample_notebooks/PRAVEENKUMAR C/CHAPTER_1.ipynb | 66 - .../PRAVEENKUMAR C_version_backup/CHAPTER_1.ipynb | 66 + ...r_and_Separation_Process_by_Binay_K_Dutta.ipynb | 753 ------ ...and_Separation_Process_by_Binay_K_Dutta_1.ipynb | 789 ------ ...and_Separation_Process_by_Binay_K_Dutta_2.ipynb | 789 ------ .../PrashantSahu/Chapter_2_Molecular.ipynb | 657 +++++ .../Chapter_2_Molecular_Diffusion.ipynb | 657 ----- ...ransfer_and_Separation_Process_by_Binay_K.ipynb | 753 ++++++ ...and_Separation_Process_by_Binay_K_Dutta_1.ipynb | 789 ++++++ ...and_Separation_Process_by_Binay_K_Dutta_2.ipynb | 789 ++++++ .../PraveenKumar_version_backup/chapter1.ipynb | 1600 ++++++++++++ .../PraveenKumar_version_backup/chapter2.ipynb | 429 ++++ sample_notebooks/PraveenKumar/chapter1.ipynb | 1600 ------------ sample_notebooks/PraveenKumar/chapter2.ipynb | 429 ---- sample_notebooks/PreetiRani/Operational.ipynb | 299 +++ .../PreetiRani/Operational_Amplifiers.ipynb | 299 --- .../RONAKBANSAL_version_backup/chapter_1.ipynb | 528 ++++ sample_notebooks/RONAKBANSAL/chapter_1.ipynb | 528 ---- .../RahulJoshi/Chapter_1_An_Overview_of_Heat.ipynb | 1396 ++++++++++ .../Chapter_1_An_Overview_of_Heat_Trasnfer.ipynb | 1396 ---------- .../Raj Phani_version_backup/chapter1.ipynb | 993 ++++++++ .../Raj Phani_version_backup/chapter_1.ipynb | 1118 ++++++++ .../Raj Phani_version_backup/chapter_1_1.ipynb | 1118 ++++++++ sample_notebooks/Raj Phani/chapter1.ipynb | 993 -------- sample_notebooks/Raj Phani/chapter_1.ipynb | 1118 -------- sample_notebooks/Raj Phani/chapter_1_1.ipynb | 1118 -------- .../RaviGarg/RaviGarg_version_backup/chap1.ipynb | 462 ++++ sample_notebooks/RaviGarg/chap1.ipynb | 462 ---- sample_notebooks/RavirajJadeja/ch16.ipynb | 64 - .../Reshma Ustad/Chapter_2_Properties_Of.ipynb | 146 ++ .../Chapter_2_Properties_Of_Material.ipynb | 146 -- .../RohitPhadtare_version_backup/chapter.6.ipynb | 1494 +++++++++++ sample_notebooks/RohitPhadtare/chapter_1.ipynb | 438 ++++ sample_notebooks/RohitPhadtare/chapter_1_som.ipynb | 438 ---- sample_notebooks/RohitPhadtare/chapter_no.6.ipynb | 1494 ----------- ...agnetic_Properties_and_Crystal_Structures.ipynb | 548 ---- ...netic_Properties_and_Crystal_Structures_1.ipynb | 555 ---- .../RohithYeedulapalli/Chapter_7.ipynb | 232 -- .../RohithYeedulapalli/Chapter_7_1.ipynb | 236 -- ...agnetic_Properties_and_Crystal_Structures.ipynb | 548 ++++ ...netic_Properties_and_Crystal_Structures_1.ipynb | 555 ++++ .../Chapter_7.ipynb | 232 ++ .../Chapter_7_1.ipynb | 236 ++ .../RuchiMittal_version_backup/chap1.ipynb | 412 +++ .../RuchiMittal_version_backup/chapter1.ipynb | 543 ++++ sample_notebooks/RuchiMittal/chap1.ipynb | 412 --- sample_notebooks/RuchiMittal/chapter1.ipynb | 543 ---- sample_notebooks/SINDHUARROJU/Chapter10.ipynb | 410 --- .../SINDHUARROJU_version_backup/Chapter10.ipynb | 410 +++ sample_notebooks/SPANDANAARROJU/Chapter4.ipynb | 764 ++---- .../SPANDANAARROJU/Chapter4_J3M7PEz.ipynb | 211 -- .../Sadananda CharyArroju/Chapter10.ipynb | 431 ---- .../Chapter10.ipynb | 431 ++++ .../SaiRakesh_version_backup/chapter_1.ipynb | 1777 +++++++++++++ sample_notebooks/SaiRakesh/chapter_1.ipynb | 1777 ------------- .../SakshiGoplani_version_backup/Sample.ipynb | 662 +++++ sample_notebooks/SakshiGoplani/Sample.ipynb | 662 ----- sample_notebooks/SaleemAhmed/Chapter10.ipynb | 439 ---- .../SaleemAhmed_version_backup/Chapter10.ipynb | 439 ++++ .../SalilKapur/IntroductionConcept_of.ipynb | 282 +++ .../SalilKapur/IntroductionConcept_of_Stress.ipynb | 282 --- sample_notebooks/SantoshPawar/Chapter9.ipynb | 569 ----- .../SantoshPawar_version_backup/Chapter9.ipynb | 569 +++++ .../SaurabhBarot_version_backup/ch2.ipynb | 510 ++++ sample_notebooks/SaurabhBarot/ch2.ipynb | 510 ---- sample_notebooks/SayanDas Karmakar/Chapter_4.ipynb | 339 --- .../Chapter_4.ipynb | 339 +++ .../ShantanuBhosale_version_backup/chapter40.ipynb | 1989 +++++++++++++++ sample_notebooks/ShantanuBhosale/chapter40.ipynb | 1989 --------------- .../chapter1.ipynb | 448 ++++ .../ShivaAmruthavakkula/chapter1.ipynb | 448 ---- .../chapter_1.ipynb | 193 ++ sample_notebooks/ShubhamDahiphale/chapter_1.ipynb | 193 -- sample_notebooks/SoumenGanguly/ncert.ipynb | 355 +++ sample_notebooks/SoumenGanguly/ncert_Maths.ipynb | 355 --- ...er_11-_Object_Initialization_and_Clean-Up.ipynb | 1779 ------------- ..._11-_Object_Initialization_and_Clean-Up_1.ipynb | 1779 ------------- .../Chapter_11-_Object_Initialization_and.ipynb | 1779 +++++++++++++ ..._11-_Object_Initialization_and_Clean-Up_1.ipynb | 1779 +++++++++++++ .../Chapter_4_Op_Amps_as_AC_Amplifiers.ipynb | 363 --- .../Chapter_4_Op_Amps_as_AC.ipynb | 363 +++ .../Suhaib Alam_version_backup/ch2.ipynb | 507 ++++ .../Suhaib Alam_version_backup/chapter-4.ipynb | 380 +++ sample_notebooks/Suhaib Alam/ch2.ipynb | 507 ---- sample_notebooks/Suhaib Alam/chapter-4.ipynb | 380 --- .../SumadhuriDamerla/Chapter_1_Passive.ipynb | 370 +++ .../Chapter_1_Passive_Circuits.ipynb | 370 --- .../SumedhKadam/Chapter_1_General.ipynb | 117 + .../SumedhKadam/Chapter_1_General_Principles.ipynb | 117 - .../Chapter_6_IMPEDENCE_MATCHING_AND_TUNNING.ipynb | 277 -- .../Chapter_6_IMPEDENCE_MATCHING_AND.ipynb | 277 ++ sample_notebooks/Tarun KumarDas/Chapter9.ipynb | 227 -- sample_notebooks/Tarun KumarDas/Chapter9_2.ipynb | 227 -- sample_notebooks/Tarun KumarDas/Chapter9_3.ipynb | 227 -- sample_notebooks/Tarun KumarDas/Chapter9_4.ipynb | 227 -- .../Tarun KumarDas_version_backup/Chapter9.ipynb | 227 ++ .../Tarun KumarDas_version_backup/Chapter9_2.ipynb | 227 ++ .../Tarun KumarDas_version_backup/Chapter9_3.ipynb | 227 ++ .../Tarun KumarDas_version_backup/Chapter9_4.ipynb | 227 ++ .../TestUser_version_backup/chapter1.ipynb | 423 ++++ sample_notebooks/TestUser/chapter1.ipynb | 423 ---- .../UmangAgarwal/Sample_Notebook.ipynb | 128 - .../UmangAgarwal/Sample_Notebook_Umang.ipynb | 163 -- .../UmangAgarwal_version_backup/Sample.ipynb | 163 ++ .../Vaibhav Vajani_version_backup/chapter2.ipynb | 1412 +++++++++++ sample_notebooks/Vaibhav Vajani/chapter2.ipynb | 1412 ----------- .../Chapter_2_Electric.ipynb | 296 +++ .../Chapter_2_Electric_Fields.ipynb | 296 --- .../Vedantam Lakshmi Manasa/Mathematical.ipynb | 212 ++ .../Mathematical_Foundation.ipynb | 212 -- .../VidyashankarVenkatraman/Chapter_3.ipynb | 79 + .../VidyashankarVenkatraman/Chapter_3_Kittel.ipynb | 79 - .../Chapter_3_Kitteldemo.ipynb | 79 - .../Chapter_3.ipynb | 79 + sample_notebooks/VikasPrasad/Chapter_01.ipynb | 170 -- sample_notebooks/VikasPrasad/Chapter_01_1.ipynb | 170 -- .../VikasPrasad_version_backup/Chapter_01.ipynb | 170 ++ .../VikasPrasad_version_backup/Chapter_01_1.ipynb | 170 ++ .../VikasPrasad_version_backup/chapter1.ipynb | 166 ++ .../VikasPrasad_version_backup/chapter1_3.ipynb | 165 ++ .../VikasPrasad_version_backup/chapter1_4.ipynb | 165 ++ .../VikasPrasad_version_backup/chapter1_5.ipynb | 165 ++ .../VikasPrasad_version_backup/chapter1_6.ipynb | 165 ++ .../VikasPrasad_version_backup/chapter1_7.ipynb | 165 ++ .../VikasPrasad_version_backup/chapter1_8.ipynb | 170 ++ sample_notebooks/VikasPrasad/chapter1.ipynb | 166 -- sample_notebooks/VikasPrasad/chapter1_3.ipynb | 165 -- sample_notebooks/VikasPrasad/chapter1_4.ipynb | 165 -- sample_notebooks/VikasPrasad/chapter1_5.ipynb | 165 -- sample_notebooks/VikasPrasad/chapter1_6.ipynb | 165 -- sample_notebooks/VikasPrasad/chapter1_7.ipynb | 165 -- sample_notebooks/VikasPrasad/chapter1_8.ipynb | 170 -- sample_notebooks/VineshSaini/Ch1.ipynb | 516 ---- .../VineshSaini_version_backup/Ch1.ipynb | 516 ++++ sample_notebooks/YogeshPatil/Chapter_11.ipynb | 494 ---- sample_notebooks/YogeshPatil/Chapter_11_1.ipynb | 494 ---- .../YogeshPatil_version_backup/Chapter_11.ipynb | 494 ++++ .../YogeshPatil_version_backup/Chapter_11_1.ipynb | 494 ++++ sample_notebooks/abhishekchauhan/Chapter10.ipynb | 214 -- .../abhishekchauhan_version_backup/Chapter10.ipynb | 214 ++ sample_notebooks/ajinkyakhair/Untitled3.ipynb | 105 - .../ajinkyakhair_version_backup/Untitled3.ipynb | 105 + .../ajinkyakhair_version_backup/chapter2.ipynb | 240 ++ sample_notebooks/ajinkyakhair/chapter2.ipynb | 243 +- .../ajinkyakhair/chapter2_8f8MyfH.ipynb | 337 --- .../anubhav gupta_version_backup/chapter15.ipynb | 318 +++ sample_notebooks/anubhav gupta/chapter15.ipynb | 318 --- .../asmitaasmita/1_An_overview_of_C++.ipynb | 254 -- .../asmitaasmita/1_An_overview_of_C++_1.ipynb | 254 -- .../1_An_overview_of.ipynb | 254 ++ .../1_An_overview_of_C++_1.ipynb | 254 ++ sample_notebooks/bharthkumar/Untitled1.ipynb | 185 -- .../bharthkumar_version_backup/Untitled1.ipynb | 185 ++ sample_notebooks/ebbygeorge/Ch1.ipynb | 87 - .../ebbygeorge/ebbygeorge_version_backup/Ch1.ipynb | 87 + .../harikagunturu/Chapter_4_Angle_Modulation.ipynb | 666 ----- .../Chapter_4_Angle.ipynb | 666 +++++ sample_notebooks/hemanth/Untitled1.ipynb | 27 - .../hemanth/hemanth_version_backup/Untitled1.ipynb | 27 + .../karansingh/Thyristors_Principles_&.ipynb | 209 ++ .../Thyristors_Principles_&_Characeristics.ipynb | 209 -- sample_notebooks/kartiksankhla/Chapter2.ipynb | 217 +- .../kartiksankhla/Chapter2_WEIco2c.ipynb | 250 -- .../keerthi vanigundla/R.K.RAJPUTCHAPTER_12.ipynb | 292 --- .../R.K.RAJPUTCHAPTER_12.ipynb | 292 +++ .../r.k.shukla.ipynb | 379 +++ .../keerthi vanigundla/r.k.shukla.ipynb | 379 --- .../samplebook(process_heat.ipynb | 278 ++ .../samplebook(process_heat_transfer)_1.ipynb | 281 +++ .../samplebook(process_heat_transfer).ipynb | 278 -- .../samplebook(process_heat_transfer)_1.ipynb | 281 --- .../Chapter_1_Stress,Axial_load_and_Safety.ipynb | 395 +++ ...r_1_Stress,Axial_load_and_Safety_concepts.ipynb | 395 --- sample_notebooks/kumargugloth/Chapter1.ipynb | 290 +-- .../kumargugloth/Chapter1_wopEYRj.ipynb | 130 - .../Chapter_1_-_Overview_of_optical_fiber.ipynb | 251 ++ ...-_Overview_of_optical_fiber_communication.ipynb | 251 -- sample_notebooks/lalithap/CHAPTER_10.ipynb | 438 ---- .../lalithap_version_backup/CHAPTER_10.ipynb | 438 ++++ sample_notebooks/maheshvattikuti/chapter1.ipynb | 1147 --------- .../maheshvattikuti_version_backup/chapter1.ipynb | 1147 +++++++++ .../Chapter_2_Nuclear_Sturcture_and.ipynb | 234 ++ ...ter_2_Nuclear_Sturcture_and_Radioactivity.ipynb | 234 -- .../Chapter_5_Imperfection_in.ipynb | 227 ++ .../Chapter_5_Imperfection_in_Solids.ipynb | 227 -- .../manchukondasrinivasa rao/Chapter_7_Wave.ipynb | 299 +++ .../Chapter_7_Wave_Guides.ipynb | 299 --- ...iffusion_and_Reaction_in_Porous_Catalysts.ipynb | 303 --- .../Sample_(chapter.ipynb | 247 ++ .../Sample_(chapter_9).ipynb | 247 -- ...hapter_4_Diffusion_and_Reaction_in_Porous.ipynb | 303 +++ sample_notebooks/mokshagunda/Chapter_2.ipynb | 365 +++ .../mokshagunda/Chapter_2_DIFFRACTION.ipynb | 365 --- sample_notebooks/nishumittal/chapter1.ipynb | 165 -- sample_notebooks/nishumittal/chapter2.ipynb | 710 ------ .../nishumittal_version_backup/chapter1.ipynb | 165 ++ .../nishumittal_version_backup/chapter2.ipynb | 710 ++++++ .../pramodkumardesu/Chapter_2_Transmission.ipynb | 263 ++ .../Chapter_2_Transmission_Lines.ipynb | 263 -- .../Chapter_1_Basics_of_thermodynamics.ipynb | 461 ++++ ...pter_1_Basics_of_thermodynamics_Rudramani.ipynb | 461 ---- .../sai kiranmalepati/Sample_Notebook.ipynb | 349 --- .../sai kiranmalepati_version_backup/Sample.ipynb | 349 +++ sample_notebooks/saikomalchanagam/AKmaini.ipynb | 293 +++ .../saikomalchanagam/AKmaini_(1).ipynb | 293 --- sample_notebooks/srinivasparupalli/CHAPTER_1.ipynb | 347 --- sample_notebooks/srinivasparupalli/CHAPTER_3.ipynb | 310 --- .../CHAPTER_1.ipynb | 347 +++ .../CHAPTER_3.ipynb | 310 +++ sample_notebooks/sriragap/CHAPTER_2.ipynb | 294 --- .../sriragap_version_backup/CHAPTER_2.ipynb | 294 +++ .../Chapter_5_Force_Torque_and_Shaft_power.ipynb | 265 ++ ..._Force_Torque_and_Shaft_power_Measurement.ipynb | 265 -- sample_notebooks/vijayadurga/sample_(chapter.ipynb | 410 +++ .../vijayadurga/sample_(chapter_3).ipynb | 410 --- .../yashwanth kumarmada/Chapter_5.ipynb | 272 ++ .../yashwanth kumarmada/Chapter_5_Laser.ipynb | 272 -- sample_notebooks/yashwanth kumarmada/sample.ipynb | 414 +++ .../yashwanth kumarmada/sample_notes.ipynb | 414 --- 478 files changed, 110783 insertions(+), 115578 deletions(-) create mode 100755 sample_notebooks/ABHISHEKAGRAWAL/ABHISHEKAGRAWAL_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/ABHISHEKAGRAWAL/chapter2.ipynb create mode 100755 sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11.ipynb create mode 100755 sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_1.ipynb create mode 100755 sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_2.ipynb delete mode 100755 sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance.ipynb delete mode 100755 sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_(1).ipynb delete mode 100755 sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_1.ipynb delete mode 100755 sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_2.ipynb create mode 100755 sample_notebooks/ARIJITCHATTERJEE/ARIJITCHATTERJEE_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/ARIJITCHATTERJEE/chapter1.ipynb create mode 100755 sample_notebooks/Abu BakkerSiddik/Functions.ipynb delete mode 100755 sample_notebooks/Abu BakkerSiddik/Functions_.ipynb create mode 100755 sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8.ipynb create mode 100755 sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-.ipynb create mode 100755 sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-_Gravitation_1.ipynb delete mode 100755 sample_notebooks/AdityaAnand/Chapter_8.ipynb delete mode 100755 sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation.ipynb delete mode 100755 sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation_1.ipynb create mode 100755 sample_notebooks/AdityaR/AdityaR_version_backup/Chapter_5-Sample.ipynb delete mode 100755 sample_notebooks/AdityaR/Chapter_5-Sample_Notebook.ipynb create mode 100755 sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler.ipynb create mode 100755 sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED.ipynb create mode 100755 sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED_(1).ipynb delete mode 100755 sample_notebooks/AjaySatish/Sample_H.S._Fogler.ipynb delete mode 100755 sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED.ipynb delete mode 100755 sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED_(1).ipynb delete mode 100755 sample_notebooks/Akshay Ghogare/AKSHAY_GHOGARE.ipynb create mode 100755 sample_notebooks/Akshay Ghogare/Akshay Ghogare_version_backup/AKSHAY.ipynb create mode 100755 sample_notebooks/AkshayPatil/AkshayPatil_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/AkshayPatil/chapter1.ipynb create mode 100755 sample_notebooks/AkshayShende/AkshayShende_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/AkshayShende/chapter2.ipynb delete mode 100755 sample_notebooks/AlokDadlani/ALOK_DADLANI.ipynb create mode 100755 sample_notebooks/AlokDadlani/AlokDadlani_version_backup/ALOK.ipynb create mode 100755 sample_notebooks/Aman KumarJain/Aman KumarJain_version_backup/Chapter_6_Objects_and.ipynb delete mode 100755 sample_notebooks/Aman KumarJain/Chapter_6_Objects_and_Classes.ipynb create mode 100755 sample_notebooks/AnaySonawane/Solid_State_electronics.ipynb delete mode 100755 sample_notebooks/AnaySonawane/Solid_State_electronics_Ch1.ipynb create mode 100755 sample_notebooks/AnkitKumar/AnkitKumar_version_backup/Ch16.ipynb delete mode 100755 sample_notebooks/AnkitKumar/Ch16.ipynb create mode 100755 sample_notebooks/Anshulkhare/Anshulkhare_version_backup/Chapter9.ipynb delete mode 100755 sample_notebooks/Anshulkhare/Chapter9.ipynb create mode 100755 sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3.ipynb create mode 100755 sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3_1.ipynb delete mode 100755 sample_notebooks/ApurvaBhushan/Chapter_3.ipynb delete mode 100755 sample_notebooks/ApurvaBhushan/Chapter_3_1.ipynb create mode 100755 sample_notebooks/Ashish KumarSingh/Chapter.ipynb delete mode 100755 sample_notebooks/Ashish KumarSingh/Chapter_First.ipynb create mode 100755 sample_notebooks/AumkarRane/AumkarRane_version_backup/Chapter9.ipynb delete mode 100755 sample_notebooks/AumkarRane/Chapter9.ipynb create mode 100755 sample_notebooks/AviralYadav/AviralYadav_version_backup/Chapter9.ipynb delete mode 100755 sample_notebooks/AviralYadav/Chapter9.ipynb create mode 100755 sample_notebooks/AzagumozhiMadhaiyan/Chapter8.ipynb delete mode 100755 sample_notebooks/AzagumozhiMadhaiyan/Chapter_8_.ipynb create mode 100755 sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL.ipynb delete mode 100755 sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL_STRUCTURES.ipynb create mode 100755 sample_notebooks/DanishAnsari/DanishAnsari_version_backup/chapter_1.ipynb delete mode 100755 sample_notebooks/DanishAnsari/chapter_1.ipynb delete mode 100755 sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb create mode 100755 sample_notebooks/DaudIbrahir Saifi/DaudIbrahir Saifi_version_backup/Chapter_07.ipynb create mode 100755 sample_notebooks/DeepTrambadia/DeepTrambadia_version_backup/sc201.ipynb create mode 100755 sample_notebooks/DeepTrambadia/Diode.ipynb delete mode 100755 sample_notebooks/DeepTrambadia/Diode_Applications.ipynb delete mode 100755 sample_notebooks/DeepTrambadia/sc201.ipynb create mode 100755 sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication.ipynb delete mode 100755 sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication_Systems.ipynb create mode 100755 sample_notebooks/Dileep KumarShakya/Dileep KumarShakya_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/Dileep KumarShakya/chapter1.ipynb create mode 100755 sample_notebooks/DivyangGandhi/DivyangGandhi_version_backup/ch2.ipynb delete mode 100755 sample_notebooks/DivyangGandhi/ch2.ipynb create mode 100755 sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices.ipynb delete mode 100755 sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices_Fundamentals.ipynb create mode 100755 sample_notebooks/Ershad AhamedChemmalasseri/Ershad AhamedChemmalasseri_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/Ershad AhamedChemmalasseri/chapter1.ipynb create mode 100755 sample_notebooks/GauravMittal/GauravMittal_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/GauravMittal/chapter2.ipynb create mode 100755 sample_notebooks/GirishVora/GirishVora_version_backup/ch2.ipynb delete mode 100755 sample_notebooks/GirishVora/ch2.ipynb create mode 100755 sample_notebooks/Gopi KrishnaManchukonda/Chapter2Electrostatics.ipynb delete mode 100755 sample_notebooks/Gopi KrishnaManchukonda/Chapter8.ipynb delete mode 100755 sample_notebooks/Gopi KrishnaManchukonda/Chapter_2_Electrostatics_.ipynb create mode 100755 sample_notebooks/Gopi KrishnaManchukonda/Gopi KrishnaManchukonda_version_backup/Chapter8.ipynb delete mode 100755 sample_notebooks/GudePrithvi/Chapter_3.ipynb create mode 100755 sample_notebooks/GudePrithvi/GudePrithvi_version_backup/Chapter_3.ipynb delete mode 100755 sample_notebooks/GundaChaitnaya rani/Chapter_3_Ionization_and_Deionization_Processes_in_gases.ipynb create mode 100755 sample_notebooks/GundaChaitnaya rani/GundaChaitnaya rani_version_backup/Chapter_3_Ionization_and_Deionization_Processes_in.ipynb create mode 100755 sample_notebooks/GundlaKeerthi vani/GundlaKeerthi vani_version_backup/J.B.Gupta_Chapter_6_(1).ipynb delete mode 100755 sample_notebooks/GundlaKeerthi vani/J.B.Gupta_Chapter_6_(1).ipynb delete mode 100755 sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS_.ipynb delete mode 100755 sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb create mode 100755 sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter1-INTRODUCTIONTOMECHANICSOFSOLIDS.ipynb create mode 100755 sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb create mode 100755 sample_notebooks/HeminChheda/HeminChheda_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/HeminChheda/chapter1.ipynb delete mode 100755 sample_notebooks/Hrituraj/Ch-6.ipynb create mode 100755 sample_notebooks/Hrituraj/Hrituraj_version_backup/Ch-6.ipynb create mode 100755 sample_notebooks/Hrituraj/Various_types_of.ipynb delete mode 100755 sample_notebooks/Hrituraj/Various_types_of_tarrifs.ipynb create mode 100755 sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL.ipynb delete mode 100755 sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL_STRUCTURES.ipynb create mode 100755 sample_notebooks/JagadeeshwarGoshika/JagadeeshwarGoshika_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/JagadeeshwarGoshika/chapter1.ipynb create mode 100755 sample_notebooks/JaiMathur/JaiMathur_version_backup/ch2.ipynb delete mode 100755 sample_notebooks/JaiMathur/ch2.ipynb create mode 100755 sample_notebooks/JayDadlani/SAMPLE_NB_KI.ipynb delete mode 100755 sample_notebooks/JayDadlani/SAMPLE_NB_KI_KAPOOR.ipynb delete mode 100755 sample_notebooks/Jaya Sravya/Chapter10.ipynb create mode 100755 sample_notebooks/Jaya Sravya/Jaya Sravya_version_backup/Chapter10.ipynb delete mode 100755 sample_notebooks/KARTHIKEYAN S/CHAPTER_1.ipynb create mode 100755 sample_notebooks/KARTHIKEYAN S/KARTHIKEYAN S_version_backup/CHAPTER_1.ipynb delete mode 100755 sample_notebooks/KAVANA B/CHAPTER.ipynb create mode 100755 sample_notebooks/KAVANA B/KAVANA B_version_backup/CHAPTER.ipynb create mode 100755 sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction.ipynb delete mode 100755 sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction_Turbines.ipynb delete mode 100755 sample_notebooks/KavinkumarD/Chapter_8_FREQUENCY_EFFECTS_IN_AMPLIFIERS.ipynb create mode 100755 sample_notebooks/KavinkumarD/KavinkumarD_version_backup/Chapter_8_FREQUENCY_EFFECTS_IN.ipynb create mode 100755 sample_notebooks/KhushbuPattani/KhushbuPattani_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/KhushbuPattani/chapter1.ipynb create mode 100755 sample_notebooks/KonasaniSai Dheeraj/sample(chapter.ipynb delete mode 100755 sample_notebooks/KonasaniSai Dheeraj/sample(chapter_1).ipynb create mode 100755 sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb delete mode 100755 sample_notebooks/KonasaniSai Dheeraj/sample_(chapter_6).ipynb create mode 100755 sample_notebooks/LalitKumar/LalitKumar_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/LalitKumar/chapter2.ipynb create mode 100755 sample_notebooks/LaxmanSole/LaxmanSole_version_backup/Pinciples_of_electronic_Instrumentation.ipynb delete mode 100755 sample_notebooks/LaxmanSole/Pinciples_of_electronic_Instrumentation_Ch1.ipynb create mode 100755 sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave.ipynb delete mode 100755 sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave_Guides.ipynb create mode 100755 sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1.ipynb delete mode 100755 sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1_Gravity.ipynb create mode 100755 sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring.ipynb delete mode 100755 sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring_Instruments.ipynb create mode 100755 sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian.ipynb delete mode 100755 sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian_Measure.ipynb create mode 100755 sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical.ipynb delete mode 100755 sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb create mode 100755 sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight.ipynb delete mode 100755 sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight_line.ipynb create mode 100755 sample_notebooks/ManikandanD/chapter1.ipynb delete mode 100755 sample_notebooks/ManikandanD/chapter_1_.ipynb create mode 100755 sample_notebooks/MaulikRathod/MaulikRathod_version_backup/ch11.ipynb delete mode 100755 sample_notebooks/MaulikRathod/ch11.ipynb create mode 100755 sample_notebooks/MayankSahu/Chapter1.ipynb delete mode 100755 sample_notebooks/MayankSahu/Chapter1_.ipynb create mode 100755 sample_notebooks/MayankSahu/Chapter5.ipynb delete mode 100755 sample_notebooks/MayankSahu/Chapter5_.ipynb create mode 100644 sample_notebooks/Mayur Phadtare/Mayur Phadtare_version_backup/chapter.3.ipynb delete mode 100644 sample_notebooks/Mayur Phadtare/chapter_no.3.ipynb create mode 100755 sample_notebooks/MeenaChandrupatla/Chapter2.ipynb delete mode 100755 sample_notebooks/MeenaChandrupatla/Chapter2_Gases.ipynb create mode 100755 sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic.ipynb delete mode 100755 sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic_Circuits.ipynb create mode 100755 sample_notebooks/MeenaChandrupatla/Chapter_2_The.ipynb delete mode 100755 sample_notebooks/MeenaChandrupatla/Chapter_2_The_Device.ipynb create mode 100755 sample_notebooks/MohdAnwar/MohdAnwar_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/MohdAnwar/chapter1.ipynb create mode 100755 sample_notebooks/MohdAsif/Chapter2,_Measurement.ipynb delete mode 100755 sample_notebooks/MohdAsif/Chapter2,_Measurement_Errors.ipynb create mode 100755 sample_notebooks/MohdAsif/Chapter2_-_Measurement.ipynb delete mode 100755 sample_notebooks/MohdAsif/Chapter2_-_Measurement_Errors.ipynb create mode 100755 sample_notebooks/MohdAsif/MohdAsif_version_backup/ch2.ipynb create mode 100755 sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/MohdAsif/ch2.ipynb delete mode 100755 sample_notebooks/MohdAsif/chapter1.ipynb delete mode 100755 sample_notebooks/MohdAsif/chapter2.ipynb create mode 100755 sample_notebooks/MohdGufran/MohdGufran_version_backup/chapter_10.ipynb delete mode 100755 sample_notebooks/MohdGufran/chapter_10.ipynb delete mode 100755 sample_notebooks/MohdRizwan/Chapter8.ipynb create mode 100755 sample_notebooks/MohdRizwan/MohdRizwan_version_backup/Chapter8.ipynb create mode 100755 sample_notebooks/MukteshChaudhary/MukteshChaudhary_version_backup/ch2.ipynb delete mode 100755 sample_notebooks/MukteshChaudhary/ch2.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb delete mode 100755 sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb create mode 100755 sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb create mode 100755 sample_notebooks/NagadeviPriya/NagadeviPriya_version_backup/Sample.ipynb delete mode 100755 sample_notebooks/NagadeviPriya/Sample_Notebook.ipynb delete mode 100755 sample_notebooks/Namratha Reddy/chapter3_(1).ipynb delete mode 100755 sample_notebooks/NarasimhaMamidala/Chapter_4_BJT_Fundamentals.ipynb create mode 100755 sample_notebooks/NarasimhaMamidala/NarasimhaMamidala_version_backup/Chapter_4_BJT.ipynb create mode 100755 sample_notebooks/NarayaniGurumoorthy/NarayaniGurumoorthy_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/NarayaniGurumoorthy/chapter1.ipynb create mode 100755 sample_notebooks/NeerajBaunthiyal/NeerajBaunthiyal_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/NeerajBaunthiyal/chapter1.ipynb create mode 100755 sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2.ipynb create mode 100755 sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2_1.ipynb delete mode 100755 sample_notebooks/NirenNegandhi/ch2.ipynb delete mode 100755 sample_notebooks/NirenNegandhi/ch2_1.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb delete mode 100755 sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb create mode 100755 sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_(1).ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb delete mode 100755 sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb create mode 100644 sample_notebooks/Nitin Kumar/Nitin Kumar_version_backup/chapter2.ipynb delete mode 100644 sample_notebooks/Nitin Kumar/chapter2.ipynb create mode 100755 sample_notebooks/NityaL/NityaL_version_backup/Sample-Chapter_26.ipynb create mode 100755 sample_notebooks/NityaL/NityaL_version_backup/Sample.ipynb delete mode 100755 sample_notebooks/NityaL/Sample-Chapter_26.ipynb delete mode 100755 sample_notebooks/NityaL/Sample.ipynb create mode 100755 sample_notebooks/NivethaChezhian/NivethaChezhian_version_backup/Sample.ipynb delete mode 100755 sample_notebooks/NivethaChezhian/Sample_Notebook.ipynb delete mode 100755 sample_notebooks/PRAVEENKUMAR C/CHAPTER_1.ipynb create mode 100755 sample_notebooks/PRAVEENKUMAR C/PRAVEENKUMAR C_version_backup/CHAPTER_1.ipynb delete mode 100755 sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta.ipynb delete mode 100755 sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb delete mode 100755 sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb create mode 100755 sample_notebooks/PrashantSahu/Chapter_2_Molecular.ipynb delete mode 100755 sample_notebooks/PrashantSahu/Chapter_2_Molecular_Diffusion.ipynb create mode 100755 sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K.ipynb create mode 100755 sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb create mode 100755 sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb create mode 100755 sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/PraveenKumar/chapter1.ipynb delete mode 100755 sample_notebooks/PraveenKumar/chapter2.ipynb create mode 100755 sample_notebooks/PreetiRani/Operational.ipynb delete mode 100755 sample_notebooks/PreetiRani/Operational_Amplifiers.ipynb create mode 100755 sample_notebooks/RONAKBANSAL/RONAKBANSAL_version_backup/chapter_1.ipynb delete mode 100755 sample_notebooks/RONAKBANSAL/chapter_1.ipynb create mode 100644 sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat.ipynb delete mode 100644 sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat_Trasnfer.ipynb create mode 100755 sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1.ipynb create mode 100755 sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1_1.ipynb delete mode 100755 sample_notebooks/Raj Phani/chapter1.ipynb delete mode 100755 sample_notebooks/Raj Phani/chapter_1.ipynb delete mode 100755 sample_notebooks/Raj Phani/chapter_1_1.ipynb create mode 100755 sample_notebooks/RaviGarg/RaviGarg_version_backup/chap1.ipynb delete mode 100755 sample_notebooks/RaviGarg/chap1.ipynb delete mode 100755 sample_notebooks/RavirajJadeja/ch16.ipynb create mode 100755 sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of.ipynb delete mode 100755 sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of_Material.ipynb create mode 100755 sample_notebooks/RohitPhadtare/RohitPhadtare_version_backup/chapter.6.ipynb create mode 100755 sample_notebooks/RohitPhadtare/chapter_1.ipynb delete mode 100755 sample_notebooks/RohitPhadtare/chapter_1_som.ipynb delete mode 100755 sample_notebooks/RohitPhadtare/chapter_no.6.ipynb delete mode 100755 sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures.ipynb delete mode 100755 sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb delete mode 100755 sample_notebooks/RohithYeedulapalli/Chapter_7.ipynb delete mode 100755 sample_notebooks/RohithYeedulapalli/Chapter_7_1.ipynb create mode 100755 sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures.ipynb create mode 100755 sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb create mode 100755 sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7.ipynb create mode 100755 sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7_1.ipynb create mode 100755 sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chap1.ipynb create mode 100755 sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/RuchiMittal/chap1.ipynb delete mode 100755 sample_notebooks/RuchiMittal/chapter1.ipynb delete mode 100755 sample_notebooks/SINDHUARROJU/Chapter10.ipynb create mode 100755 sample_notebooks/SINDHUARROJU/SINDHUARROJU_version_backup/Chapter10.ipynb mode change 100755 => 100644 sample_notebooks/SPANDANAARROJU/Chapter4.ipynb delete mode 100644 sample_notebooks/SPANDANAARROJU/Chapter4_J3M7PEz.ipynb delete mode 100755 sample_notebooks/Sadananda CharyArroju/Chapter10.ipynb create mode 100755 sample_notebooks/Sadananda CharyArroju/Sadananda CharyArroju_version_backup/Chapter10.ipynb create mode 100755 sample_notebooks/SaiRakesh/SaiRakesh_version_backup/chapter_1.ipynb delete mode 100755 sample_notebooks/SaiRakesh/chapter_1.ipynb create mode 100755 sample_notebooks/SakshiGoplani/SakshiGoplani_version_backup/Sample.ipynb delete mode 100755 sample_notebooks/SakshiGoplani/Sample.ipynb delete mode 100755 sample_notebooks/SaleemAhmed/Chapter10.ipynb create mode 100755 sample_notebooks/SaleemAhmed/SaleemAhmed_version_backup/Chapter10.ipynb create mode 100755 sample_notebooks/SalilKapur/IntroductionConcept_of.ipynb delete mode 100755 sample_notebooks/SalilKapur/IntroductionConcept_of_Stress.ipynb delete mode 100755 sample_notebooks/SantoshPawar/Chapter9.ipynb create mode 100755 sample_notebooks/SantoshPawar/SantoshPawar_version_backup/Chapter9.ipynb create mode 100755 sample_notebooks/SaurabhBarot/SaurabhBarot_version_backup/ch2.ipynb delete mode 100755 sample_notebooks/SaurabhBarot/ch2.ipynb delete mode 100755 sample_notebooks/SayanDas Karmakar/Chapter_4.ipynb create mode 100755 sample_notebooks/SayanDas Karmakar/SayanDas Karmakar_version_backup/Chapter_4.ipynb create mode 100755 sample_notebooks/ShantanuBhosale/ShantanuBhosale_version_backup/chapter40.ipynb delete mode 100755 sample_notebooks/ShantanuBhosale/chapter40.ipynb create mode 100755 sample_notebooks/ShivaAmruthavakkula/ShivaAmruthavakkula_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb create mode 100644 sample_notebooks/ShubhamDahiphale/ShubhamDahiphale_version_backup/chapter_1.ipynb delete mode 100644 sample_notebooks/ShubhamDahiphale/chapter_1.ipynb create mode 100755 sample_notebooks/SoumenGanguly/ncert.ipynb delete mode 100755 sample_notebooks/SoumenGanguly/ncert_Maths.ipynb delete mode 100755 sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up.ipynb delete mode 100755 sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb create mode 100755 sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and.ipynb create mode 100755 sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb delete mode 100755 sample_notebooks/SudheerBommisetty/Chapter_4_Op_Amps_as_AC_Amplifiers.ipynb create mode 100755 sample_notebooks/SudheerBommisetty/SudheerBommisetty_version_backup/Chapter_4_Op_Amps_as_AC.ipynb create mode 100644 sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/ch2.ipynb create mode 100755 sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/chapter-4.ipynb delete mode 100644 sample_notebooks/Suhaib Alam/ch2.ipynb delete mode 100755 sample_notebooks/Suhaib Alam/chapter-4.ipynb create mode 100755 sample_notebooks/SumadhuriDamerla/Chapter_1_Passive.ipynb delete mode 100755 sample_notebooks/SumadhuriDamerla/Chapter_1_Passive_Circuits.ipynb create mode 100644 sample_notebooks/SumedhKadam/Chapter_1_General.ipynb delete mode 100644 sample_notebooks/SumedhKadam/Chapter_1_General_Principles.ipynb delete mode 100755 sample_notebooks/SwathiSyamala/Chapter_6_IMPEDENCE_MATCHING_AND_TUNNING.ipynb create mode 100755 sample_notebooks/SwathiSyamala/SwathiSyamala_version_backup/Chapter_6_IMPEDENCE_MATCHING_AND.ipynb delete mode 100755 sample_notebooks/Tarun KumarDas/Chapter9.ipynb delete mode 100755 sample_notebooks/Tarun KumarDas/Chapter9_2.ipynb delete mode 100755 sample_notebooks/Tarun KumarDas/Chapter9_3.ipynb delete mode 100755 sample_notebooks/Tarun KumarDas/Chapter9_4.ipynb create mode 100755 sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9.ipynb create mode 100755 sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_2.ipynb create mode 100755 sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_3.ipynb create mode 100755 sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_4.ipynb create mode 100755 sample_notebooks/TestUser/TestUser_version_backup/chapter1.ipynb delete mode 100755 sample_notebooks/TestUser/chapter1.ipynb delete mode 100755 sample_notebooks/UmangAgarwal/Sample_Notebook.ipynb delete mode 100755 sample_notebooks/UmangAgarwal/Sample_Notebook_Umang.ipynb create mode 100755 sample_notebooks/UmangAgarwal/UmangAgarwal_version_backup/Sample.ipynb create mode 100755 sample_notebooks/Vaibhav Vajani/Vaibhav Vajani_version_backup/chapter2.ipynb delete mode 100755 sample_notebooks/Vaibhav Vajani/chapter2.ipynb create mode 100755 sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric.ipynb delete mode 100755 sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric_Fields.ipynb create mode 100755 sample_notebooks/Vedantam Lakshmi Manasa/Mathematical.ipynb delete mode 100755 sample_notebooks/Vedantam Lakshmi Manasa/Mathematical_Foundation.ipynb create mode 100755 sample_notebooks/VidyashankarVenkatraman/Chapter_3.ipynb delete mode 100755 sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kittel.ipynb delete mode 100755 sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kitteldemo.ipynb create mode 100755 sample_notebooks/VidyashankarVenkatraman/VidyashankarVenkatraman_version_backup/Chapter_3.ipynb delete mode 100755 sample_notebooks/VikasPrasad/Chapter_01.ipynb delete mode 100755 sample_notebooks/VikasPrasad/Chapter_01_1.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01_1.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_3.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_4.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_5.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_6.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_7.ipynb create mode 100755 sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_8.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_3.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_4.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_5.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_6.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_7.ipynb delete mode 100755 sample_notebooks/VikasPrasad/chapter1_8.ipynb delete mode 100755 sample_notebooks/VineshSaini/Ch1.ipynb create mode 100755 sample_notebooks/VineshSaini/VineshSaini_version_backup/Ch1.ipynb delete mode 100755 sample_notebooks/YogeshPatil/Chapter_11.ipynb delete mode 100755 sample_notebooks/YogeshPatil/Chapter_11_1.ipynb create mode 100755 sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11.ipynb create mode 100755 sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11_1.ipynb delete mode 100755 sample_notebooks/abhishekchauhan/Chapter10.ipynb create mode 100755 sample_notebooks/abhishekchauhan/abhishekchauhan_version_backup/Chapter10.ipynb delete mode 100755 sample_notebooks/ajinkyakhair/Untitled3.ipynb create mode 100755 sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/Untitled3.ipynb create mode 100755 sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/chapter2.ipynb mode change 100755 => 100644 sample_notebooks/ajinkyakhair/chapter2.ipynb delete mode 100644 sample_notebooks/ajinkyakhair/chapter2_8f8MyfH.ipynb create mode 100755 sample_notebooks/anubhav gupta/anubhav gupta_version_backup/chapter15.ipynb delete mode 100755 sample_notebooks/anubhav gupta/chapter15.ipynb delete mode 100755 sample_notebooks/asmitaasmita/1_An_overview_of_C++.ipynb delete mode 100755 sample_notebooks/asmitaasmita/1_An_overview_of_C++_1.ipynb create mode 100755 sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of.ipynb create mode 100755 sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of_C++_1.ipynb delete mode 100755 sample_notebooks/bharthkumar/Untitled1.ipynb create mode 100755 sample_notebooks/bharthkumar/bharthkumar_version_backup/Untitled1.ipynb delete mode 100644 sample_notebooks/ebbygeorge/Ch1.ipynb create mode 100644 sample_notebooks/ebbygeorge/ebbygeorge_version_backup/Ch1.ipynb delete mode 100755 sample_notebooks/harikagunturu/Chapter_4_Angle_Modulation.ipynb create mode 100755 sample_notebooks/harikagunturu/harikagunturu_version_backup/Chapter_4_Angle.ipynb delete mode 100755 sample_notebooks/hemanth/Untitled1.ipynb create mode 100755 sample_notebooks/hemanth/hemanth_version_backup/Untitled1.ipynb create mode 100755 sample_notebooks/karansingh/Thyristors_Principles_&.ipynb delete mode 100755 sample_notebooks/karansingh/Thyristors_Principles_&_Characeristics.ipynb mode change 100755 => 100644 sample_notebooks/kartiksankhla/Chapter2.ipynb delete mode 100644 sample_notebooks/kartiksankhla/Chapter2_WEIco2c.ipynb delete mode 100755 sample_notebooks/keerthi vanigundla/R.K.RAJPUTCHAPTER_12.ipynb create mode 100755 sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/R.K.RAJPUTCHAPTER_12.ipynb create mode 100755 sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/r.k.shukla.ipynb delete mode 100755 sample_notebooks/keerthi vanigundla/r.k.shukla.ipynb create mode 100755 sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat.ipynb create mode 100755 sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat_transfer)_1.ipynb delete mode 100755 sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer).ipynb delete mode 100755 sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer)_1.ipynb create mode 100755 sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety.ipynb delete mode 100755 sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety_concepts.ipynb mode change 100755 => 100644 sample_notebooks/kumargugloth/Chapter1.ipynb delete mode 100644 sample_notebooks/kumargugloth/Chapter1_wopEYRj.ipynb create mode 100755 sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber.ipynb delete mode 100755 sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber_communication.ipynb delete mode 100755 sample_notebooks/lalithap/CHAPTER_10.ipynb create mode 100755 sample_notebooks/lalithap/lalithap_version_backup/CHAPTER_10.ipynb delete mode 100755 sample_notebooks/maheshvattikuti/chapter1.ipynb create mode 100755 sample_notebooks/maheshvattikuti/maheshvattikuti_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and.ipynb delete mode 100755 sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and_Radioactivity.ipynb create mode 100755 sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in.ipynb delete mode 100755 sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in_Solids.ipynb create mode 100755 sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave.ipynb delete mode 100755 sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave_Guides.ipynb delete mode 100755 sample_notebooks/marupeddisameer chaitanya/Chapter_4_Diffusion_and_Reaction_in_Porous_Catalysts.ipynb create mode 100755 sample_notebooks/marupeddisameer chaitanya/Sample_(chapter.ipynb delete mode 100755 sample_notebooks/marupeddisameer chaitanya/Sample_(chapter_9).ipynb create mode 100755 sample_notebooks/marupeddisameer chaitanya/marupeddisameer chaitanya_version_backup/Chapter_4_Diffusion_and_Reaction_in_Porous.ipynb create mode 100755 sample_notebooks/mokshagunda/Chapter_2.ipynb delete mode 100755 sample_notebooks/mokshagunda/Chapter_2_DIFFRACTION.ipynb delete mode 100755 sample_notebooks/nishumittal/chapter1.ipynb delete mode 100755 sample_notebooks/nishumittal/chapter2.ipynb create mode 100755 sample_notebooks/nishumittal/nishumittal_version_backup/chapter1.ipynb create mode 100755 sample_notebooks/nishumittal/nishumittal_version_backup/chapter2.ipynb create mode 100755 sample_notebooks/pramodkumardesu/Chapter_2_Transmission.ipynb delete mode 100755 sample_notebooks/pramodkumardesu/Chapter_2_Transmission_Lines.ipynb create mode 100644 sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics.ipynb delete mode 100644 sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics_Rudramani.ipynb delete mode 100644 sample_notebooks/sai kiranmalepati/Sample_Notebook.ipynb create mode 100644 sample_notebooks/sai kiranmalepati/sai kiranmalepati_version_backup/Sample.ipynb create mode 100755 sample_notebooks/saikomalchanagam/AKmaini.ipynb delete mode 100755 sample_notebooks/saikomalchanagam/AKmaini_(1).ipynb delete mode 100755 sample_notebooks/srinivasparupalli/CHAPTER_1.ipynb delete mode 100755 sample_notebooks/srinivasparupalli/CHAPTER_3.ipynb create mode 100755 sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_1.ipynb create mode 100755 sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_3.ipynb delete mode 100755 sample_notebooks/sriragap/CHAPTER_2.ipynb create mode 100755 sample_notebooks/sriragap/sriragap_version_backup/CHAPTER_2.ipynb create mode 100755 sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power.ipynb delete mode 100755 sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power_Measurement.ipynb create mode 100755 sample_notebooks/vijayadurga/sample_(chapter.ipynb delete mode 100755 sample_notebooks/vijayadurga/sample_(chapter_3).ipynb create mode 100755 sample_notebooks/yashwanth kumarmada/Chapter_5.ipynb delete mode 100755 sample_notebooks/yashwanth kumarmada/Chapter_5_Laser.ipynb create mode 100755 sample_notebooks/yashwanth kumarmada/sample.ipynb delete mode 100755 sample_notebooks/yashwanth kumarmada/sample_notes.ipynb (limited to 'sample_notebooks') diff --git a/sample_notebooks/ABHISHEKAGRAWAL/ABHISHEKAGRAWAL_version_backup/chapter2.ipynb b/sample_notebooks/ABHISHEKAGRAWAL/ABHISHEKAGRAWAL_version_backup/chapter2.ipynb new file mode 100755 index 00000000..1bfa373e --- /dev/null +++ b/sample_notebooks/ABHISHEKAGRAWAL/ABHISHEKAGRAWAL_version_backup/chapter2.ipynb @@ -0,0 +1,149 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:41187fe2c381fd7b42e97b2fb4a9a8ffca57cedad7f414bab15784b2fa882a72" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter2:ELECTROMAGNETIC PLANE WAVES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex2.6.5:pg-69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + " \n", + "import math \n", + "#(a) Program to find gold-film surface resistance \n", + " \n", + " \n", + "t=80*(10**(-10)) #Film Thickness\n", + "o=4.1*(10**7) #Bulk conductivity \n", + "p=570*(10**(-10)) #Electron mean free path \n", + "of=((3*t*o)/(4*p))*(0.4228 + math.log(p/t)) #the gold-film conductivity is of=(3*t*o/4*p)*(0.4228 + ln(p/t)) \n", + "\n", + "Rs=1/(t*of) #the gold-film surface resistance is given by Rs=1/(t*of) in Ohms per square\n", + "\n", + "\n", + "print\"The gold film surface resistance in Ohms per square is=\",round(Rs,2),\"Ohms/square\"\n", + "\n", + "\n", + "#(b) Program to find the microwave attenuation \n", + "\n", + "Attenuation=40-20*log10(Rs) #Microwave attenuation \n", + "\n", + "print\"Microwave Attenuation in db is=\",int(Attenuation),\"db\"\n", + "\n", + "\n", + "#(c)Light transmittance T\n", + "\n", + "print\"From figure No.2-6-5 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for gold film, we find that for given gold film of thickness 80 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 75%\"\n", + "\n", + "\n", + "#(d)light reflection loss R\n", + "\n", + "print\"From the same figure the LIGHT REFLECTION LOSS R is about 25%\"\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The gold film surface resistance in Ohms per square is= 12.14 Ohms/square\n", + "Microwave Attenuation in db is= 18 db\n", + "From figure No.2-6-5 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for gold film, we find that for given gold film of thickness 80 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 75%\n", + "From the same figure the LIGHT REFLECTION LOSS R is about 25%\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex2.6.6:pg-74" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math \n", + "#(a) Program to find copper-film surface resistance \n", + " \n", + " \n", + "t=60*(10**(-10)) #Film Thickness\n", + "o=5.8*(10**7) #Bulk conductivity \n", + "p=420*(10**(-10)) #Electron mean free path \n", + "of=((3*t*o)/(4*p))*(0.4228 + math.log(p/t)) #the copper-film conductivity is of=(3*t*o/4*p)*(0.4228 + ln(p/t))\n", + "Rs=1/(t*of) #the copper-film surface resistance is given by Rs=1/(t*of) in Ohms per square\n", + "\n", + "print\"The copper-film surface resistance in Ohms per square is=\",round(Rs,2),\"Ohms/square\"\n", + "\n", + "\n", + "#(b) Program to find the microwave attenuation \n", + "\n", + "Attenuation=40-20*log10(Rs) #Microwave attenuation \n", + "\n", + "print\"Microwave Attenuation in db is=\",int(round(Attenuation)),\"db\"\n", + "\n", + "#(c)Light transmittance T\n", + "\n", + "print\"From figure No.2-6-11 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for copper film, we find that for given copper film of thickness 60 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 82%\"\n", + "\n", + "#(d)light reflection loss R\n", + "\n", + "print\"From the same figure the LIGHT REFLECTION LOSS R is about 18%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The copper-film surface resistance in Ohms per square is= 11.32 Ohms/square\n", + "Microwave Attenuation in db is= 19 db\n", + "From figure No.2-6-11 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for copper film, we find that for given copper film of thickness 60 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 82%\n", + "From the same figure the LIGHT REFLECTION LOSS R is about 18%\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ABHISHEKAGRAWAL/chapter2.ipynb b/sample_notebooks/ABHISHEKAGRAWAL/chapter2.ipynb deleted file mode 100755 index 1bfa373e..00000000 --- a/sample_notebooks/ABHISHEKAGRAWAL/chapter2.ipynb +++ /dev/null @@ -1,149 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:41187fe2c381fd7b42e97b2fb4a9a8ffca57cedad7f414bab15784b2fa882a72" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter2:ELECTROMAGNETIC PLANE WAVES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2.6.5:pg-69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - " \n", - "import math \n", - "#(a) Program to find gold-film surface resistance \n", - " \n", - " \n", - "t=80*(10**(-10)) #Film Thickness\n", - "o=4.1*(10**7) #Bulk conductivity \n", - "p=570*(10**(-10)) #Electron mean free path \n", - "of=((3*t*o)/(4*p))*(0.4228 + math.log(p/t)) #the gold-film conductivity is of=(3*t*o/4*p)*(0.4228 + ln(p/t)) \n", - "\n", - "Rs=1/(t*of) #the gold-film surface resistance is given by Rs=1/(t*of) in Ohms per square\n", - "\n", - "\n", - "print\"The gold film surface resistance in Ohms per square is=\",round(Rs,2),\"Ohms/square\"\n", - "\n", - "\n", - "#(b) Program to find the microwave attenuation \n", - "\n", - "Attenuation=40-20*log10(Rs) #Microwave attenuation \n", - "\n", - "print\"Microwave Attenuation in db is=\",int(Attenuation),\"db\"\n", - "\n", - "\n", - "#(c)Light transmittance T\n", - "\n", - "print\"From figure No.2-6-5 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for gold film, we find that for given gold film of thickness 80 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 75%\"\n", - "\n", - "\n", - "#(d)light reflection loss R\n", - "\n", - "print\"From the same figure the LIGHT REFLECTION LOSS R is about 25%\"\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The gold film surface resistance in Ohms per square is= 12.14 Ohms/square\n", - "Microwave Attenuation in db is= 18 db\n", - "From figure No.2-6-5 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for gold film, we find that for given gold film of thickness 80 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 75%\n", - "From the same figure the LIGHT REFLECTION LOSS R is about 25%\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2.6.6:pg-74" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " \n", - "import math \n", - "#(a) Program to find copper-film surface resistance \n", - " \n", - " \n", - "t=60*(10**(-10)) #Film Thickness\n", - "o=5.8*(10**7) #Bulk conductivity \n", - "p=420*(10**(-10)) #Electron mean free path \n", - "of=((3*t*o)/(4*p))*(0.4228 + math.log(p/t)) #the copper-film conductivity is of=(3*t*o/4*p)*(0.4228 + ln(p/t))\n", - "Rs=1/(t*of) #the copper-film surface resistance is given by Rs=1/(t*of) in Ohms per square\n", - "\n", - "print\"The copper-film surface resistance in Ohms per square is=\",round(Rs,2),\"Ohms/square\"\n", - "\n", - "\n", - "#(b) Program to find the microwave attenuation \n", - "\n", - "Attenuation=40-20*log10(Rs) #Microwave attenuation \n", - "\n", - "print\"Microwave Attenuation in db is=\",int(round(Attenuation)),\"db\"\n", - "\n", - "#(c)Light transmittance T\n", - "\n", - "print\"From figure No.2-6-11 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for copper film, we find that for given copper film of thickness 60 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 82%\"\n", - "\n", - "#(d)light reflection loss R\n", - "\n", - "print\"From the same figure the LIGHT REFLECTION LOSS R is about 18%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The copper-film surface resistance in Ohms per square is= 11.32 Ohms/square\n", - "Microwave Attenuation in db is= 19 db\n", - "From figure No.2-6-11 of Light transmittance T and light attenuation loss L versus wavelength with film thickness t as parameter for copper film, we find that for given copper film of thickness 60 angstrom ,the LIGHT TRANSMITTANCE T is estimated to be 82%\n", - "From the same figure the LIGHT REFLECTION LOSS R is about 18%\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11.ipynb b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11.ipynb new file mode 100755 index 00000000..4f69b243 --- /dev/null +++ b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11.ipynb @@ -0,0 +1,2636 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:e85379c4218575d4b069259557cffbbc2d0259e3ba5d0e030c11dd77aae5e38d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.1, Page Number:444" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#A simple classA having a public data member x\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + "\n", + "#A simple classA having a public data member y \n", + "class B(A): #derived class\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + "b=B() #create a instance b of Derived class B\n", + "b.x=20\n", + "b.y=30\n", + "\n", + "print 'member of A:',b.x\n", + "print 'Member of B:',b.y" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "member of A: 20\n", + "Member of B: 30\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.2, Page Number:445" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self): #class A having x as a private data member\n", + " self.__x=20\n", + " \n", + " def showx(self):\n", + " print \"x=\",self.__x\n", + " \n", + " \n", + "class B(A): #Derived class\n", + " def __init__(self):\n", + " self.y=30 #class B having y as a public data member\n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx()\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B() #declaration of object\n", + " #class the method of derived class object by a derived class instance\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 30\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.3, Page Number:447" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None #x is a public member\n", + " \n", + " \n", + "#derived class\n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 \n", + " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", + " \n", + " def show(self):\n", + " print \"x=\",A.__x\n", + " print \"y=\",self.y\n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.4, Page Number:448" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self):\n", + " self.__x=20 #x is a privet member of it\n", + " \n", + " def showx(self): \n", + " print \"x=\",self.__x\n", + " \n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 #y is a public member of it\n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx() #call the base class method\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.5, Page Number:449" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self):\n", + " self._x=None #x is a protected member of the base class\n", + " \n", + " \n", + "class B(A): #private inheritance,x become a private member of the derived class\n", + " def __init__(self):\n", + " self.y=40\n", + " self.__x=30\n", + " \n", + " \n", + " def show(self):\n", + " print \"x=\",self.__x\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 30\n", + "y= 40\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.6, Page Number:456" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class ABC: #Base class\n", + " def __init__(self):\n", + " self._name=None #these 2 are protected data member\n", + " self._age=None\n", + " \n", + "class abc(ABC): #Derived class ,Public derivation\n", + " def __init__(self):\n", + " self.height=None\n", + " self.weight=None\n", + " \n", + " def getdata(self):\n", + " \n", + " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", + " self.age=raw_input(\"Enter a age: \") \n", + " self._height=raw_input(\"Enter a Height: \") \n", + " self._weight=raw_input(\"Enter a Weight: \") \n", + " \n", + " def show(self): #display the value of data members\n", + " print 'Name:',self.name \n", + " print 'Age:',self.age,\"years\"\n", + " print 'Height:',self._height,\"Feets\"\n", + " print 'Weight:',self._weight,\"kg.\"\n", + " \n", + " \n", + "x=abc()\n", + "x.getdata()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a name: Santosh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a age: 24\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Height: 4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Weight: 50\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Santosh\n", + "Age: 24 years\n", + "Height: 4.5 Feets\n", + "Weight: 50 kg.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.7, Page Number:458" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A1: #super Base class,have 2 protected data members\n", + " def __init__(self):\n", + " self._name=None\n", + " self._age=None\n", + "\n", + " \n", + "class A2(A1): #Public derivation\n", + " def __init(self):\n", + " self._height=None\n", + " self._weight=None\n", + "\n", + "class A3(A2): #public Derivation\n", + " def __init__(self):\n", + " self._sex=None\n", + " \n", + " \n", + " def get(self): #get input \n", + " self._name=raw_input(\"Name: \")\n", + " self._age=raw_input(\"Age: \")\n", + " self._sex=raw_input(\"Sex: \")\n", + " \n", + " self._height=raw_input(\"Height: \")\n", + " self._weight=raw_input(\"Weight: \")\n", + " \n", + " def show(self): #Display values of all the data members\n", + " print \"Name:\",self._name\n", + " print \"Age:\",self._age ,\"years\"\n", + " print \"Sex:\",self._sex\n", + " print \"Height:\",self._height ,\"Feet\"\n", + " print \"Weight:\",self._weight ,\"Kg.\"\n", + " \n", + "\n", + "x=A3()\n", + "x.get()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age: 26\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight: 49.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n", + "Age: 26 years\n", + "Sex: M\n", + "Height: 4 Feet\n", + "Weight: 49.5 Kg.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8, Page Number:459" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Example of multiple Inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self._a=None\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " self._b=None\n", + " \n", + " \n", + "class C:\n", + " def __init__(self):\n", + " self._c=None\n", + " \n", + "class D:\n", + " def __init__(self):\n", + " self._d=None\n", + " \n", + "class E(A,B,C,D): #inherites all the base classes publically\n", + " def __init__(self):\n", + " self.e=None\n", + " \n", + " def getdata(self):\n", + " print \"Enter the value of a,b,c &d &e:\"\n", + " self._a=input()\n", + " self._b=input()\n", + " self._c=input()\n", + " self._d=input()\n", + " self._e=input()\n", + " \n", + " def show(self):\n", + " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", + " \n", + " \n", + "x=E() #x is the instance of the derived class\n", + "x.getdata() #call the methods of derived class through x \n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a,b,c &d &e:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a= 1 b= 2 c= 4 d= 8 e= 16\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.9, Page Number:461" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class red: #these three base class\n", + " def __init__(self):\n", + " print \"Red\",\n", + " \n", + "class yellow:\n", + " def __init__(self):\n", + " print \"Yellow\",\n", + " \n", + "class blue:\n", + " def __init__(self):\n", + " print \"Blue\",\n", + " \n", + "class orange(red,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Orange\",\n", + " \n", + "class green(blue,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " blue.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Green\",\n", + " \n", + "class violet(red,blue): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " blue.__init__(self)\n", + " print \"=Violet\",\n", + " \n", + "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Reddishbrown\"\n", + " \n", + "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Yellowishbrown\"\n", + " \n", + "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Bluishbrown\"\n", + " \n", + " \n", + " \n", + "r=reddishbrown() #create instances of the derived class\n", + "b=bluishbrown()\n", + "y=yellowishbrown()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", + "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", + "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.10, Page Number:463" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# WAP to create a derived class from multiple base classes\n", + "\n", + "class PLAYER: #these three are the base classes\n", + " def __init__(self):\n", + " self._name=None\n", + " self._gender=None\n", + " self._age\n", + " \n", + "class PHYSIQUE(PLAYER):\n", + " def __init__(self):\n", + " self._height=None\n", + " self._weight=None\n", + " \n", + "class LOCATION:\n", + " def __init__(self):\n", + " self._city=None\n", + " self._pin=None\n", + " \n", + "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", + " def __init__(self):\n", + " self._game=None\n", + " def getdata(self): #Method to take inputes\n", + " print\"Enter the following information\\n\\n\"\n", + " self._name=raw_input(\"Name:\")\n", + " self._gender=raw_input(\"Gender:\")\n", + " self._age=raw_input(\"Age:\")\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " self._city=raw_input(\"City:\")\n", + " self._pin=raw_input(\"Pin:\")\n", + " self._game=raw_input(\"game:\")\n", + " \n", + " \n", + " \n", + " def show(self): #Method for displaying inputes\n", + " print\"Entered Information!!\"\n", + " print\"Name:\",self._name\n", + " print \"Gender:\",self._gender\n", + " print \"Age:\",self._age\n", + " print \"Height:\",self._height\n", + " print \"Weight:\",self._weight\n", + " print \"City :\",self._city\n", + " print \"Pincode:\",self._pin\n", + " print \"Game :\",self._game\n", + " \n", + " \n", + "G=GAME() #create an instance of the derived class\n", + "G.getdata() #call the public methods by the created instances\n", + "G.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the following information\n", + "\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Mahesh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gender:M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:55\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City:Nanded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pin:431603\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "game:Cricket\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entered Information!!\n", + "Name: Mahesh\n", + "Gender: M\n", + "Age: 25\n", + "Height: 4.9\n", + "Weight: 55\n", + "City : Nanded\n", + "Pincode: 431603\n", + "Game : Cricket\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.11, Page Number:467" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Multipath Inheritance,concept of virtual classes\n", + "\n", + "class A1: #Super base class\n", + " def __init__(self):\n", + " self._a1=None\n", + " \n", + "class A2(A1): #base class 1,inherites Super Base class\n", + " def __init__(self):\n", + " self._a2=None\n", + " \n", + "class A3(A1): #base class 2,inherites Super Base class\n", + " def __init__(self):\n", + " self._a3=None\n", + " \n", + "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", + " def __init__(self):\n", + " self.__a4=None\n", + " \n", + " def get(self):\n", + " print \"Enter the value of a1,a2,a3,and a4:\"\n", + " self._a1=input()\n", + " self._a2=input()\n", + " self._a3=input()\n", + " self.__a4=input()\n", + " \n", + " def put(self):\n", + " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", + " \n", + " \n", + " \n", + "a=A4() #create the instance of the derived class\n", + "a.get()\n", + "a.put()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a1,a2,a3,and a4:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 5 a2= 8 a3= 7 a4= 3\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.12, Page Number:469" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To show order of execution of the constructors and destructors in multiple inheritance\n", + "\n", + "#**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class A\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class A\"\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class B\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class B\"\n", + "\n", + "class C(A,B):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print\"Zero argument Constructor of base class C\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class C\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "c=C() #create instance of derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument Constructor of base class A\n", + "Zero argument Constructor of base class B\n", + "Zero argument Constructor of base class C\n", + "Destructor of class C\n", + "Destructor of class A\n", + "Destructor of class B\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.13, Page Number:471" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#WAP to use constructor and destructor in all the classess\n", + "\n", + "class A1:\n", + " def __init__(self): #take name and age as input in super base class\n", + " self._name=raw_input(\"Name:\")\n", + " self._age=raw_input(\"Age:\")\n", + " \n", + " def __del__(self):\n", + " print\"Name:\",self._name\n", + " print\"Age\",self._age\n", + " \n", + " \n", + "class A2(A1): #take height and weight as input in base base class,public derivation \n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " \n", + " def __del__(self):\n", + " print\"Height:\",self._height\n", + " print\"Weight:\",self._weight\n", + " A1.__del__(self)\n", + " \n", + " \n", + "class A3(A2): #take sex as input in derived class,derived from class A2\n", + " def __init__(self):\n", + " A2.__init__(self)\n", + " self.__sex=raw_input(\"Sex:\")\n", + " def __del__(self): #display all the input taken by all the base classes\n", + " print\"Sex:\",self.__sex\n", + " A2.__del__(self)\n", + " \n", + " \n", + "x=A3() #create instance x of the class A3\n", + "\n", + "del x #call the destructor" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex:M\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n", + "Height: 4.5\n", + "Weight: 40\n", + "Name: Ajay\n", + "Age 20\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14, Page Number:472" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To create derived class from the base class,by constructor and destructor\n", + "class in_t:\n", + " def __init__(self):\n", + " self._i=1\n", + " print\"Constructor in_t()\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor in_t()\"\n", + " \n", + "class floa_t:\n", + " def __init__(self):\n", + " self._f=1.5\n", + " print\"Constructor floa_t()\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor floa_t()\"\n", + " \n", + " \n", + "class cha_r(in_t,floa_t): #multiple derivation\n", + " def __init__(self):\n", + " self._c='A'\n", + " print\"Constructor cha_r()\"\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " \n", + " def show(self):\n", + " print\"i=\",self._i\n", + " print \"f=\",self._f\n", + " print \"c=\",self._c\n", + " \n", + " def __del__(self):\n", + " print \"Destructing cha_r()\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "a=cha_r() #create derived class instance and call the public method of the derived class\n", + "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor cha_r()\n", + "Constructor in_t()\n", + "Constructor floa_t()\n", + "i= 1\n", + "f= 1.5\n", + "c= A\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.15, Page Number:474" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "class I:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " self.__y=None\n", + " \n", + " def set(self,j,k):\n", + " self.x=j\n", + " self.__y=k\n", + " \n", + " def show(self):\n", + " print \"X=\",self.x, \"Y=\",self.__y\n", + " \n", + " \n", + "i=II()\n", + "i.set(4,5)\n", + "i.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "X= 4 Y= 5\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.16, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class I:\n", + " def __init__(self):\n", + " self.x=10\n", + " print \"In the Base class constuctor\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " self.__y=None\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In the Base class constuctor\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.17, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class without constructor and derived class with constructor\n", + "class I:\n", + " pass\n", + "class II(I):\n", + " def __init__(self):\n", + " print \"In derived class constructor\"\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In derived class constructor\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.18, Page Number:476" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#both the class have constructor\n", + "class I:\n", + " def __init__(self):\n", + " print \"In base class Constructor\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " print \"In derived Class constructor\"\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class Constructor\n", + "In derived Class constructor\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.19, Page Number:477" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple constructor in base class and single constructor in the derived class\n", + "\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument base class construtor\"\n", + " \n", + " def __init__(self,k):\n", + " self.x=None\n", + " print \"One argument base class construtor\"\n", + " \n", + " \n", + "class II(I):\n", + " def __init__(self,j,k=None): #default constructor\n", + " I.__init__(self,k)\n", + " self.__y=j\n", + " print \"One argument derived class constructor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class constructor\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.20, Page Number:478" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base and derived class without default constructor\n", + "class I:\n", + " def __init__(self,k):\n", + " self.x=k\n", + " print \"One argument base class construtor\"\n", + " \n", + "class II(I):\n", + " def __init__(self,j):\n", + " I.__init__(self,j)\n", + " self.__y=j\n", + " print \"One argument derived class construtor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class construtor\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.21, Page Number:479" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors and multiple inheritance\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #class III inhrites class II and I\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self) \n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #create an instance of the base class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.22, Page Number:480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors in multiple inhritance with invoking constructor of the base classes\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I):\n", + " def __init__(self):\n", + " II.__init__(self)\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.23, Page Number:481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple inheritance,invoking the base classes explicitly\n", + "\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.24, Page Number:482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multilevel Inheritance,observation of the execution of the constructors\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.25, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#use object of one class in another class as a member\n", + "class I:\n", + " def __init__(self):\n", + " self.x=20\n", + " print \"Constructor of class I\"\n", + " \n", + "class II:\n", + " \n", + " def __init__(self):\n", + " self.k=30\n", + " y=I()\n", + " print \"Constructor of class II\"\n", + " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", + " \n", + " \n", + " def show(self):\n", + " print \"k=\",self.k\n", + " \n", + "ii=II()\n", + "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class I\n", + "Constructor of class II\n", + "x= 20\n", + "k= 30\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.26, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access a member variable of base class using object,class name, and direct\n", + "\n", + "class A1:\n", + " def __init__(self):\n", + " self.name=None\n", + " self.age=None\n", + " \n", + "class A2(A1):\n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " a=A1()\n", + " print \"Access using name of the class:\"\n", + " A1.name=raw_input(\"Name:\")\n", + " A1.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using object of the class\"\n", + " a.name=raw_input(\"Name:\")\n", + " a.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using direct member variables:\"\n", + " self.name=raw_input(\"Name:\")\n", + " self.age=raw_input(\"Age:\")\n", + " self.__height=raw_input(\"Height:\")\n", + " self.__weight=raw_input(\"Weight:\")\n", + " \n", + " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", + " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", + " print \"Age:\",a.age\n", + " \n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of Derived class\"\n", + " print \"Display using class name\"\n", + " print \"Name:\",A1.name\n", + " print \"Age:\",A1.age\n", + " \n", + " print \"Display using direct member variable\"\n", + " print \"Name:\",self.name\n", + " print \"Age\",self.age\n", + " print \"height:\",self.__height\n", + " print \"Weight:\",self.__weight\n", + " \n", + "x=A2()\n", + "\n", + "del x\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using name of the class:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:21\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using object of the class\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Amit\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using direct member variables:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Arun\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:19\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:5.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:31\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Display using object of the class\n", + "Name: Amit\n", + "Age: 20\n", + "Destructor of Derived class\n", + "Display using class name\n", + "Name: Ajay\n", + "Age: 21\n", + "Display using direct member variable\n", + "Name: Arun\n", + "Age 19\n", + "height: 5.5\n", + "Weight: 31\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.27, Page Number:488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self.a1=None\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " self.b1=None\n", + " \n", + "class AB:\n", + " def __init__(self):\n", + " a=A()\n", + " b=B()\n", + " a.a1=65 #initialize the two data members of the class A and B and Display them\n", + " b.b1=66\n", + " print \"a1=\",a.a1, \"b1=\",b.b1\n", + " \n", + " def __del__(self):\n", + " pass\n", + " \n", + " \n", + "ab=AB()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 65 b1= 66\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.28, Page Number:489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create derived class from qualifier class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + " class B:\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + " \n", + "class C(A,A.B): #A.B is the inner class of the class A\n", + " def __init__(self,j,k,l):\n", + " self.x=j\n", + " self.y=k\n", + " self.z=l\n", + " \n", + " def show(self):\n", + " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", + " \n", + " \n", + "c=C(4,7,1)\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 y= 7 z= 1\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.29, Page Number:490" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialize member variable of the base class and derived class using constructor of the derived class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self._x=None #protected members\n", + " self._y=None\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.z=3\n", + " self.__x=1 #private members\n", + " self.__y=2\n", + " \n", + " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", + " \n", + "b=B()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 1 y= 2 z= 3\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.30, Page Number:491" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access data members by object pointer\n", + "\n", + "from ctypes import *\n", + "import ctypes\n", + "class A:\n", + " def __init__(self):\n", + " self.x=1\n", + " self.y=2\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " self.z=3\n", + " \n", + "b=B()\n", + "\n", + "\n", + "i=c_int(b.z)\n", + "p=pointer(i)\n", + "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", + "\n", + "i = c_int(b.y)\n", + "p = pointer(i)\n", + "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", + "\n", + "i = c_int(b.x)\n", + "p = pointer(i)\n", + "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", + "\n", + "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", + "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", + "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of z: 57077392 Value of Z: 3\n", + "Address of y: 57074448 Value of y: 2\n", + "Address of x: 57077648 Value of x: 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.31, Page Number:492" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#overload member function in base and derived class\n", + "\n", + "class B:\n", + " def show(self):\n", + " print \"In base class function\"\n", + " \n", + "class D(B):\n", + " def show(self):\n", + " \n", + " print \"In Derived class\"\n", + " \n", + " \n", + "b=B()\n", + "d=D()\n", + "\n", + "b.show()\n", + "d.show()\n", + "\n", + "bp=[B()] #create a base class pointer variable\n", + "bp[0]=d #assign address of the derived class object to the base class pointer\n", + "bp[0].show() #call the derived class method by base class pointer\n", + "b.show() #calling the base class method by base class object" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class function\n", + "In Derived class\n", + "In Derived class\n", + "In base class function\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.32, Page Number:495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in single inheritance\n", + "class Father:\n", + " def __init__(self):\n", + " print \"Base Class constructor.\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def __del__(self):\n", + " print \"Base class Destructor.\"\n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " Father.__init__(self)\n", + " print \"Derived class constructor.\"\n", + " self.__cname=raw_input(\"Enter child name:\")\n", + " \n", + " def __del__(self):\n", + " print \"Derived class destructor.\"\n", + " print \"\",self.__cname,\"\",self.__name\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + " \n", + " \n", + "C=Child()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Base Class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:Manoj\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter child name:Sanjay\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class destructor.\n", + " Sanjay Manoj\n", + "Base class Destructor.\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.33, Page Number:496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in multilevel inheritance\n", + "\n", + "class Grandfather:\n", + " def __init__(self):\n", + " print\"Constructor of class grandfather\"\n", + " self._gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class grandfather\"\n", + " \n", + " \n", + "class Father(Grandfather):\n", + " def __init__(self):\n", + " Grandfather.__init__(self)\n", + " print\"Constructor of class Father\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class Father\"\n", + " Grandfather.__del__(self)\n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " Father.__init__(self)\n", + " print\"Constructor of class Child\"\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class Child\"\n", + " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", + " Father.__del__(self) \n", + " \n", + " \n", + "C=Child()\n", + "\n", + "del C #call the destructor of the derived class\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class grandfather\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:x\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Father\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:y\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Child\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:z\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Destructor of class Child\n", + "Grandfather: x Father: y Child: z\n", + "Destructor of class Father\n", + "Destructor of class grandfather\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.34, Page Number:498" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#program to explain multilevel inheritance with member function\n", + "class Grandfather:\n", + " def __init__(self):\n", + " self.__gname=None\n", + " \n", + " def getg(self):\n", + " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " def showg(self):\n", + " print \"Grandfather Name:\",self.__gname\n", + " \n", + " \n", + "class Father(Grandfather):\n", + " def __init__(self):\n", + " self.__name=None\n", + " \n", + " def getf(self):\n", + " self.__name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def showf(self):\n", + " print \"Father Name:\",self.__name\n", + " \n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " self.__cname=None\n", + " \n", + " def getc(self):\n", + " self.getg()\n", + " self.getf()\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " def showc(self):\n", + " self.showg()\n", + " self.showf()\n", + " print \"child Name:\",self.__cname\n", + " \n", + "C=Child()\n", + "C.getc()\n", + "C.showc()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:XXX\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:YYY\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:ZZZ\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grandfather Name: XXX\n", + "Father Name: YYY\n", + "child Name: ZZZ\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.35, Page Number:499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + " \n", + "class B:\n", + " def __init__(self):\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + " \n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + " \n", + "class D(A,B,C):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self) \n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "x=D() \n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class A\n", + "Destructor of class B\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + " A.__del__(self)\n", + " \n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + " \n", + "class D(B,C):\n", + " def __init__(self):\n", + " B.__init__(self)\n", + " C.__init__(self)\n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\"\n", + " B.__del__(self)\n", + " C.__del__(self)\n", + " \n", + "x=D() \n", + "del x\n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class B\n", + "Destructor of class A\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrate single inheritance\n", + "\n", + "class A:\n", + " def __init__(self,j=0):\n", + " self._c=j\n", + " \n", + " def show(self):\n", + " print \"c=\",self._c\n", + " \n", + " def inc(self):\n", + " self._c=self._c+1\n", + " return self._c\n", + " \n", + "class B(A):\n", + " \n", + " def __init_(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " \n", + " def dec(self):\n", + " self._c=self._c-1\n", + " return self._c\n", + " \n", + " \n", + "a=B()\n", + "a.inc()\n", + "a.show()\n", + "\n", + "\n", + "a.dec()\n", + "a.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c= 1\n", + "c= 0\n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.38, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access method from private inheritance\n", + "class B:\n", + " def one(self):\n", + " print \"one\"\n", + " \n", + " def __two(self):\n", + " print \"two\"\n", + " \n", + "class D(B):\n", + " def __init__(self):\n", + " pass\n", + " \n", + "d=D()\n", + "d.one()\n", + "#d.two() #Not accesible" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "one\n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.39, Page Number:503" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + "class C(B):\n", + " def __init__(self,j,k,l):\n", + " self.z=l\n", + " self.x=j\n", + " self.y=k\n", + " \n", + " def show(self):\n", + " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", + " \n", + "c=C(4,7,1)\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 Y= 7 z= 1\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.40, Page Number:504" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Explicitly call the base constructor in multiple inheritance\n", + "\n", + "class X:\n", + " def __init__(self,a):\n", + " print a,\n", + " \n", + "class Y:\n", + " def __init__(self,b):\n", + " print b,\n", + " \n", + "class Z(X,Y):\n", + " def __init__(self,p,q,r):\n", + " X.__init__(self,p)\n", + " Y.__init__(self,q)\n", + " print r\n", + " \n", + " \n", + "z=Z(1,2,3)\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 2 3\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_1.ipynb b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_1.ipynb new file mode 100755 index 00000000..4f69b243 --- /dev/null +++ b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_1.ipynb @@ -0,0 +1,2636 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:e85379c4218575d4b069259557cffbbc2d0259e3ba5d0e030c11dd77aae5e38d" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.1, Page Number:444" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#A simple classA having a public data member x\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + "\n", + "#A simple classA having a public data member y \n", + "class B(A): #derived class\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + "b=B() #create a instance b of Derived class B\n", + "b.x=20\n", + "b.y=30\n", + "\n", + "print 'member of A:',b.x\n", + "print 'Member of B:',b.y" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "member of A: 20\n", + "Member of B: 30\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.2, Page Number:445" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self): #class A having x as a private data member\n", + " self.__x=20\n", + " \n", + " def showx(self):\n", + " print \"x=\",self.__x\n", + " \n", + " \n", + "class B(A): #Derived class\n", + " def __init__(self):\n", + " self.y=30 #class B having y as a public data member\n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx()\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B() #declaration of object\n", + " #class the method of derived class object by a derived class instance\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 30\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.3, Page Number:447" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None #x is a public member\n", + " \n", + " \n", + "#derived class\n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 \n", + " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", + " \n", + " def show(self):\n", + " print \"x=\",A.__x\n", + " print \"y=\",self.y\n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.4, Page Number:448" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self):\n", + " self.__x=20 #x is a privet member of it\n", + " \n", + " def showx(self): \n", + " print \"x=\",self.__x\n", + " \n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 #y is a public member of it\n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx() #call the base class method\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.5, Page Number:449" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self):\n", + " self._x=None #x is a protected member of the base class\n", + " \n", + " \n", + "class B(A): #private inheritance,x become a private member of the derived class\n", + " def __init__(self):\n", + " self.y=40\n", + " self.__x=30\n", + " \n", + " \n", + " def show(self):\n", + " print \"x=\",self.__x\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 30\n", + "y= 40\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.6, Page Number:456" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class ABC: #Base class\n", + " def __init__(self):\n", + " self._name=None #these 2 are protected data member\n", + " self._age=None\n", + " \n", + "class abc(ABC): #Derived class ,Public derivation\n", + " def __init__(self):\n", + " self.height=None\n", + " self.weight=None\n", + " \n", + " def getdata(self):\n", + " \n", + " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", + " self.age=raw_input(\"Enter a age: \") \n", + " self._height=raw_input(\"Enter a Height: \") \n", + " self._weight=raw_input(\"Enter a Weight: \") \n", + " \n", + " def show(self): #display the value of data members\n", + " print 'Name:',self.name \n", + " print 'Age:',self.age,\"years\"\n", + " print 'Height:',self._height,\"Feets\"\n", + " print 'Weight:',self._weight,\"kg.\"\n", + " \n", + " \n", + "x=abc()\n", + "x.getdata()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a name: Santosh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a age: 24\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Height: 4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Weight: 50\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Santosh\n", + "Age: 24 years\n", + "Height: 4.5 Feets\n", + "Weight: 50 kg.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.7, Page Number:458" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A1: #super Base class,have 2 protected data members\n", + " def __init__(self):\n", + " self._name=None\n", + " self._age=None\n", + "\n", + " \n", + "class A2(A1): #Public derivation\n", + " def __init(self):\n", + " self._height=None\n", + " self._weight=None\n", + "\n", + "class A3(A2): #public Derivation\n", + " def __init__(self):\n", + " self._sex=None\n", + " \n", + " \n", + " def get(self): #get input \n", + " self._name=raw_input(\"Name: \")\n", + " self._age=raw_input(\"Age: \")\n", + " self._sex=raw_input(\"Sex: \")\n", + " \n", + " self._height=raw_input(\"Height: \")\n", + " self._weight=raw_input(\"Weight: \")\n", + " \n", + " def show(self): #Display values of all the data members\n", + " print \"Name:\",self._name\n", + " print \"Age:\",self._age ,\"years\"\n", + " print \"Sex:\",self._sex\n", + " print \"Height:\",self._height ,\"Feet\"\n", + " print \"Weight:\",self._weight ,\"Kg.\"\n", + " \n", + "\n", + "x=A3()\n", + "x.get()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age: 26\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight: 49.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n", + "Age: 26 years\n", + "Sex: M\n", + "Height: 4 Feet\n", + "Weight: 49.5 Kg.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8, Page Number:459" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Example of multiple Inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self._a=None\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " self._b=None\n", + " \n", + " \n", + "class C:\n", + " def __init__(self):\n", + " self._c=None\n", + " \n", + "class D:\n", + " def __init__(self):\n", + " self._d=None\n", + " \n", + "class E(A,B,C,D): #inherites all the base classes publically\n", + " def __init__(self):\n", + " self.e=None\n", + " \n", + " def getdata(self):\n", + " print \"Enter the value of a,b,c &d &e:\"\n", + " self._a=input()\n", + " self._b=input()\n", + " self._c=input()\n", + " self._d=input()\n", + " self._e=input()\n", + " \n", + " def show(self):\n", + " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", + " \n", + " \n", + "x=E() #x is the instance of the derived class\n", + "x.getdata() #call the methods of derived class through x \n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a,b,c &d &e:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a= 1 b= 2 c= 4 d= 8 e= 16\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.9, Page Number:461" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class red: #these three base class\n", + " def __init__(self):\n", + " print \"Red\",\n", + " \n", + "class yellow:\n", + " def __init__(self):\n", + " print \"Yellow\",\n", + " \n", + "class blue:\n", + " def __init__(self):\n", + " print \"Blue\",\n", + " \n", + "class orange(red,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Orange\",\n", + " \n", + "class green(blue,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " blue.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Green\",\n", + " \n", + "class violet(red,blue): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " blue.__init__(self)\n", + " print \"=Violet\",\n", + " \n", + "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Reddishbrown\"\n", + " \n", + "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Yellowishbrown\"\n", + " \n", + "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Bluishbrown\"\n", + " \n", + " \n", + " \n", + "r=reddishbrown() #create instances of the derived class\n", + "b=bluishbrown()\n", + "y=yellowishbrown()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", + "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", + "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.10, Page Number:463" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# WAP to create a derived class from multiple base classes\n", + "\n", + "class PLAYER: #these three are the base classes\n", + " def __init__(self):\n", + " self._name=None\n", + " self._gender=None\n", + " self._age\n", + " \n", + "class PHYSIQUE(PLAYER):\n", + " def __init__(self):\n", + " self._height=None\n", + " self._weight=None\n", + " \n", + "class LOCATION:\n", + " def __init__(self):\n", + " self._city=None\n", + " self._pin=None\n", + " \n", + "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", + " def __init__(self):\n", + " self._game=None\n", + " def getdata(self): #Method to take inputes\n", + " print\"Enter the following information\\n\\n\"\n", + " self._name=raw_input(\"Name:\")\n", + " self._gender=raw_input(\"Gender:\")\n", + " self._age=raw_input(\"Age:\")\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " self._city=raw_input(\"City:\")\n", + " self._pin=raw_input(\"Pin:\")\n", + " self._game=raw_input(\"game:\")\n", + " \n", + " \n", + " \n", + " def show(self): #Method for displaying inputes\n", + " print\"Entered Information!!\"\n", + " print\"Name:\",self._name\n", + " print \"Gender:\",self._gender\n", + " print \"Age:\",self._age\n", + " print \"Height:\",self._height\n", + " print \"Weight:\",self._weight\n", + " print \"City :\",self._city\n", + " print \"Pincode:\",self._pin\n", + " print \"Game :\",self._game\n", + " \n", + " \n", + "G=GAME() #create an instance of the derived class\n", + "G.getdata() #call the public methods by the created instances\n", + "G.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the following information\n", + "\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Mahesh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gender:M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:55\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City:Nanded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pin:431603\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "game:Cricket\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entered Information!!\n", + "Name: Mahesh\n", + "Gender: M\n", + "Age: 25\n", + "Height: 4.9\n", + "Weight: 55\n", + "City : Nanded\n", + "Pincode: 431603\n", + "Game : Cricket\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.11, Page Number:467" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Multipath Inheritance,concept of virtual classes\n", + "\n", + "class A1: #Super base class\n", + " def __init__(self):\n", + " self._a1=None\n", + " \n", + "class A2(A1): #base class 1,inherites Super Base class\n", + " def __init__(self):\n", + " self._a2=None\n", + " \n", + "class A3(A1): #base class 2,inherites Super Base class\n", + " def __init__(self):\n", + " self._a3=None\n", + " \n", + "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", + " def __init__(self):\n", + " self.__a4=None\n", + " \n", + " def get(self):\n", + " print \"Enter the value of a1,a2,a3,and a4:\"\n", + " self._a1=input()\n", + " self._a2=input()\n", + " self._a3=input()\n", + " self.__a4=input()\n", + " \n", + " def put(self):\n", + " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", + " \n", + " \n", + " \n", + "a=A4() #create the instance of the derived class\n", + "a.get()\n", + "a.put()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a1,a2,a3,and a4:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 5 a2= 8 a3= 7 a4= 3\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.12, Page Number:469" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To show order of execution of the constructors and destructors in multiple inheritance\n", + "\n", + "#**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class A\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class A\"\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class B\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class B\"\n", + "\n", + "class C(A,B):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print\"Zero argument Constructor of base class C\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class C\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "c=C() #create instance of derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument Constructor of base class A\n", + "Zero argument Constructor of base class B\n", + "Zero argument Constructor of base class C\n", + "Destructor of class C\n", + "Destructor of class A\n", + "Destructor of class B\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.13, Page Number:471" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#WAP to use constructor and destructor in all the classess\n", + "\n", + "class A1:\n", + " def __init__(self): #take name and age as input in super base class\n", + " self._name=raw_input(\"Name:\")\n", + " self._age=raw_input(\"Age:\")\n", + " \n", + " def __del__(self):\n", + " print\"Name:\",self._name\n", + " print\"Age\",self._age\n", + " \n", + " \n", + "class A2(A1): #take height and weight as input in base base class,public derivation \n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " \n", + " def __del__(self):\n", + " print\"Height:\",self._height\n", + " print\"Weight:\",self._weight\n", + " A1.__del__(self)\n", + " \n", + " \n", + "class A3(A2): #take sex as input in derived class,derived from class A2\n", + " def __init__(self):\n", + " A2.__init__(self)\n", + " self.__sex=raw_input(\"Sex:\")\n", + " def __del__(self): #display all the input taken by all the base classes\n", + " print\"Sex:\",self.__sex\n", + " A2.__del__(self)\n", + " \n", + " \n", + "x=A3() #create instance x of the class A3\n", + "\n", + "del x #call the destructor" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex:M\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n", + "Height: 4.5\n", + "Weight: 40\n", + "Name: Ajay\n", + "Age 20\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14, Page Number:472" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To create derived class from the base class,by constructor and destructor\n", + "class in_t:\n", + " def __init__(self):\n", + " self._i=1\n", + " print\"Constructor in_t()\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor in_t()\"\n", + " \n", + "class floa_t:\n", + " def __init__(self):\n", + " self._f=1.5\n", + " print\"Constructor floa_t()\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor floa_t()\"\n", + " \n", + " \n", + "class cha_r(in_t,floa_t): #multiple derivation\n", + " def __init__(self):\n", + " self._c='A'\n", + " print\"Constructor cha_r()\"\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " \n", + " def show(self):\n", + " print\"i=\",self._i\n", + " print \"f=\",self._f\n", + " print \"c=\",self._c\n", + " \n", + " def __del__(self):\n", + " print \"Destructing cha_r()\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "a=cha_r() #create derived class instance and call the public method of the derived class\n", + "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor cha_r()\n", + "Constructor in_t()\n", + "Constructor floa_t()\n", + "i= 1\n", + "f= 1.5\n", + "c= A\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.15, Page Number:474" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "class I:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " self.__y=None\n", + " \n", + " def set(self,j,k):\n", + " self.x=j\n", + " self.__y=k\n", + " \n", + " def show(self):\n", + " print \"X=\",self.x, \"Y=\",self.__y\n", + " \n", + " \n", + "i=II()\n", + "i.set(4,5)\n", + "i.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "X= 4 Y= 5\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.16, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class I:\n", + " def __init__(self):\n", + " self.x=10\n", + " print \"In the Base class constuctor\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " self.__y=None\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In the Base class constuctor\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.17, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class without constructor and derived class with constructor\n", + "class I:\n", + " pass\n", + "class II(I):\n", + " def __init__(self):\n", + " print \"In derived class constructor\"\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In derived class constructor\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.18, Page Number:476" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#both the class have constructor\n", + "class I:\n", + " def __init__(self):\n", + " print \"In base class Constructor\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " print \"In derived Class constructor\"\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class Constructor\n", + "In derived Class constructor\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.19, Page Number:477" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple constructor in base class and single constructor in the derived class\n", + "\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument base class construtor\"\n", + " \n", + " def __init__(self,k):\n", + " self.x=None\n", + " print \"One argument base class construtor\"\n", + " \n", + " \n", + "class II(I):\n", + " def __init__(self,j,k=None): #default constructor\n", + " I.__init__(self,k)\n", + " self.__y=j\n", + " print \"One argument derived class constructor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class constructor\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.20, Page Number:478" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base and derived class without default constructor\n", + "class I:\n", + " def __init__(self,k):\n", + " self.x=k\n", + " print \"One argument base class construtor\"\n", + " \n", + "class II(I):\n", + " def __init__(self,j):\n", + " I.__init__(self,j)\n", + " self.__y=j\n", + " print \"One argument derived class construtor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class construtor\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.21, Page Number:479" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors and multiple inheritance\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #class III inhrites class II and I\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self) \n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #create an instance of the base class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.22, Page Number:480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors in multiple inhritance with invoking constructor of the base classes\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I):\n", + " def __init__(self):\n", + " II.__init__(self)\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.23, Page Number:481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple inheritance,invoking the base classes explicitly\n", + "\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.24, Page Number:482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multilevel Inheritance,observation of the execution of the constructors\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.25, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#use object of one class in another class as a member\n", + "class I:\n", + " def __init__(self):\n", + " self.x=20\n", + " print \"Constructor of class I\"\n", + " \n", + "class II:\n", + " \n", + " def __init__(self):\n", + " self.k=30\n", + " y=I()\n", + " print \"Constructor of class II\"\n", + " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", + " \n", + " \n", + " def show(self):\n", + " print \"k=\",self.k\n", + " \n", + "ii=II()\n", + "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class I\n", + "Constructor of class II\n", + "x= 20\n", + "k= 30\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.26, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access a member variable of base class using object,class name, and direct\n", + "\n", + "class A1:\n", + " def __init__(self):\n", + " self.name=None\n", + " self.age=None\n", + " \n", + "class A2(A1):\n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " a=A1()\n", + " print \"Access using name of the class:\"\n", + " A1.name=raw_input(\"Name:\")\n", + " A1.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using object of the class\"\n", + " a.name=raw_input(\"Name:\")\n", + " a.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using direct member variables:\"\n", + " self.name=raw_input(\"Name:\")\n", + " self.age=raw_input(\"Age:\")\n", + " self.__height=raw_input(\"Height:\")\n", + " self.__weight=raw_input(\"Weight:\")\n", + " \n", + " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", + " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", + " print \"Age:\",a.age\n", + " \n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of Derived class\"\n", + " print \"Display using class name\"\n", + " print \"Name:\",A1.name\n", + " print \"Age:\",A1.age\n", + " \n", + " print \"Display using direct member variable\"\n", + " print \"Name:\",self.name\n", + " print \"Age\",self.age\n", + " print \"height:\",self.__height\n", + " print \"Weight:\",self.__weight\n", + " \n", + "x=A2()\n", + "\n", + "del x\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using name of the class:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:21\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using object of the class\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Amit\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using direct member variables:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Arun\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:19\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:5.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:31\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Display using object of the class\n", + "Name: Amit\n", + "Age: 20\n", + "Destructor of Derived class\n", + "Display using class name\n", + "Name: Ajay\n", + "Age: 21\n", + "Display using direct member variable\n", + "Name: Arun\n", + "Age 19\n", + "height: 5.5\n", + "Weight: 31\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.27, Page Number:488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self.a1=None\n", + " \n", + "class B:\n", + " def __init__(self):\n", + " self.b1=None\n", + " \n", + "class AB:\n", + " def __init__(self):\n", + " a=A()\n", + " b=B()\n", + " a.a1=65 #initialize the two data members of the class A and B and Display them\n", + " b.b1=66\n", + " print \"a1=\",a.a1, \"b1=\",b.b1\n", + " \n", + " def __del__(self):\n", + " pass\n", + " \n", + " \n", + "ab=AB()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 65 b1= 66\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.28, Page Number:489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create derived class from qualifier class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + " class B:\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + " \n", + "class C(A,A.B): #A.B is the inner class of the class A\n", + " def __init__(self,j,k,l):\n", + " self.x=j\n", + " self.y=k\n", + " self.z=l\n", + " \n", + " def show(self):\n", + " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", + " \n", + " \n", + "c=C(4,7,1)\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 y= 7 z= 1\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.29, Page Number:490" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialize member variable of the base class and derived class using constructor of the derived class\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " self._x=None #protected members\n", + " self._y=None\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.z=3\n", + " self.__x=1 #private members\n", + " self.__y=2\n", + " \n", + " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", + " \n", + "b=B()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 1 y= 2 z= 3\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.30, Page Number:491" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access data members by object pointer\n", + "\n", + "from ctypes import *\n", + "import ctypes\n", + "class A:\n", + " def __init__(self):\n", + " self.x=1\n", + " self.y=2\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " self.z=3\n", + " \n", + "b=B()\n", + "\n", + "\n", + "i=c_int(b.z)\n", + "p=pointer(i)\n", + "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", + "\n", + "i = c_int(b.y)\n", + "p = pointer(i)\n", + "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", + "\n", + "i = c_int(b.x)\n", + "p = pointer(i)\n", + "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", + "\n", + "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", + "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", + "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of z: 57077392 Value of Z: 3\n", + "Address of y: 57074448 Value of y: 2\n", + "Address of x: 57077648 Value of x: 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.31, Page Number:492" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#overload member function in base and derived class\n", + "\n", + "class B:\n", + " def show(self):\n", + " print \"In base class function\"\n", + " \n", + "class D(B):\n", + " def show(self):\n", + " \n", + " print \"In Derived class\"\n", + " \n", + " \n", + "b=B()\n", + "d=D()\n", + "\n", + "b.show()\n", + "d.show()\n", + "\n", + "bp=[B()] #create a base class pointer variable\n", + "bp[0]=d #assign address of the derived class object to the base class pointer\n", + "bp[0].show() #call the derived class method by base class pointer\n", + "b.show() #calling the base class method by base class object" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class function\n", + "In Derived class\n", + "In Derived class\n", + "In base class function\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.32, Page Number:495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in single inheritance\n", + "class Father:\n", + " def __init__(self):\n", + " print \"Base Class constructor.\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def __del__(self):\n", + " print \"Base class Destructor.\"\n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " Father.__init__(self)\n", + " print \"Derived class constructor.\"\n", + " self.__cname=raw_input(\"Enter child name:\")\n", + " \n", + " def __del__(self):\n", + " print \"Derived class destructor.\"\n", + " print \"\",self.__cname,\"\",self.__name\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + " \n", + " \n", + "C=Child()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Base Class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:Manoj\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter child name:Sanjay\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class destructor.\n", + " Sanjay Manoj\n", + "Base class Destructor.\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.33, Page Number:496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in multilevel inheritance\n", + "\n", + "class Grandfather:\n", + " def __init__(self):\n", + " print\"Constructor of class grandfather\"\n", + " self._gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class grandfather\"\n", + " \n", + " \n", + "class Father(Grandfather):\n", + " def __init__(self):\n", + " Grandfather.__init__(self)\n", + " print\"Constructor of class Father\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class Father\"\n", + " Grandfather.__del__(self)\n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " Father.__init__(self)\n", + " print\"Constructor of class Child\"\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class Child\"\n", + " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", + " Father.__del__(self) \n", + " \n", + " \n", + "C=Child()\n", + "\n", + "del C #call the destructor of the derived class\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class grandfather\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:x\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Father\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:y\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Child\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:z\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Destructor of class Child\n", + "Grandfather: x Father: y Child: z\n", + "Destructor of class Father\n", + "Destructor of class grandfather\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.34, Page Number:498" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#program to explain multilevel inheritance with member function\n", + "class Grandfather:\n", + " def __init__(self):\n", + " self.__gname=None\n", + " \n", + " def getg(self):\n", + " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " def showg(self):\n", + " print \"Grandfather Name:\",self.__gname\n", + " \n", + " \n", + "class Father(Grandfather):\n", + " def __init__(self):\n", + " self.__name=None\n", + " \n", + " def getf(self):\n", + " self.__name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def showf(self):\n", + " print \"Father Name:\",self.__name\n", + " \n", + " \n", + "class Child(Father):\n", + " def __init__(self):\n", + " self.__cname=None\n", + " \n", + " def getc(self):\n", + " self.getg()\n", + " self.getf()\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " def showc(self):\n", + " self.showg()\n", + " self.showf()\n", + " print \"child Name:\",self.__cname\n", + " \n", + "C=Child()\n", + "C.getc()\n", + "C.showc()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:XXX\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:YYY\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:ZZZ\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grandfather Name: XXX\n", + "Father Name: YYY\n", + "child Name: ZZZ\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.35, Page Number:499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + " \n", + "class B:\n", + " def __init__(self):\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + " \n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + " \n", + "class D(A,B,C):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self) \n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "x=D() \n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class A\n", + "Destructor of class B\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + " A.__del__(self)\n", + " \n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + " \n", + "class D(B,C):\n", + " def __init__(self):\n", + " B.__init__(self)\n", + " C.__init__(self)\n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\"\n", + " B.__del__(self)\n", + " C.__del__(self)\n", + " \n", + "x=D() \n", + "del x\n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class B\n", + "Destructor of class A\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrate single inheritance\n", + "\n", + "class A:\n", + " def __init__(self,j=0):\n", + " self._c=j\n", + " \n", + " def show(self):\n", + " print \"c=\",self._c\n", + " \n", + " def inc(self):\n", + " self._c=self._c+1\n", + " return self._c\n", + " \n", + "class B(A):\n", + " \n", + " def __init_(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " \n", + " def dec(self):\n", + " self._c=self._c-1\n", + " return self._c\n", + " \n", + " \n", + "a=B()\n", + "a.inc()\n", + "a.show()\n", + "\n", + "\n", + "a.dec()\n", + "a.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c= 1\n", + "c= 0\n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.38, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access method from private inheritance\n", + "class B:\n", + " def one(self):\n", + " print \"one\"\n", + " \n", + " def __two(self):\n", + " print \"two\"\n", + " \n", + "class D(B):\n", + " def __init__(self):\n", + " pass\n", + " \n", + "d=D()\n", + "d.one()\n", + "#d.two() #Not accesible" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "one\n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.39, Page Number:503" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + "class C(B):\n", + " def __init__(self,j,k,l):\n", + " self.z=l\n", + " self.x=j\n", + " self.y=k\n", + " \n", + " def show(self):\n", + " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", + " \n", + "c=C(4,7,1)\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 Y= 7 z= 1\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.40, Page Number:504" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Explicitly call the base constructor in multiple inheritance\n", + "\n", + "class X:\n", + " def __init__(self,a):\n", + " print a,\n", + " \n", + "class Y:\n", + " def __init__(self,b):\n", + " print b,\n", + " \n", + "class Z(X,Y):\n", + " def __init__(self,p,q,r):\n", + " X.__init__(self,p)\n", + " Y.__init__(self,q)\n", + " print r\n", + " \n", + " \n", + "z=Z(1,2,3)\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 2 3\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_2.ipynb b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_2.ipynb new file mode 100755 index 00000000..d92c896a --- /dev/null +++ b/sample_notebooks/AJEET KUMARSINGH/AJEET KUMARSINGH_version_backup/Chapter_11_Inheritance_2.ipynb @@ -0,0 +1,2661 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:4d2b31f88da13c65a205238b2aa0d40205b037d2cf9c5ea74665d1d4bd106552" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.1, Page Number:444" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Public Derivation of a class\n", + "class A: #Base class\n", + " def __init__(self):\n", + " self.x=None\n", + "\n", + " \n", + "class B(A): #derived class\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + "b=B() #declaration of object\n", + "b.x=20\n", + "b.y=30\n", + "\n", + "print 'member of A:',b.x\n", + "print 'Member of B:',b.y" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "member of A: 20\n", + "Member of B: 30\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.2, Page Number:445" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Base class\n", + "class A: #Base class\n", + " def __init__(self): #class A having x as a private data member\n", + " self.__x=20\n", + " \n", + " def showx(self):\n", + " print \"x=\",self.__x\n", + " \n", + "#derived class \n", + "class B(A): #Derived class\n", + " def __init__(self):\n", + " self.y=30 #class B having y as a public data member\n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx()\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B() #declaration of object\n", + " \n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 30\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.3, Page Number:447" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None #x is a public member\n", + " \n", + " \n", + "#derived class\n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 \n", + " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", + " \n", + " def show(self):\n", + " print \"x=\",A.__x\n", + " print \"y=\",self.y\n", + " \n", + "b=B() #declaration of object\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.4, Page Number:448" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#derivation of a class privately\n", + "class A:\n", + " def __init__(self):\n", + " self.__x=20 \n", + " \n", + " def showx(self): \n", + " print \"x=\",self.__x\n", + " \n", + "#derived class \n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=40 \n", + " \n", + " def show(self):\n", + " a=A()\n", + " a.showx() #call the base class method\n", + " print \"y=\",self.y\n", + " \n", + " \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 20\n", + "y= 40\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.5, Page Number:449" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A:\n", + " def __init__(self):\n", + " self._x=None #x is a protected member of the base class\n", + " \n", + " \n", + "class B(A): #private inheritance,x become a private member of the derived class\n", + " def __init__(self):\n", + " self.y=40\n", + " self.__x=30\n", + " \n", + " \n", + " def show(self): #method to display all the values of all the data memeber\n", + " print \"x=\",self.__x\n", + " print \"y=\",self.y\n", + " \n", + " #declaration of object \n", + "b=B()\n", + "b.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 30\n", + "y= 40\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.6, Page Number:456" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class ABC: #Base class\n", + " def __init__(self):\n", + " self._name=None #these 2 are protected data member\n", + " self._age=None\n", + " \n", + "class abc(ABC): #Derived class ,Public derivation\n", + " def __init__(self):\n", + " self.height=None\n", + " self.weight=None\n", + " \n", + " def getdata(self):\n", + " \n", + " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", + " self.age=raw_input(\"Enter a age: \") \n", + " self._height=raw_input(\"Enter a Height: \") \n", + " self._weight=raw_input(\"Enter a Weight: \") \n", + " \n", + " def show(self): #display the value of data members\n", + " print 'Name:',self.name \n", + " print 'Age:',self.age,\"years\"\n", + " print 'Height:',self._height,\"Feets\"\n", + " print 'Weight:',self._weight,\"kg.\"\n", + " \n", + " \n", + "x=abc()\n", + "x.getdata()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a name: Santosh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a age: 24\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Height: 4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a Weight: 50\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Santosh\n", + "Age: 24 years\n", + "Height: 4.5 Feets\n", + "Weight: 50 kg.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.7, Page Number:458" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class A1: #super Base class,have 2 protected data members\n", + " def __init__(self):\n", + " self._name=None\n", + " self._age=None\n", + "\n", + " \n", + "class A2(A1): #Public derivation\n", + " def __init(self):\n", + " self._height=None\n", + " self._weight=None\n", + "\n", + "class A3(A2): #public Derivation\n", + " def __init__(self):\n", + " self._sex=None\n", + " \n", + " \n", + " def get(self): #get input \n", + " self._name=raw_input(\"Name: \")\n", + " self._age=raw_input(\"Age: \")\n", + " self._sex=raw_input(\"Sex: \")\n", + " \n", + " self._height=raw_input(\"Height: \")\n", + " self._weight=raw_input(\"Weight: \")\n", + " \n", + " def show(self): #Display values of all the data members\n", + " print \"Name:\",self._name\n", + " print \"Age:\",self._age ,\"years\"\n", + " print \"Sex:\",self._sex\n", + " print \"Height:\",self._height ,\"Feet\"\n", + " print \"Weight:\",self._weight ,\"Kg.\"\n", + " \n", + "\n", + "x=A3()\n", + "x.get()\n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age: 26\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight: 49.5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Balaji\n", + "Age: 26 years\n", + "Sex: M\n", + "Height: 4 Feet\n", + "Weight: 49.5 Kg.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.8, Page Number:459" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Example of multiple Inheritance\n", + "#Base1 class\n", + "class A:\n", + " def __init__(self):\n", + " self._a=None\n", + "#Base2 class\n", + "class B:\n", + " def __init__(self):\n", + " self._b=None\n", + "#Base3 class\n", + "class C:\n", + " def __init__(self):\n", + " self._c=None\n", + "#Base4 class \n", + "class D:\n", + " def __init__(self):\n", + " self._d=None\n", + "#derived class,multiple derivation\n", + "class E(A,B,C,D): #inherites all the base classes publically\n", + " def __init__(self):\n", + " self.e=None\n", + " \n", + " def getdata(self): #member method to take input for all the data members \n", + " print \"Enter the value of a,b,c &d &e:\"\n", + " self._a=input()\n", + " self._b=input()\n", + " self._c=input()\n", + " self._d=input()\n", + " self._e=input()\n", + " \n", + " def show(self): #member method to display for all the data members \n", + " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", + " \n", + " \n", + "x=E() #x is the instance of the derived class\n", + "x.getdata() #call the methods of derived class through x \n", + "x.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a,b,c &d &e:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "16\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a= 1 b= 2 c= 4 d= 8 e= 16\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.9, Page Number:461" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class red: #these three base class\n", + " def __init__(self):\n", + " print \"Red\",\n", + " \n", + "class yellow:\n", + " def __init__(self):\n", + " print \"Yellow\",\n", + " \n", + "class blue:\n", + " def __init__(self):\n", + " print \"Blue\",\n", + " \n", + "class orange(red,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Orange\",\n", + " \n", + "class green(blue,yellow): #public multiple Derivation\n", + " def __init__(self):\n", + " blue.__init__(self)\n", + " yellow.__init__(self)\n", + " print \"=Green\",\n", + " \n", + "class violet(red,blue): #public multiple Derivation\n", + " def __init__(self):\n", + " red.__init__(self)\n", + " blue.__init__(self)\n", + " print \"=Violet\",\n", + " \n", + "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Reddishbrown\"\n", + " \n", + "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Yellowishbrown\"\n", + " \n", + "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " print \"=Bluishbrown\"\n", + " \n", + " \n", + " \n", + "r=reddishbrown() #create instances of the derived class\n", + "b=bluishbrown()\n", + "y=yellowishbrown()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", + "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", + "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.10, Page Number:463" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# WAP to create a derived class from multiple base classes\n", + "\n", + "class PLAYER: #these three are the base classes\n", + " def __init__(self):\n", + " self._name=None\n", + " self._gender=None\n", + " self._age\n", + " \n", + "class PHYSIQUE(PLAYER):\n", + " def __init__(self):\n", + " self._height=None\n", + " self._weight=None\n", + " \n", + "class LOCATION:\n", + " def __init__(self):\n", + " self._city=None\n", + " self._pin=None\n", + " \n", + "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", + " def __init__(self):\n", + " self._game=None\n", + " def getdata(self): #Method to take inputes\n", + " print\"Enter the following information\\n\\n\"\n", + " self._name=raw_input(\"Name:\")\n", + " self._gender=raw_input(\"Gender:\")\n", + " self._age=raw_input(\"Age:\")\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " self._city=raw_input(\"City:\")\n", + " self._pin=raw_input(\"Pin:\")\n", + " self._game=raw_input(\"game:\")\n", + " \n", + " \n", + " \n", + " def show(self): #Method for displaying inputes\n", + " print\"Entered Information!!\"\n", + " print\"Name:\",self._name\n", + " print \"Gender:\",self._gender\n", + " print \"Age:\",self._age\n", + " print \"Height:\",self._height\n", + " print \"Weight:\",self._weight\n", + " print \"City :\",self._city\n", + " print \"Pincode:\",self._pin\n", + " print \"Game :\",self._game\n", + " \n", + " \n", + "G=GAME() #create an instance of the derived class\n", + "G.getdata() #call the public methods by the created instances\n", + "G.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the following information\n", + "\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Mahesh\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gender:M\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:25\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:55\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "City:Nanded\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Pin:431603\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "game:Cricket\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Entered Information!!\n", + "Name: Mahesh\n", + "Gender: M\n", + "Age: 25\n", + "Height: 4.9\n", + "Weight: 55\n", + "City : Nanded\n", + "Pincode: 431603\n", + "Game : Cricket\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.11, Page Number:467" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Multipath Inheritance,concept of virtual classes\n", + "\n", + "class A1: #Super base class\n", + " def __init__(self):\n", + " self._a1=None\n", + " \n", + "class A2(A1): #base class 1,inherites Super Base class\n", + " def __init__(self):\n", + " self._a2=None\n", + " \n", + "class A3(A1): #base class 2,inherites Super Base class\n", + " def __init__(self):\n", + " self._a3=None\n", + " \n", + "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", + " def __init__(self):\n", + " self.__a4=None\n", + " \n", + " def get(self):\n", + " print \"Enter the value of a1,a2,a3,and a4:\"\n", + " self._a1=input()\n", + " self._a2=input()\n", + " self._a3=input()\n", + " self.__a4=input()\n", + " \n", + " def put(self):\n", + " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", + " \n", + " \n", + " \n", + "a=A4() #create the instance of the derived class\n", + "a.get()\n", + "a.put()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the value of a1,a2,a3,and a4:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 5 a2= 8 a3= 7 a4= 3\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.12, Page Number:469" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To show order of execution of the constructors and destructors in multiple inheritance\n", + "\n", + "#Base1 class\n", + "class A:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class A\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class A\"\n", + "#Base2 class \n", + "class B:\n", + " def __init__(self):\n", + " print\"Zero argument Constructor of base class B\"\n", + " \n", + " def __del__(self):\n", + " print\"Destructor of class B\"\n", + "#derived class,multiple derivation\n", + "class C(A,B):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__: #invocation of the constructor of all the base classes\n", + " b.__init__(self)\n", + " print\"Zero argument Constructor of base class C\"\n", + " \n", + " def __del__(self): \n", + " print\"Destructor of class C\"\n", + " for b in self.__class__.__bases__: #invocation of the destructor of all the base classes\n", + " b.__del__(self)\n", + " \n", + "c=C() #create instance of derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument Constructor of base class A\n", + "Zero argument Constructor of base class B\n", + "Zero argument Constructor of base class C\n", + "Destructor of class C\n", + "Destructor of class A\n", + "Destructor of class B\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.13, Page Number:471" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#WAP to use constructor and destructor in all the classess\n", + "\n", + "class A1:\n", + " def __init__(self): #take name and age as input in super base class\n", + " self._name=raw_input(\"Name:\")\n", + " self._age=raw_input(\"Age:\")\n", + " \n", + " def __del__(self): #show name and age as input in super base class\n", + " print\"Name:\",self._name\n", + " print\"Age\",self._age\n", + " \n", + " \n", + "class A2(A1): #take height and weight as input in base base class,public derivation \n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " self._height=raw_input(\"Height:\")\n", + " self._weight=raw_input(\"Weight:\")\n", + " \n", + " def __del__(self): #show height and weight as input in base base class,public derivation \n", + " print\"Height:\",self._height\n", + " print\"Weight:\",self._weight\n", + " A1.__del__(self)\n", + " \n", + " \n", + "class A3(A2): #take sex as input in derived class,derived from class A2\n", + " def __init__(self):\n", + " A2.__init__(self)\n", + " self.__sex=raw_input(\"Sex:\")\n", + " def __del__(self): #display all the input taken by all the base classes\n", + " print\"Sex:\",self.__sex\n", + " A2.__del__(self)\n", + " \n", + " \n", + "x=A3() #create instance x of the class A3\n", + "\n", + "del x #call the destructor" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:4.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:40\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex:M\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sex: M\n", + "Height: 4.5\n", + "Weight: 40\n", + "Name: Ajay\n", + "Age 20\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.14, Page Number:472" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To create derived class from the base class,by constructor and destructor\n", + "#Base1 class\n", + "class in_t:\n", + " def __init__(self): #constructor of base1 class\n", + " self._i=1\n", + " print\"Constructor in_t()\"\n", + " \n", + " def __del__(self): #destructor of base1 class\n", + " print\"Destructor in_t()\"\n", + "\n", + "#Base2 class\n", + "class floa_t:\n", + " def __init__(self): #constructor of base2 class\n", + " self._f=1.5\n", + " print\"Constructor floa_t()\"\n", + " \n", + " def __del__(self): #destructor of base2 class\n", + " print\"Destructor floa_t()\"\n", + " \n", + "#Derived class \n", + "class cha_r(in_t,floa_t): #multiple derivation\n", + " def __init__(self):\n", + " self._c='A'\n", + " print\"Constructor cha_r()\"\n", + " for b in self.__class__.__bases__: #invocation of the base class constructors\n", + " b.__init__(self)\n", + " \n", + " def show(self): #member method to show all the data member \n", + " print\"i=\",self._i\n", + " print \"f=\",self._f\n", + " print \"c=\",self._c\n", + " \n", + " def __del__(self): #Destructor of the derived cladd\n", + " print \"Destructing cha_r()\"\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "a=cha_r() #create derived class instance and call the public method of the derived class\n", + "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor cha_r()\n", + "Constructor in_t()\n", + "Constructor floa_t()\n", + "i= 1\n", + "f= 1.5\n", + "c= A\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.15, Page Number:474" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Base class\n", + "class I:\n", + " def __init__(self):\n", + " self.x=None\n", + "#derived class \n", + "class II(I):\n", + " def __init__(self):\n", + " self.__y=None #private member of the classII\n", + " \n", + " def set(self,j,k): #Parametrized constructor \n", + " self.x=j\n", + " self.__y=k\n", + " \n", + " def show(self):\n", + " print \"X=\",self.x, \"Y=\",self.__y\n", + " \n", + " \n", + "i=II() #creation of instance of the Derived class\n", + "i.set(4,5) #invocation of the derived class member method by instance of the derived class\n", + "i.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "X= 4 Y= 5\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.16, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Base class\n", + "class I:\n", + " def __init__(self):\n", + " self.x=10\n", + " print \"In the Base class constuctor\"\n", + "#Derived class\n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self) #invocation of the base class constructor\n", + " self.__y=None\n", + " \n", + "i=II() #instance of the derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In the Base class constuctor\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.17, Page Number:475" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base class without constructor and derived class with constructor\n", + "class I:\n", + " pass #Empty body of the base class\n", + "class II(I):\n", + " def __init__(self):\n", + " print \"In derived class constructor\"\n", + " \n", + "i=II()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In derived class constructor\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.18, Page Number:476" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#both the class have constructor\n", + "class I:\n", + " def __init__(self):\n", + " print \"In base class Constructor\"\n", + "#Derived class \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)#invocation of the base class constructor\n", + " print \"In derived Class constructor\"\n", + " \n", + "i=II()#instance of the derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class Constructor\n", + "In derived Class constructor\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.19, Page Number:477" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple constructor in base class and single constructor in the derived class\n", + "#Base class\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument base class construtor\"\n", + " \n", + " def __init__(self,k): #parametrized constructor\n", + " self.x=None\n", + " print \"One argument base class construtor\"\n", + " \n", + "#Derived class \n", + "class II(I):\n", + " def __init__(self,j,k=None): #default constructor\n", + " I.__init__(self,k)\n", + " self.__y=j\n", + " print \"One argument derived class constructor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class constructor\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.20, Page Number:478" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#base and derived class without default constructor\n", + "class I:\n", + " def __init__(self,k):\n", + " self.x=k\n", + " print \"One argument base class construtor\"\n", + "#Derived class \n", + "class II(I):\n", + " def __init__(self,j):\n", + " I.__init__(self,j) #invlocation of baser class constructor\n", + " self.__y=j\n", + " print \"One argument derived class construtor\"\n", + " \n", + "i=II(2) #create the instance of the base class by passing initial value " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "One argument base class construtor\n", + "One argument derived class construtor\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.21, Page Number:479" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors and multiple inheritance\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #class III inhrites class II and I\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__: #invocation \n", + " b.__init__(self) \n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #create an instance of the base class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.22, Page Number:480" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constructors in multiple inhritance with invoking constructor of the base classes\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + " \n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I):\n", + " def __init__(self):\n", + " II.__init__(self) #invocation of base class constructors\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #instaace of thr derived class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.23, Page Number:481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multiple inheritance,invoking the base classes explicitly\n", + "#Base1 class\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + "#Base2 class\n", + "class II:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II,I): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " I.__init__(self) #invocation of the base classes\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #instane of the Derived class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.24, Page Number:482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#multilevel Inheritance,observation of the execution of the constructors\n", + "class I:\n", + " def __init__(self):\n", + " print \"Zero argument constructor of base class I\"\n", + "#Derived1 class \n", + "class II(I):\n", + " def __init__(self):\n", + " I.__init__(self)\n", + " print \"Zero argument constructor of base class II\"\n", + " \n", + "class III(II): #Class I is virtually inherited so its constructor called first\n", + " def __init__(self):\n", + " II.__init__(self)\n", + " print \"Zero argument constructor of base class III\"\n", + " \n", + "i=III() #instance of the class III" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Zero argument constructor of base class I\n", + "Zero argument constructor of base class II\n", + "Zero argument constructor of base class III\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.25, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#use object of one class in another class as a member\n", + "class I:\n", + " def __init__(self):\n", + " self.x=20\n", + " print \"Constructor of class I\"\n", + " \n", + "class II(I):\n", + " \n", + " def __init__(self):\n", + " self.k=30\n", + " y=I()\n", + " print \"Constructor of class II\"\n", + " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", + " \n", + " \n", + " def show(self):\n", + " print \"k=\",self.k\n", + " \n", + "ii=II()\n", + "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class I\n", + "Constructor of class II\n", + "x= 20\n", + "k= 30\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.26, Page Number:484" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access a member variable of base class using object,class name, and direct\n", + "#Base class\n", + "class A1:\n", + " def __init__(self): #constructor of the base class\n", + " self.name=None\n", + " self.age=None\n", + "\n", + "#Derived class\n", + "class A2(A1):\n", + " def __init__(self):\n", + " A1.__init__(self)\n", + " a=A1() #create the instances of the base classe,to visible in this block\n", + " print \"Access using name of the class:\"\n", + " A1.name=raw_input(\"Name:\")\n", + " A1.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using object of the class\"\n", + " a.name=raw_input(\"Name:\")\n", + " a.age=raw_input(\"Age:\")\n", + " \n", + " print \"Access using direct member variables:\"\n", + " self.name=raw_input(\"Name:\")\n", + " self.age=raw_input(\"Age:\")\n", + " self.__height=raw_input(\"Height:\")\n", + " self.__weight=raw_input(\"Weight:\")\n", + " \n", + " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", + " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", + " print \"Age:\",a.age\n", + " \n", + " \n", + " \n", + " def __del__(self):\n", + " print \"Destructor of Derived class\"\n", + " print \"Display using class name\"\n", + " print \"Name:\",A1.name\n", + " print \"Age:\",A1.age\n", + " \n", + " print \"Display using direct member variable\"\n", + " print \"Name:\",self.name\n", + " print \"Age\",self.age\n", + " print \"height:\",self.__height\n", + " print \"Weight:\",self.__weight\n", + " \n", + "x=A2()\n", + "\n", + "del x #call the destructor of the derived class\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using name of the class:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Ajay\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:21\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using object of the class\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Amit\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:20\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Access using direct member variables:\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name:Arun\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Age:19\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Height:5.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Weight:31\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Display using object of the class\n", + "Name: Amit\n", + "Age: 20\n", + "Destructor of Derived class\n", + "Display using class name\n", + "Name: Ajay\n", + "Age: 21\n", + "Display using direct member variable\n", + "Name: Arun\n", + "Age 19\n", + "height: 5.5\n", + "Weight: 31\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.27, Page Number:488" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", + "#Base1 class\n", + "class A:\n", + " def __init__(self):\n", + " self.a1=None\n", + "#Base2 class \n", + "class B:\n", + " def __init__(self):\n", + " self.b1=None\n", + "#derived class\n", + "class AB:\n", + " def __init__(self):\n", + " a=A() #create the instances of the base classes,to visible in this block\n", + " b=B()\n", + " a.a1=65 #initialize the two data members of the class A and B and Display them\n", + " b.b1=66\n", + " print \"a1=\",a.a1, \"b1=\",b.b1\n", + " \n", + " def __del__(self):\n", + " pass\n", + " \n", + " \n", + "ab=AB() #ab is the instance of the derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a1= 65 b1= 66\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.28, Page Number:489" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create derived class from qualifier class\n", + "#Base class,container class for the class B\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + " class B: #nested class\n", + " def __init__(self):\n", + " self.y=None\n", + " \n", + " \n", + "class C(A,A.B): #A.B is the inner class of the class A\n", + " def __init__(self,j,k,l):\n", + " self.x=j #set the container base class data member\n", + " self.y=k #set the data member of the nested class\n", + " self.z=l\n", + " \n", + " def show(self): #show method to show all the data members\n", + " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", + " \n", + " \n", + "c=C(4,7,1) #assign all the data members by invocation of the derived class constructor\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 y= 7 z= 1\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.29, Page Number:490" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialize member variable of the base class and derived class using constructor of the derived class\n", + "#Base class\n", + "class A:\n", + " def __init__(self): #constructor\n", + " self._x=None #protected members\n", + " self._y=None\n", + " \n", + "class B(A):\n", + " def __init__(self): #derived class constructor\n", + " self.z=3 \n", + " self.__x=1 #private members\n", + " self.__y=2\n", + " \n", + " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", + " \n", + "b=B() #instance of the derived class" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 1 y= 2 z= 3\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.30, Page Number:491" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access data members by object pointer\n", + "\n", + "from ctypes import *\n", + "import ctypes\n", + "class A:\n", + " def __init__(self):\n", + " self.x=1\n", + " self.y=2\n", + " \n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " self.z=3\n", + " \n", + "b=B()\n", + "\n", + "\n", + "i=c_int(b.z)\n", + "p=pointer(i)\n", + "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", + "\n", + "i = c_int(b.y)\n", + "p = pointer(i)\n", + "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", + "\n", + "i = c_int(b.x)\n", + "p = pointer(i)\n", + "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", + "\n", + "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", + "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", + "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Address of z: 57077392 Value of Z: 3\n", + "Address of y: 57074448 Value of y: 2\n", + "Address of x: 57077648 Value of x: 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.31, Page Number:492" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#overload member function in base and derived class\n", + "#Base class\n", + "class B:\n", + " def show(self): #method to be ovveriden\n", + " print \"In base class function\"\n", + " \n", + "class D(B):\n", + " def show(self): #Derived class method,ovveride to the base class\n", + " \n", + " print \"In Derived class\"\n", + " \n", + " \n", + "b=B() #b is the base class instance\n", + "d=D() #d is the derived class instance\n", + "\n", + "b.show()\n", + "d.show()\n", + "\n", + "bp=[B()] #create a base class pointer variable\n", + "bp[0]=d #assign address of the derived class object to the base class pointer\n", + "bp[0].show() #call the derived class method by base class pointer\n", + "b.show() #calling the base class method by base class object" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In base class function\n", + "In Derived class\n", + "In Derived class\n", + "In base class function\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.32, Page Number:495" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in single inheritance\n", + "\n", + "#Base class\n", + "class Father:\n", + " def __init__(self): #Constructor to set the data member name\n", + " print \"Base Class constructor.\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def __del__(self):\n", + " print \"Base class Destructor.\"\n", + "\n", + "#Derived class\n", + "class Child(Father):\n", + " def __init__(self):#Constructor to set the data member cname\n", + " Father.__init__(self) #invocation of base class constructor\n", + " print \"Derived class constructor.\"\n", + " self.__cname=raw_input(\"Enter child name:\")\n", + " \n", + " def __del__(self): #destructor to set the data member cname\n", + " print \"Derived class destructor.\"\n", + " print \"\",self.__cname,\"\",self.__name \n", + " for b in self.__class__.__bases__: #invocation of base class destructor\n", + " b.__del__(self)\n", + " \n", + " \n", + " \n", + "C=Child()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Base Class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:Manoj\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class constructor.\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter child name:Sanjay\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Derived class destructor.\n", + " Sanjay Manoj\n", + "Base class Destructor.\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.33, Page Number:496" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Constuctor and destructors in multilevel inheritance\n", + "#Base class\n", + "class Grandfather:\n", + " def __init__(self): #Constructor to set the data member gname\n", + " print\"Constructor of class grandfather\"\n", + " self._gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " \n", + " def __del__(self): #Destructor to show the data member gname\n", + " print \"Destructor of class grandfather\"\n", + " \n", + " \n", + "#Derived1 class\n", + "class Father(Grandfather):\n", + " def __init__(self): #Constructor to set the data member name\n", + " Grandfather.__init__(self) #invocation of base class constructor\n", + " print\"Constructor of class Father\"\n", + " self._name=raw_input(\"Enter Father Name:\")\n", + " \n", + " \n", + " def __del__(self): #Destructor to show the data member name\n", + " print \"Destructor of class Father\"\n", + " Grandfather.__del__(self) #invocation of base class destructor\n", + " \n", + "#Derived2 class\n", + "class Child(Father):\n", + " def __init__(self): #Constructor to set the data member cname\n", + " Father.__init__(self) #invocation of base class constructor\n", + " print\"Constructor of class Child\"\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " \n", + " def __del__(self): #Destructor to show the data member name\n", + " print \"Destructor of class Child\"\n", + " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", + " Father.__del__(self) #invocation of base class destructor\n", + " \n", + "#instance of the Derived2 class \n", + "C=Child()\n", + "\n", + "del C #call the destructor of the derived class\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class grandfather\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:x\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Father\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:y\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Child\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:z\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Destructor of class Child\n", + "Grandfather: x Father: y Child: z\n", + "Destructor of class Father\n", + "Destructor of class grandfather\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.34, Page Number:498" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#program to explain multilevel inheritance with member function\n", + "\n", + "#Base class\n", + "class Grandfather:\n", + " def __init__(self):\n", + " self.__gname=None\n", + " \n", + " def getg(self): #method to set the data member gname\n", + " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", + " \n", + " def showg(self):#method to show the data member gname\n", + " print \"Grandfather Name:\",self.__gname\n", + " \n", + " \n", + "#Derived1 class\n", + "class Father(Grandfather):\n", + " def __init__(self):\n", + " self.__name=None\n", + " \n", + " def getf(self): #method to set the data member name\n", + " self.__name=raw_input(\"Enter Father Name:\")\n", + " \n", + " def showf(self): #method to show the data member name\n", + " print \"Father Name:\",self.__name\n", + " \n", + "#Derived2 class \n", + "class Child(Father):\n", + " def __init__(self):\n", + " self.__cname=None\n", + " \n", + " def getc(self): #method for invocation of base class methods and set the data member cname\n", + " self.getg()\n", + " self.getf()\n", + " self.__cname=raw_input(\"Enter Child Name:\")\n", + " \n", + " def showc(self): #method for invocation of base class methods and set the data member cname\n", + " self.showg()\n", + " self.showf()\n", + " print \"child Name:\",self.__cname\n", + " \n", + "C=Child() #cretaion of a instance of Derived2 class\n", + "C.getc() #invocation of the method of Derived2 class for setting all the data member value\n", + "C.showc()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Grandfather Name:XXX\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Father Name:YYY\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Child Name:ZZZ\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Grandfather Name: XXX\n", + "Father Name: YYY\n", + "child Name: ZZZ\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.35, Page Number:499" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "#Base1 class\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + "#Base2 class \n", + "class B:\n", + " def __init__(self):\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + "#Base3 class \n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + "#Derived class,Multiple Derivation \n", + "class D(A,B,C):\n", + " def __init__(self):\n", + " for b in self.__class__.__bases__: #invoke all the base class constructors\n", + " b.__init__(self) \n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\" #invoke all the base class destructors\n", + " for b in self.__class__.__bases__:\n", + " b.__del__(self)\n", + " \n", + "x=D() \n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class A\n", + "Destructor of class B\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#execution of constructor and destructor in multilevel inheritance\n", + "\n", + "#Base class\n", + "class A:\n", + " def __init__(self):\n", + " print \"Constructor of class A\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class A\"\n", + " \n", + "#Derived1 class\n", + "class B(A):\n", + " def __init__(self):\n", + " A.__init__(self)\n", + " print \"Constructor of class B\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class B\"\n", + " A.__del__(self)\n", + "\n", + "#Derived2 class\n", + "class C:\n", + " def __init__(self):\n", + " print \"Constructor of class C\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class C\"\n", + " \n", + "#Derived3 class,multiple derivation\n", + "class D(B,C):\n", + " def __init__(self):\n", + " B.__init__(self)\n", + " C.__init__(self)\n", + " print \"Constructor of class D\"\n", + " \n", + " def __del__(self):\n", + " print \"Destructor of class D\"\n", + " B.__del__(self)\n", + " C.__del__(self)\n", + " \n", + "x=D() #creation of Derived3 class instance\n", + "del x\n", + " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class A\n", + "Constructor of class B\n", + "Constructor of class C\n", + "Constructor of class D\n", + "Destructor of class D\n", + "Destructor of class B\n", + "Destructor of class A\n", + "Destructor of class C\n" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.37, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrate single inheritance\n", + "\n", + "#Base class\n", + "class A:\n", + " def __init__(self,j=0):\n", + " self._c=j #protected Member\n", + " \n", + " def show(self): #Public member \n", + " print \"c=\",self._c\n", + " \n", + " def inc(self): #public increment method of base class\n", + " self._c=self._c+1\n", + " return self._c\n", + " \n", + "class B(A):\n", + " \n", + " def __init_(self):\n", + " for b in self.__class__.__bases__:\n", + " b.__init__(self)\n", + " \n", + " def dec(self): #public increment method of derived class\n", + " self._c=self._c-1\n", + " return self._c\n", + " \n", + " \n", + "a=B() #create a instance of a derived class\n", + "\n", + "a.inc() #call the base class public member function by derived class instance for increment\n", + "a.show()\n", + "\n", + "\n", + "a.dec() #call the derived class public member function by derived class instance for decrement\n", + "a.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c= 1\n", + "c= 0\n" + ] + } + ], + "prompt_number": 44 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.38, Page Number:502" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#access method from private inheritance\n", + "\n", + "#base class\n", + "class B:\n", + " def one(self): #Public Member\n", + " print \"one\"\n", + " \n", + " def __two(self): #Private Member\n", + " print \"two\"\n", + " \n", + "class D(B):\n", + " def __init__(self):\n", + " pass\n", + " \n", + "d=D()\n", + "d.one()\n", + "#d.two() #Not accesible" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "one\n" + ] + } + ], + "prompt_number": 45 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.39, Page Number:503" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", + "\n", + "#Base class\n", + "class A:\n", + " def __init__(self):\n", + " self.x=None\n", + " \n", + "#Derived1 class\n", + "class B(A):\n", + " def __init__(self):\n", + " self.y=None\n", + "\n", + "#Derived2 class\n", + "class C(B):\n", + " def __init__(self,j,k,l):\n", + " self.z=l #Initializing the base class data members by calling base class constructor\n", + " self.x=j\n", + " self.y=k\n", + " \n", + " def show(self):\n", + " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", + "\n", + "#Creation of instance of derived2 class,with constructor invocation \n", + "c=C(4,7,1)\n", + "c.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x= 4 Y= 7 z= 1\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 3, + "metadata": {}, + "source": [ + "Example 11.40, Page Number:504" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Explicitly call the base constructor in multiple inheritance\n", + "\n", + "#Base class\n", + "class X:\n", + " def __init__(self,a):\n", + " print a,\n", + "#Base class \n", + "class Y:\n", + " def __init__(self,b):\n", + " print b,\n", + "#multiple Derivation \n", + "class Z(X,Y):\n", + " def __init__(self,p,q,r):\n", + " X.__init__(self,p)\n", + " Y.__init__(self,q)\n", + " print r\n", + " \n", + "#Creation of instance of derived class,with constructor invocation \n", + "z=Z(1,2,3)\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1 2 3\n" + ] + } + ], + "prompt_number": 47 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance.ipynb b/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance.ipynb deleted file mode 100755 index 4f69b243..00000000 --- a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance.ipynb +++ /dev/null @@ -1,2636 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e85379c4218575d4b069259557cffbbc2d0259e3ba5d0e030c11dd77aae5e38d" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.1, Page Number:444" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#A simple classA having a public data member x\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - "\n", - "#A simple classA having a public data member y \n", - "class B(A): #derived class\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "b=B() #create a instance b of Derived class B\n", - "b.x=20\n", - "b.y=30\n", - "\n", - "print 'member of A:',b.x\n", - "print 'Member of B:',b.y" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "member of A: 20\n", - "Member of B: 30\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.2, Page Number:445" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self): #class A having x as a private data member\n", - " self.__x=20\n", - " \n", - " def showx(self):\n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A): #Derived class\n", - " def __init__(self):\n", - " self.y=30 #class B having y as a public data member\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx()\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B() #declaration of object\n", - " #class the method of derived class object by a derived class instance\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 30\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.3, Page Number:447" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None #x is a public member\n", - " \n", - " \n", - "#derived class\n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 \n", - " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", - " \n", - " def show(self):\n", - " print \"x=\",A.__x\n", - " print \"y=\",self.y\n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.4, Page Number:448" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self.__x=20 #x is a privet member of it\n", - " \n", - " def showx(self): \n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 #y is a public member of it\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx() #call the base class method\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.5, Page Number:449" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self._x=None #x is a protected member of the base class\n", - " \n", - " \n", - "class B(A): #private inheritance,x become a private member of the derived class\n", - " def __init__(self):\n", - " self.y=40\n", - " self.__x=30\n", - " \n", - " \n", - " def show(self):\n", - " print \"x=\",self.__x\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 30\n", - "y= 40\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.6, Page Number:456" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class ABC: #Base class\n", - " def __init__(self):\n", - " self._name=None #these 2 are protected data member\n", - " self._age=None\n", - " \n", - "class abc(ABC): #Derived class ,Public derivation\n", - " def __init__(self):\n", - " self.height=None\n", - " self.weight=None\n", - " \n", - " def getdata(self):\n", - " \n", - " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", - " self.age=raw_input(\"Enter a age: \") \n", - " self._height=raw_input(\"Enter a Height: \") \n", - " self._weight=raw_input(\"Enter a Weight: \") \n", - " \n", - " def show(self): #display the value of data members\n", - " print 'Name:',self.name \n", - " print 'Age:',self.age,\"years\"\n", - " print 'Height:',self._height,\"Feets\"\n", - " print 'Weight:',self._weight,\"kg.\"\n", - " \n", - " \n", - "x=abc()\n", - "x.getdata()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a name: Santosh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a age: 24\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Height: 4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Weight: 50\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Santosh\n", - "Age: 24 years\n", - "Height: 4.5 Feets\n", - "Weight: 50 kg.\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.7, Page Number:458" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A1: #super Base class,have 2 protected data members\n", - " def __init__(self):\n", - " self._name=None\n", - " self._age=None\n", - "\n", - " \n", - "class A2(A1): #Public derivation\n", - " def __init(self):\n", - " self._height=None\n", - " self._weight=None\n", - "\n", - "class A3(A2): #public Derivation\n", - " def __init__(self):\n", - " self._sex=None\n", - " \n", - " \n", - " def get(self): #get input \n", - " self._name=raw_input(\"Name: \")\n", - " self._age=raw_input(\"Age: \")\n", - " self._sex=raw_input(\"Sex: \")\n", - " \n", - " self._height=raw_input(\"Height: \")\n", - " self._weight=raw_input(\"Weight: \")\n", - " \n", - " def show(self): #Display values of all the data members\n", - " print \"Name:\",self._name\n", - " print \"Age:\",self._age ,\"years\"\n", - " print \"Sex:\",self._sex\n", - " print \"Height:\",self._height ,\"Feet\"\n", - " print \"Weight:\",self._weight ,\"Kg.\"\n", - " \n", - "\n", - "x=A3()\n", - "x.get()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age: 26\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight: 49.5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n", - "Age: 26 years\n", - "Sex: M\n", - "Height: 4 Feet\n", - "Weight: 49.5 Kg.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.8, Page Number:459" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Example of multiple Inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._a=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self._b=None\n", - " \n", - " \n", - "class C:\n", - " def __init__(self):\n", - " self._c=None\n", - " \n", - "class D:\n", - " def __init__(self):\n", - " self._d=None\n", - " \n", - "class E(A,B,C,D): #inherites all the base classes publically\n", - " def __init__(self):\n", - " self.e=None\n", - " \n", - " def getdata(self):\n", - " print \"Enter the value of a,b,c &d &e:\"\n", - " self._a=input()\n", - " self._b=input()\n", - " self._c=input()\n", - " self._d=input()\n", - " self._e=input()\n", - " \n", - " def show(self):\n", - " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", - " \n", - " \n", - "x=E() #x is the instance of the derived class\n", - "x.getdata() #call the methods of derived class through x \n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a,b,c &d &e:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "16\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a= 1 b= 2 c= 4 d= 8 e= 16\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.9, Page Number:461" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class red: #these three base class\n", - " def __init__(self):\n", - " print \"Red\",\n", - " \n", - "class yellow:\n", - " def __init__(self):\n", - " print \"Yellow\",\n", - " \n", - "class blue:\n", - " def __init__(self):\n", - " print \"Blue\",\n", - " \n", - "class orange(red,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Orange\",\n", - " \n", - "class green(blue,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " blue.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Green\",\n", - " \n", - "class violet(red,blue): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " blue.__init__(self)\n", - " print \"=Violet\",\n", - " \n", - "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Reddishbrown\"\n", - " \n", - "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Yellowishbrown\"\n", - " \n", - "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Bluishbrown\"\n", - " \n", - " \n", - " \n", - "r=reddishbrown() #create instances of the derived class\n", - "b=bluishbrown()\n", - "y=yellowishbrown()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", - "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", - "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.10, Page Number:463" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# WAP to create a derived class from multiple base classes\n", - "\n", - "class PLAYER: #these three are the base classes\n", - " def __init__(self):\n", - " self._name=None\n", - " self._gender=None\n", - " self._age\n", - " \n", - "class PHYSIQUE(PLAYER):\n", - " def __init__(self):\n", - " self._height=None\n", - " self._weight=None\n", - " \n", - "class LOCATION:\n", - " def __init__(self):\n", - " self._city=None\n", - " self._pin=None\n", - " \n", - "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", - " def __init__(self):\n", - " self._game=None\n", - " def getdata(self): #Method to take inputes\n", - " print\"Enter the following information\\n\\n\"\n", - " self._name=raw_input(\"Name:\")\n", - " self._gender=raw_input(\"Gender:\")\n", - " self._age=raw_input(\"Age:\")\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " self._city=raw_input(\"City:\")\n", - " self._pin=raw_input(\"Pin:\")\n", - " self._game=raw_input(\"game:\")\n", - " \n", - " \n", - " \n", - " def show(self): #Method for displaying inputes\n", - " print\"Entered Information!!\"\n", - " print\"Name:\",self._name\n", - " print \"Gender:\",self._gender\n", - " print \"Age:\",self._age\n", - " print \"Height:\",self._height\n", - " print \"Weight:\",self._weight\n", - " print \"City :\",self._city\n", - " print \"Pincode:\",self._pin\n", - " print \"Game :\",self._game\n", - " \n", - " \n", - "G=GAME() #create an instance of the derived class\n", - "G.getdata() #call the public methods by the created instances\n", - "G.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the following information\n", - "\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Mahesh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gender:M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:25\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.9\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:55\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "City:Nanded\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Pin:431603\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "game:Cricket\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Entered Information!!\n", - "Name: Mahesh\n", - "Gender: M\n", - "Age: 25\n", - "Height: 4.9\n", - "Weight: 55\n", - "City : Nanded\n", - "Pincode: 431603\n", - "Game : Cricket\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.11, Page Number:467" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Multipath Inheritance,concept of virtual classes\n", - "\n", - "class A1: #Super base class\n", - " def __init__(self):\n", - " self._a1=None\n", - " \n", - "class A2(A1): #base class 1,inherites Super Base class\n", - " def __init__(self):\n", - " self._a2=None\n", - " \n", - "class A3(A1): #base class 2,inherites Super Base class\n", - " def __init__(self):\n", - " self._a3=None\n", - " \n", - "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", - " def __init__(self):\n", - " self.__a4=None\n", - " \n", - " def get(self):\n", - " print \"Enter the value of a1,a2,a3,and a4:\"\n", - " self._a1=input()\n", - " self._a2=input()\n", - " self._a3=input()\n", - " self.__a4=input()\n", - " \n", - " def put(self):\n", - " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", - " \n", - " \n", - " \n", - "a=A4() #create the instance of the derived class\n", - "a.get()\n", - "a.put()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a1,a2,a3,and a4:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 5 a2= 8 a3= 7 a4= 3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.12, Page Number:469" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To show order of execution of the constructors and destructors in multiple inheritance\n", - "\n", - "#**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class A\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class A\"\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class B\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class B\"\n", - "\n", - "class C(A,B):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print\"Zero argument Constructor of base class C\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class C\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "c=C() #create instance of derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument Constructor of base class A\n", - "Zero argument Constructor of base class B\n", - "Zero argument Constructor of base class C\n", - "Destructor of class C\n", - "Destructor of class A\n", - "Destructor of class B\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.13, Page Number:471" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#WAP to use constructor and destructor in all the classess\n", - "\n", - "class A1:\n", - " def __init__(self): #take name and age as input in super base class\n", - " self._name=raw_input(\"Name:\")\n", - " self._age=raw_input(\"Age:\")\n", - " \n", - " def __del__(self):\n", - " print\"Name:\",self._name\n", - " print\"Age\",self._age\n", - " \n", - " \n", - "class A2(A1): #take height and weight as input in base base class,public derivation \n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " \n", - " def __del__(self):\n", - " print\"Height:\",self._height\n", - " print\"Weight:\",self._weight\n", - " A1.__del__(self)\n", - " \n", - " \n", - "class A3(A2): #take sex as input in derived class,derived from class A2\n", - " def __init__(self):\n", - " A2.__init__(self)\n", - " self.__sex=raw_input(\"Sex:\")\n", - " def __del__(self): #display all the input taken by all the base classes\n", - " print\"Sex:\",self.__sex\n", - " A2.__del__(self)\n", - " \n", - " \n", - "x=A3() #create instance x of the class A3\n", - "\n", - "del x #call the destructor" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:40\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex:M\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n", - "Height: 4.5\n", - "Weight: 40\n", - "Name: Ajay\n", - "Age 20\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.14, Page Number:472" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To create derived class from the base class,by constructor and destructor\n", - "class in_t:\n", - " def __init__(self):\n", - " self._i=1\n", - " print\"Constructor in_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor in_t()\"\n", - " \n", - "class floa_t:\n", - " def __init__(self):\n", - " self._f=1.5\n", - " print\"Constructor floa_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor floa_t()\"\n", - " \n", - " \n", - "class cha_r(in_t,floa_t): #multiple derivation\n", - " def __init__(self):\n", - " self._c='A'\n", - " print\"Constructor cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def show(self):\n", - " print\"i=\",self._i\n", - " print \"f=\",self._f\n", - " print \"c=\",self._c\n", - " \n", - " def __del__(self):\n", - " print \"Destructing cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "a=cha_r() #create derived class instance and call the public method of the derived class\n", - "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor cha_r()\n", - "Constructor in_t()\n", - "Constructor floa_t()\n", - "i= 1\n", - "f= 1.5\n", - "c= A\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.15, Page Number:474" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "class I:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " self.__y=None\n", - " \n", - " def set(self,j,k):\n", - " self.x=j\n", - " self.__y=k\n", - " \n", - " def show(self):\n", - " print \"X=\",self.x, \"Y=\",self.__y\n", - " \n", - " \n", - "i=II()\n", - "i.set(4,5)\n", - "i.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "X= 4 Y= 5\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.16, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class I:\n", - " def __init__(self):\n", - " self.x=10\n", - " print \"In the Base class constuctor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " self.__y=None\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In the Base class constuctor\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.17, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class without constructor and derived class with constructor\n", - "class I:\n", - " pass\n", - "class II(I):\n", - " def __init__(self):\n", - " print \"In derived class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In derived class constructor\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.18, Page Number:476" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#both the class have constructor\n", - "class I:\n", - " def __init__(self):\n", - " print \"In base class Constructor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"In derived Class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class Constructor\n", - "In derived Class constructor\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.19, Page Number:477" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple constructor in base class and single constructor in the derived class\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument base class construtor\"\n", - " \n", - " def __init__(self,k):\n", - " self.x=None\n", - " print \"One argument base class construtor\"\n", - " \n", - " \n", - "class II(I):\n", - " def __init__(self,j,k=None): #default constructor\n", - " I.__init__(self,k)\n", - " self.__y=j\n", - " print \"One argument derived class constructor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class constructor\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.20, Page Number:478" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base and derived class without default constructor\n", - "class I:\n", - " def __init__(self,k):\n", - " self.x=k\n", - " print \"One argument base class construtor\"\n", - " \n", - "class II(I):\n", - " def __init__(self,j):\n", - " I.__init__(self,j)\n", - " self.__y=j\n", - " print \"One argument derived class construtor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class construtor\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.21, Page Number:479" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors and multiple inheritance\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #class III inhrites class II and I\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #create an instance of the base class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.22, Page Number:480" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors in multiple inhritance with invoking constructor of the base classes\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I):\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.23, Page Number:481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple inheritance,invoking the base classes explicitly\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.24, Page Number:482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multilevel Inheritance,observation of the execution of the constructors\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.25, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#use object of one class in another class as a member\n", - "class I:\n", - " def __init__(self):\n", - " self.x=20\n", - " print \"Constructor of class I\"\n", - " \n", - "class II:\n", - " \n", - " def __init__(self):\n", - " self.k=30\n", - " y=I()\n", - " print \"Constructor of class II\"\n", - " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", - " \n", - " \n", - " def show(self):\n", - " print \"k=\",self.k\n", - " \n", - "ii=II()\n", - "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class I\n", - "Constructor of class II\n", - "x= 20\n", - "k= 30\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.26, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access a member variable of base class using object,class name, and direct\n", - "\n", - "class A1:\n", - " def __init__(self):\n", - " self.name=None\n", - " self.age=None\n", - " \n", - "class A2(A1):\n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " a=A1()\n", - " print \"Access using name of the class:\"\n", - " A1.name=raw_input(\"Name:\")\n", - " A1.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using object of the class\"\n", - " a.name=raw_input(\"Name:\")\n", - " a.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using direct member variables:\"\n", - " self.name=raw_input(\"Name:\")\n", - " self.age=raw_input(\"Age:\")\n", - " self.__height=raw_input(\"Height:\")\n", - " self.__weight=raw_input(\"Weight:\")\n", - " \n", - " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", - " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", - " print \"Age:\",a.age\n", - " \n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of Derived class\"\n", - " print \"Display using class name\"\n", - " print \"Name:\",A1.name\n", - " print \"Age:\",A1.age\n", - " \n", - " print \"Display using direct member variable\"\n", - " print \"Name:\",self.name\n", - " print \"Age\",self.age\n", - " print \"height:\",self.__height\n", - " print \"Weight:\",self.__weight\n", - " \n", - "x=A2()\n", - "\n", - "del x\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using name of the class:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:21\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using object of the class\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Amit\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using direct member variables:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Arun\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:19\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:5.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:31\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Display using object of the class\n", - "Name: Amit\n", - "Age: 20\n", - "Destructor of Derived class\n", - "Display using class name\n", - "Name: Ajay\n", - "Age: 21\n", - "Display using direct member variable\n", - "Name: Arun\n", - "Age 19\n", - "height: 5.5\n", - "Weight: 31\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.27, Page Number:488" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.a1=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self.b1=None\n", - " \n", - "class AB:\n", - " def __init__(self):\n", - " a=A()\n", - " b=B()\n", - " a.a1=65 #initialize the two data members of the class A and B and Display them\n", - " b.b1=66\n", - " print \"a1=\",a.a1, \"b1=\",b.b1\n", - " \n", - " def __del__(self):\n", - " pass\n", - " \n", - " \n", - "ab=AB()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 65 b1= 66\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.28, Page Number:489" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create derived class from qualifier class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - " class B:\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - " \n", - "class C(A,A.B): #A.B is the inner class of the class A\n", - " def __init__(self,j,k,l):\n", - " self.x=j\n", - " self.y=k\n", - " self.z=l\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", - " \n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 y= 7 z= 1\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.29, Page Number:490" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialize member variable of the base class and derived class using constructor of the derived class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._x=None #protected members\n", - " self._y=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.z=3\n", - " self.__x=1 #private members\n", - " self.__y=2\n", - " \n", - " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", - " \n", - "b=B()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 1 y= 2 z= 3\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.30, Page Number:491" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access data members by object pointer\n", - "\n", - "from ctypes import *\n", - "import ctypes\n", - "class A:\n", - " def __init__(self):\n", - " self.x=1\n", - " self.y=2\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " self.z=3\n", - " \n", - "b=B()\n", - "\n", - "\n", - "i=c_int(b.z)\n", - "p=pointer(i)\n", - "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", - "\n", - "i = c_int(b.y)\n", - "p = pointer(i)\n", - "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", - "\n", - "i = c_int(b.x)\n", - "p = pointer(i)\n", - "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", - "\n", - "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", - "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", - "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Address of z: 57077392 Value of Z: 3\n", - "Address of y: 57074448 Value of y: 2\n", - "Address of x: 57077648 Value of x: 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.31, Page Number:492" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#overload member function in base and derived class\n", - "\n", - "class B:\n", - " def show(self):\n", - " print \"In base class function\"\n", - " \n", - "class D(B):\n", - " def show(self):\n", - " \n", - " print \"In Derived class\"\n", - " \n", - " \n", - "b=B()\n", - "d=D()\n", - "\n", - "b.show()\n", - "d.show()\n", - "\n", - "bp=[B()] #create a base class pointer variable\n", - "bp[0]=d #assign address of the derived class object to the base class pointer\n", - "bp[0].show() #call the derived class method by base class pointer\n", - "b.show() #calling the base class method by base class object" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class function\n", - "In Derived class\n", - "In Derived class\n", - "In base class function\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.32, Page Number:495" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in single inheritance\n", - "class Father:\n", - " def __init__(self):\n", - " print \"Base Class constructor.\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Base class Destructor.\"\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print \"Derived class constructor.\"\n", - " self.__cname=raw_input(\"Enter child name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Derived class destructor.\"\n", - " print \"\",self.__cname,\"\",self.__name\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - " \n", - " \n", - "C=Child()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Base Class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:Manoj\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter child name:Sanjay\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class destructor.\n", - " Sanjay Manoj\n", - "Base class Destructor.\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.33, Page Number:496" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in multilevel inheritance\n", - "\n", - "class Grandfather:\n", - " def __init__(self):\n", - " print\"Constructor of class grandfather\"\n", - " self._gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class grandfather\"\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " Grandfather.__init__(self)\n", - " print\"Constructor of class Father\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Father\"\n", - " Grandfather.__del__(self)\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print\"Constructor of class Child\"\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Child\"\n", - " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", - " Father.__del__(self) \n", - " \n", - " \n", - "C=Child()\n", - "\n", - "del C #call the destructor of the derived class\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class grandfather\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:x\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Father\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:y\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Child\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:z\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Destructor of class Child\n", - "Grandfather: x Father: y Child: z\n", - "Destructor of class Father\n", - "Destructor of class grandfather\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.34, Page Number:498" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#program to explain multilevel inheritance with member function\n", - "class Grandfather:\n", - " def __init__(self):\n", - " self.__gname=None\n", - " \n", - " def getg(self):\n", - " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " def showg(self):\n", - " print \"Grandfather Name:\",self.__gname\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " self.__name=None\n", - " \n", - " def getf(self):\n", - " self.__name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def showf(self):\n", - " print \"Father Name:\",self.__name\n", - " \n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " self.__cname=None\n", - " \n", - " def getc(self):\n", - " self.getg()\n", - " self.getf()\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " def showc(self):\n", - " self.showg()\n", - " self.showf()\n", - " print \"child Name:\",self.__cname\n", - " \n", - "C=Child()\n", - "C.getc()\n", - "C.showc()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:XXX\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:YYY\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:ZZZ\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Grandfather Name: XXX\n", - "Father Name: YYY\n", - "child Name: ZZZ\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.35, Page Number:499" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(A,B,C):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "x=D() \n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class A\n", - "Destructor of class B\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " A.__del__(self)\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(B,C):\n", - " def __init__(self):\n", - " B.__init__(self)\n", - " C.__init__(self)\n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " B.__del__(self)\n", - " C.__del__(self)\n", - " \n", - "x=D() \n", - "del x\n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class B\n", - "Destructor of class A\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrate single inheritance\n", - "\n", - "class A:\n", - " def __init__(self,j=0):\n", - " self._c=j\n", - " \n", - " def show(self):\n", - " print \"c=\",self._c\n", - " \n", - " def inc(self):\n", - " self._c=self._c+1\n", - " return self._c\n", - " \n", - "class B(A):\n", - " \n", - " def __init_(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def dec(self):\n", - " self._c=self._c-1\n", - " return self._c\n", - " \n", - " \n", - "a=B()\n", - "a.inc()\n", - "a.show()\n", - "\n", - "\n", - "a.dec()\n", - "a.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c= 1\n", - "c= 0\n" - ] - } - ], - "prompt_number": 44 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.38, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access method from private inheritance\n", - "class B:\n", - " def one(self):\n", - " print \"one\"\n", - " \n", - " def __two(self):\n", - " print \"two\"\n", - " \n", - "class D(B):\n", - " def __init__(self):\n", - " pass\n", - " \n", - "d=D()\n", - "d.one()\n", - "#d.two() #Not accesible" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "one\n" - ] - } - ], - "prompt_number": 45 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.39, Page Number:503" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "class C(B):\n", - " def __init__(self,j,k,l):\n", - " self.z=l\n", - " self.x=j\n", - " self.y=k\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 Y= 7 z= 1\n" - ] - } - ], - "prompt_number": 46 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.40, Page Number:504" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Explicitly call the base constructor in multiple inheritance\n", - "\n", - "class X:\n", - " def __init__(self,a):\n", - " print a,\n", - " \n", - "class Y:\n", - " def __init__(self,b):\n", - " print b,\n", - " \n", - "class Z(X,Y):\n", - " def __init__(self,p,q,r):\n", - " X.__init__(self,p)\n", - " Y.__init__(self,q)\n", - " print r\n", - " \n", - " \n", - "z=Z(1,2,3)\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "1 2 3\n" - ] - } - ], - "prompt_number": 47 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_(1).ipynb b/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_(1).ipynb deleted file mode 100755 index 4f69b243..00000000 --- a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_(1).ipynb +++ /dev/null @@ -1,2636 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e85379c4218575d4b069259557cffbbc2d0259e3ba5d0e030c11dd77aae5e38d" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.1, Page Number:444" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#A simple classA having a public data member x\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - "\n", - "#A simple classA having a public data member y \n", - "class B(A): #derived class\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "b=B() #create a instance b of Derived class B\n", - "b.x=20\n", - "b.y=30\n", - "\n", - "print 'member of A:',b.x\n", - "print 'Member of B:',b.y" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "member of A: 20\n", - "Member of B: 30\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.2, Page Number:445" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self): #class A having x as a private data member\n", - " self.__x=20\n", - " \n", - " def showx(self):\n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A): #Derived class\n", - " def __init__(self):\n", - " self.y=30 #class B having y as a public data member\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx()\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B() #declaration of object\n", - " #class the method of derived class object by a derived class instance\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 30\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.3, Page Number:447" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None #x is a public member\n", - " \n", - " \n", - "#derived class\n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 \n", - " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", - " \n", - " def show(self):\n", - " print \"x=\",A.__x\n", - " print \"y=\",self.y\n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.4, Page Number:448" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self.__x=20 #x is a privet member of it\n", - " \n", - " def showx(self): \n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 #y is a public member of it\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx() #call the base class method\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.5, Page Number:449" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self._x=None #x is a protected member of the base class\n", - " \n", - " \n", - "class B(A): #private inheritance,x become a private member of the derived class\n", - " def __init__(self):\n", - " self.y=40\n", - " self.__x=30\n", - " \n", - " \n", - " def show(self):\n", - " print \"x=\",self.__x\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 30\n", - "y= 40\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.6, Page Number:456" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class ABC: #Base class\n", - " def __init__(self):\n", - " self._name=None #these 2 are protected data member\n", - " self._age=None\n", - " \n", - "class abc(ABC): #Derived class ,Public derivation\n", - " def __init__(self):\n", - " self.height=None\n", - " self.weight=None\n", - " \n", - " def getdata(self):\n", - " \n", - " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", - " self.age=raw_input(\"Enter a age: \") \n", - " self._height=raw_input(\"Enter a Height: \") \n", - " self._weight=raw_input(\"Enter a Weight: \") \n", - " \n", - " def show(self): #display the value of data members\n", - " print 'Name:',self.name \n", - " print 'Age:',self.age,\"years\"\n", - " print 'Height:',self._height,\"Feets\"\n", - " print 'Weight:',self._weight,\"kg.\"\n", - " \n", - " \n", - "x=abc()\n", - "x.getdata()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a name: Santosh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a age: 24\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Height: 4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Weight: 50\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Santosh\n", - "Age: 24 years\n", - "Height: 4.5 Feets\n", - "Weight: 50 kg.\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.7, Page Number:458" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A1: #super Base class,have 2 protected data members\n", - " def __init__(self):\n", - " self._name=None\n", - " self._age=None\n", - "\n", - " \n", - "class A2(A1): #Public derivation\n", - " def __init(self):\n", - " self._height=None\n", - " self._weight=None\n", - "\n", - "class A3(A2): #public Derivation\n", - " def __init__(self):\n", - " self._sex=None\n", - " \n", - " \n", - " def get(self): #get input \n", - " self._name=raw_input(\"Name: \")\n", - " self._age=raw_input(\"Age: \")\n", - " self._sex=raw_input(\"Sex: \")\n", - " \n", - " self._height=raw_input(\"Height: \")\n", - " self._weight=raw_input(\"Weight: \")\n", - " \n", - " def show(self): #Display values of all the data members\n", - " print \"Name:\",self._name\n", - " print \"Age:\",self._age ,\"years\"\n", - " print \"Sex:\",self._sex\n", - " print \"Height:\",self._height ,\"Feet\"\n", - " print \"Weight:\",self._weight ,\"Kg.\"\n", - " \n", - "\n", - "x=A3()\n", - "x.get()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age: 26\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight: 49.5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n", - "Age: 26 years\n", - "Sex: M\n", - "Height: 4 Feet\n", - "Weight: 49.5 Kg.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.8, Page Number:459" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Example of multiple Inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._a=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self._b=None\n", - " \n", - " \n", - "class C:\n", - " def __init__(self):\n", - " self._c=None\n", - " \n", - "class D:\n", - " def __init__(self):\n", - " self._d=None\n", - " \n", - "class E(A,B,C,D): #inherites all the base classes publically\n", - " def __init__(self):\n", - " self.e=None\n", - " \n", - " def getdata(self):\n", - " print \"Enter the value of a,b,c &d &e:\"\n", - " self._a=input()\n", - " self._b=input()\n", - " self._c=input()\n", - " self._d=input()\n", - " self._e=input()\n", - " \n", - " def show(self):\n", - " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", - " \n", - " \n", - "x=E() #x is the instance of the derived class\n", - "x.getdata() #call the methods of derived class through x \n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a,b,c &d &e:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "16\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a= 1 b= 2 c= 4 d= 8 e= 16\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.9, Page Number:461" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class red: #these three base class\n", - " def __init__(self):\n", - " print \"Red\",\n", - " \n", - "class yellow:\n", - " def __init__(self):\n", - " print \"Yellow\",\n", - " \n", - "class blue:\n", - " def __init__(self):\n", - " print \"Blue\",\n", - " \n", - "class orange(red,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Orange\",\n", - " \n", - "class green(blue,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " blue.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Green\",\n", - " \n", - "class violet(red,blue): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " blue.__init__(self)\n", - " print \"=Violet\",\n", - " \n", - "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Reddishbrown\"\n", - " \n", - "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Yellowishbrown\"\n", - " \n", - "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Bluishbrown\"\n", - " \n", - " \n", - " \n", - "r=reddishbrown() #create instances of the derived class\n", - "b=bluishbrown()\n", - "y=yellowishbrown()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", - "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", - "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.10, Page Number:463" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# WAP to create a derived class from multiple base classes\n", - "\n", - "class PLAYER: #these three are the base classes\n", - " def __init__(self):\n", - " self._name=None\n", - " self._gender=None\n", - " self._age\n", - " \n", - "class PHYSIQUE(PLAYER):\n", - " def __init__(self):\n", - " self._height=None\n", - " self._weight=None\n", - " \n", - "class LOCATION:\n", - " def __init__(self):\n", - " self._city=None\n", - " self._pin=None\n", - " \n", - "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", - " def __init__(self):\n", - " self._game=None\n", - " def getdata(self): #Method to take inputes\n", - " print\"Enter the following information\\n\\n\"\n", - " self._name=raw_input(\"Name:\")\n", - " self._gender=raw_input(\"Gender:\")\n", - " self._age=raw_input(\"Age:\")\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " self._city=raw_input(\"City:\")\n", - " self._pin=raw_input(\"Pin:\")\n", - " self._game=raw_input(\"game:\")\n", - " \n", - " \n", - " \n", - " def show(self): #Method for displaying inputes\n", - " print\"Entered Information!!\"\n", - " print\"Name:\",self._name\n", - " print \"Gender:\",self._gender\n", - " print \"Age:\",self._age\n", - " print \"Height:\",self._height\n", - " print \"Weight:\",self._weight\n", - " print \"City :\",self._city\n", - " print \"Pincode:\",self._pin\n", - " print \"Game :\",self._game\n", - " \n", - " \n", - "G=GAME() #create an instance of the derived class\n", - "G.getdata() #call the public methods by the created instances\n", - "G.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the following information\n", - "\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Mahesh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gender:M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:25\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.9\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:55\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "City:Nanded\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Pin:431603\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "game:Cricket\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Entered Information!!\n", - "Name: Mahesh\n", - "Gender: M\n", - "Age: 25\n", - "Height: 4.9\n", - "Weight: 55\n", - "City : Nanded\n", - "Pincode: 431603\n", - "Game : Cricket\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.11, Page Number:467" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Multipath Inheritance,concept of virtual classes\n", - "\n", - "class A1: #Super base class\n", - " def __init__(self):\n", - " self._a1=None\n", - " \n", - "class A2(A1): #base class 1,inherites Super Base class\n", - " def __init__(self):\n", - " self._a2=None\n", - " \n", - "class A3(A1): #base class 2,inherites Super Base class\n", - " def __init__(self):\n", - " self._a3=None\n", - " \n", - "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", - " def __init__(self):\n", - " self.__a4=None\n", - " \n", - " def get(self):\n", - " print \"Enter the value of a1,a2,a3,and a4:\"\n", - " self._a1=input()\n", - " self._a2=input()\n", - " self._a3=input()\n", - " self.__a4=input()\n", - " \n", - " def put(self):\n", - " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", - " \n", - " \n", - " \n", - "a=A4() #create the instance of the derived class\n", - "a.get()\n", - "a.put()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a1,a2,a3,and a4:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 5 a2= 8 a3= 7 a4= 3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.12, Page Number:469" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To show order of execution of the constructors and destructors in multiple inheritance\n", - "\n", - "#**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class A\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class A\"\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class B\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class B\"\n", - "\n", - "class C(A,B):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print\"Zero argument Constructor of base class C\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class C\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "c=C() #create instance of derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument Constructor of base class A\n", - "Zero argument Constructor of base class B\n", - "Zero argument Constructor of base class C\n", - "Destructor of class C\n", - "Destructor of class A\n", - "Destructor of class B\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.13, Page Number:471" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#WAP to use constructor and destructor in all the classess\n", - "\n", - "class A1:\n", - " def __init__(self): #take name and age as input in super base class\n", - " self._name=raw_input(\"Name:\")\n", - " self._age=raw_input(\"Age:\")\n", - " \n", - " def __del__(self):\n", - " print\"Name:\",self._name\n", - " print\"Age\",self._age\n", - " \n", - " \n", - "class A2(A1): #take height and weight as input in base base class,public derivation \n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " \n", - " def __del__(self):\n", - " print\"Height:\",self._height\n", - " print\"Weight:\",self._weight\n", - " A1.__del__(self)\n", - " \n", - " \n", - "class A3(A2): #take sex as input in derived class,derived from class A2\n", - " def __init__(self):\n", - " A2.__init__(self)\n", - " self.__sex=raw_input(\"Sex:\")\n", - " def __del__(self): #display all the input taken by all the base classes\n", - " print\"Sex:\",self.__sex\n", - " A2.__del__(self)\n", - " \n", - " \n", - "x=A3() #create instance x of the class A3\n", - "\n", - "del x #call the destructor" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:40\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex:M\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n", - "Height: 4.5\n", - "Weight: 40\n", - "Name: Ajay\n", - "Age 20\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.14, Page Number:472" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To create derived class from the base class,by constructor and destructor\n", - "class in_t:\n", - " def __init__(self):\n", - " self._i=1\n", - " print\"Constructor in_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor in_t()\"\n", - " \n", - "class floa_t:\n", - " def __init__(self):\n", - " self._f=1.5\n", - " print\"Constructor floa_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor floa_t()\"\n", - " \n", - " \n", - "class cha_r(in_t,floa_t): #multiple derivation\n", - " def __init__(self):\n", - " self._c='A'\n", - " print\"Constructor cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def show(self):\n", - " print\"i=\",self._i\n", - " print \"f=\",self._f\n", - " print \"c=\",self._c\n", - " \n", - " def __del__(self):\n", - " print \"Destructing cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "a=cha_r() #create derived class instance and call the public method of the derived class\n", - "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor cha_r()\n", - "Constructor in_t()\n", - "Constructor floa_t()\n", - "i= 1\n", - "f= 1.5\n", - "c= A\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.15, Page Number:474" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "class I:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " self.__y=None\n", - " \n", - " def set(self,j,k):\n", - " self.x=j\n", - " self.__y=k\n", - " \n", - " def show(self):\n", - " print \"X=\",self.x, \"Y=\",self.__y\n", - " \n", - " \n", - "i=II()\n", - "i.set(4,5)\n", - "i.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "X= 4 Y= 5\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.16, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class I:\n", - " def __init__(self):\n", - " self.x=10\n", - " print \"In the Base class constuctor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " self.__y=None\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In the Base class constuctor\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.17, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class without constructor and derived class with constructor\n", - "class I:\n", - " pass\n", - "class II(I):\n", - " def __init__(self):\n", - " print \"In derived class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In derived class constructor\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.18, Page Number:476" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#both the class have constructor\n", - "class I:\n", - " def __init__(self):\n", - " print \"In base class Constructor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"In derived Class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class Constructor\n", - "In derived Class constructor\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.19, Page Number:477" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple constructor in base class and single constructor in the derived class\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument base class construtor\"\n", - " \n", - " def __init__(self,k):\n", - " self.x=None\n", - " print \"One argument base class construtor\"\n", - " \n", - " \n", - "class II(I):\n", - " def __init__(self,j,k=None): #default constructor\n", - " I.__init__(self,k)\n", - " self.__y=j\n", - " print \"One argument derived class constructor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class constructor\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.20, Page Number:478" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base and derived class without default constructor\n", - "class I:\n", - " def __init__(self,k):\n", - " self.x=k\n", - " print \"One argument base class construtor\"\n", - " \n", - "class II(I):\n", - " def __init__(self,j):\n", - " I.__init__(self,j)\n", - " self.__y=j\n", - " print \"One argument derived class construtor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class construtor\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.21, Page Number:479" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors and multiple inheritance\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #class III inhrites class II and I\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #create an instance of the base class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.22, Page Number:480" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors in multiple inhritance with invoking constructor of the base classes\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I):\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.23, Page Number:481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple inheritance,invoking the base classes explicitly\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.24, Page Number:482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multilevel Inheritance,observation of the execution of the constructors\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.25, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#use object of one class in another class as a member\n", - "class I:\n", - " def __init__(self):\n", - " self.x=20\n", - " print \"Constructor of class I\"\n", - " \n", - "class II:\n", - " \n", - " def __init__(self):\n", - " self.k=30\n", - " y=I()\n", - " print \"Constructor of class II\"\n", - " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", - " \n", - " \n", - " def show(self):\n", - " print \"k=\",self.k\n", - " \n", - "ii=II()\n", - "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class I\n", - "Constructor of class II\n", - "x= 20\n", - "k= 30\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.26, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access a member variable of base class using object,class name, and direct\n", - "\n", - "class A1:\n", - " def __init__(self):\n", - " self.name=None\n", - " self.age=None\n", - " \n", - "class A2(A1):\n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " a=A1()\n", - " print \"Access using name of the class:\"\n", - " A1.name=raw_input(\"Name:\")\n", - " A1.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using object of the class\"\n", - " a.name=raw_input(\"Name:\")\n", - " a.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using direct member variables:\"\n", - " self.name=raw_input(\"Name:\")\n", - " self.age=raw_input(\"Age:\")\n", - " self.__height=raw_input(\"Height:\")\n", - " self.__weight=raw_input(\"Weight:\")\n", - " \n", - " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", - " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", - " print \"Age:\",a.age\n", - " \n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of Derived class\"\n", - " print \"Display using class name\"\n", - " print \"Name:\",A1.name\n", - " print \"Age:\",A1.age\n", - " \n", - " print \"Display using direct member variable\"\n", - " print \"Name:\",self.name\n", - " print \"Age\",self.age\n", - " print \"height:\",self.__height\n", - " print \"Weight:\",self.__weight\n", - " \n", - "x=A2()\n", - "\n", - "del x\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using name of the class:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:21\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using object of the class\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Amit\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using direct member variables:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Arun\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:19\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:5.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:31\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Display using object of the class\n", - "Name: Amit\n", - "Age: 20\n", - "Destructor of Derived class\n", - "Display using class name\n", - "Name: Ajay\n", - "Age: 21\n", - "Display using direct member variable\n", - "Name: Arun\n", - "Age 19\n", - "height: 5.5\n", - "Weight: 31\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.27, Page Number:488" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.a1=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self.b1=None\n", - " \n", - "class AB:\n", - " def __init__(self):\n", - " a=A()\n", - " b=B()\n", - " a.a1=65 #initialize the two data members of the class A and B and Display them\n", - " b.b1=66\n", - " print \"a1=\",a.a1, \"b1=\",b.b1\n", - " \n", - " def __del__(self):\n", - " pass\n", - " \n", - " \n", - "ab=AB()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 65 b1= 66\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.28, Page Number:489" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create derived class from qualifier class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - " class B:\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - " \n", - "class C(A,A.B): #A.B is the inner class of the class A\n", - " def __init__(self,j,k,l):\n", - " self.x=j\n", - " self.y=k\n", - " self.z=l\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", - " \n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 y= 7 z= 1\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.29, Page Number:490" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialize member variable of the base class and derived class using constructor of the derived class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._x=None #protected members\n", - " self._y=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.z=3\n", - " self.__x=1 #private members\n", - " self.__y=2\n", - " \n", - " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", - " \n", - "b=B()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 1 y= 2 z= 3\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.30, Page Number:491" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access data members by object pointer\n", - "\n", - "from ctypes import *\n", - "import ctypes\n", - "class A:\n", - " def __init__(self):\n", - " self.x=1\n", - " self.y=2\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " self.z=3\n", - " \n", - "b=B()\n", - "\n", - "\n", - "i=c_int(b.z)\n", - "p=pointer(i)\n", - "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", - "\n", - "i = c_int(b.y)\n", - "p = pointer(i)\n", - "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", - "\n", - "i = c_int(b.x)\n", - "p = pointer(i)\n", - "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", - "\n", - "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", - "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", - "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Address of z: 57077392 Value of Z: 3\n", - "Address of y: 57074448 Value of y: 2\n", - "Address of x: 57077648 Value of x: 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.31, Page Number:492" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#overload member function in base and derived class\n", - "\n", - "class B:\n", - " def show(self):\n", - " print \"In base class function\"\n", - " \n", - "class D(B):\n", - " def show(self):\n", - " \n", - " print \"In Derived class\"\n", - " \n", - " \n", - "b=B()\n", - "d=D()\n", - "\n", - "b.show()\n", - "d.show()\n", - "\n", - "bp=[B()] #create a base class pointer variable\n", - "bp[0]=d #assign address of the derived class object to the base class pointer\n", - "bp[0].show() #call the derived class method by base class pointer\n", - "b.show() #calling the base class method by base class object" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class function\n", - "In Derived class\n", - "In Derived class\n", - "In base class function\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.32, Page Number:495" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in single inheritance\n", - "class Father:\n", - " def __init__(self):\n", - " print \"Base Class constructor.\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Base class Destructor.\"\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print \"Derived class constructor.\"\n", - " self.__cname=raw_input(\"Enter child name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Derived class destructor.\"\n", - " print \"\",self.__cname,\"\",self.__name\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - " \n", - " \n", - "C=Child()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Base Class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:Manoj\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter child name:Sanjay\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class destructor.\n", - " Sanjay Manoj\n", - "Base class Destructor.\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.33, Page Number:496" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in multilevel inheritance\n", - "\n", - "class Grandfather:\n", - " def __init__(self):\n", - " print\"Constructor of class grandfather\"\n", - " self._gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class grandfather\"\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " Grandfather.__init__(self)\n", - " print\"Constructor of class Father\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Father\"\n", - " Grandfather.__del__(self)\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print\"Constructor of class Child\"\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Child\"\n", - " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", - " Father.__del__(self) \n", - " \n", - " \n", - "C=Child()\n", - "\n", - "del C #call the destructor of the derived class\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class grandfather\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:x\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Father\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:y\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Child\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:z\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Destructor of class Child\n", - "Grandfather: x Father: y Child: z\n", - "Destructor of class Father\n", - "Destructor of class grandfather\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.34, Page Number:498" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#program to explain multilevel inheritance with member function\n", - "class Grandfather:\n", - " def __init__(self):\n", - " self.__gname=None\n", - " \n", - " def getg(self):\n", - " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " def showg(self):\n", - " print \"Grandfather Name:\",self.__gname\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " self.__name=None\n", - " \n", - " def getf(self):\n", - " self.__name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def showf(self):\n", - " print \"Father Name:\",self.__name\n", - " \n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " self.__cname=None\n", - " \n", - " def getc(self):\n", - " self.getg()\n", - " self.getf()\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " def showc(self):\n", - " self.showg()\n", - " self.showf()\n", - " print \"child Name:\",self.__cname\n", - " \n", - "C=Child()\n", - "C.getc()\n", - "C.showc()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:XXX\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:YYY\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:ZZZ\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Grandfather Name: XXX\n", - "Father Name: YYY\n", - "child Name: ZZZ\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.35, Page Number:499" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(A,B,C):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "x=D() \n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class A\n", - "Destructor of class B\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " A.__del__(self)\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(B,C):\n", - " def __init__(self):\n", - " B.__init__(self)\n", - " C.__init__(self)\n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " B.__del__(self)\n", - " C.__del__(self)\n", - " \n", - "x=D() \n", - "del x\n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class B\n", - "Destructor of class A\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrate single inheritance\n", - "\n", - "class A:\n", - " def __init__(self,j=0):\n", - " self._c=j\n", - " \n", - " def show(self):\n", - " print \"c=\",self._c\n", - " \n", - " def inc(self):\n", - " self._c=self._c+1\n", - " return self._c\n", - " \n", - "class B(A):\n", - " \n", - " def __init_(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def dec(self):\n", - " self._c=self._c-1\n", - " return self._c\n", - " \n", - " \n", - "a=B()\n", - "a.inc()\n", - "a.show()\n", - "\n", - "\n", - "a.dec()\n", - "a.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c= 1\n", - "c= 0\n" - ] - } - ], - "prompt_number": 44 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.38, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access method from private inheritance\n", - "class B:\n", - " def one(self):\n", - " print \"one\"\n", - " \n", - " def __two(self):\n", - " print \"two\"\n", - " \n", - "class D(B):\n", - " def __init__(self):\n", - " pass\n", - " \n", - "d=D()\n", - "d.one()\n", - "#d.two() #Not accesible" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "one\n" - ] - } - ], - "prompt_number": 45 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.39, Page Number:503" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "class C(B):\n", - " def __init__(self,j,k,l):\n", - " self.z=l\n", - " self.x=j\n", - " self.y=k\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 Y= 7 z= 1\n" - ] - } - ], - "prompt_number": 46 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.40, Page Number:504" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Explicitly call the base constructor in multiple inheritance\n", - "\n", - "class X:\n", - " def __init__(self,a):\n", - " print a,\n", - " \n", - "class Y:\n", - " def __init__(self,b):\n", - " print b,\n", - " \n", - "class Z(X,Y):\n", - " def __init__(self,p,q,r):\n", - " X.__init__(self,p)\n", - " Y.__init__(self,q)\n", - " print r\n", - " \n", - " \n", - "z=Z(1,2,3)\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "1 2 3\n" - ] - } - ], - "prompt_number": 47 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_1.ipynb b/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_1.ipynb deleted file mode 100755 index 4f69b243..00000000 --- a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_1.ipynb +++ /dev/null @@ -1,2636 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e85379c4218575d4b069259557cffbbc2d0259e3ba5d0e030c11dd77aae5e38d" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.1, Page Number:444" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#A simple classA having a public data member x\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - "\n", - "#A simple classA having a public data member y \n", - "class B(A): #derived class\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "b=B() #create a instance b of Derived class B\n", - "b.x=20\n", - "b.y=30\n", - "\n", - "print 'member of A:',b.x\n", - "print 'Member of B:',b.y" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "member of A: 20\n", - "Member of B: 30\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.2, Page Number:445" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self): #class A having x as a private data member\n", - " self.__x=20\n", - " \n", - " def showx(self):\n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A): #Derived class\n", - " def __init__(self):\n", - " self.y=30 #class B having y as a public data member\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx()\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B() #declaration of object\n", - " #class the method of derived class object by a derived class instance\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 30\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.3, Page Number:447" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None #x is a public member\n", - " \n", - " \n", - "#derived class\n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 \n", - " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", - " \n", - " def show(self):\n", - " print \"x=\",A.__x\n", - " print \"y=\",self.y\n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.4, Page Number:448" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self.__x=20 #x is a privet member of it\n", - " \n", - " def showx(self): \n", - " print \"x=\",self.__x\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 #y is a public member of it\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx() #call the base class method\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.5, Page Number:449" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self._x=None #x is a protected member of the base class\n", - " \n", - " \n", - "class B(A): #private inheritance,x become a private member of the derived class\n", - " def __init__(self):\n", - " self.y=40\n", - " self.__x=30\n", - " \n", - " \n", - " def show(self):\n", - " print \"x=\",self.__x\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 30\n", - "y= 40\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.6, Page Number:456" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class ABC: #Base class\n", - " def __init__(self):\n", - " self._name=None #these 2 are protected data member\n", - " self._age=None\n", - " \n", - "class abc(ABC): #Derived class ,Public derivation\n", - " def __init__(self):\n", - " self.height=None\n", - " self.weight=None\n", - " \n", - " def getdata(self):\n", - " \n", - " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", - " self.age=raw_input(\"Enter a age: \") \n", - " self._height=raw_input(\"Enter a Height: \") \n", - " self._weight=raw_input(\"Enter a Weight: \") \n", - " \n", - " def show(self): #display the value of data members\n", - " print 'Name:',self.name \n", - " print 'Age:',self.age,\"years\"\n", - " print 'Height:',self._height,\"Feets\"\n", - " print 'Weight:',self._weight,\"kg.\"\n", - " \n", - " \n", - "x=abc()\n", - "x.getdata()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a name: Santosh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a age: 24\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Height: 4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Weight: 50\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Santosh\n", - "Age: 24 years\n", - "Height: 4.5 Feets\n", - "Weight: 50 kg.\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.7, Page Number:458" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A1: #super Base class,have 2 protected data members\n", - " def __init__(self):\n", - " self._name=None\n", - " self._age=None\n", - "\n", - " \n", - "class A2(A1): #Public derivation\n", - " def __init(self):\n", - " self._height=None\n", - " self._weight=None\n", - "\n", - "class A3(A2): #public Derivation\n", - " def __init__(self):\n", - " self._sex=None\n", - " \n", - " \n", - " def get(self): #get input \n", - " self._name=raw_input(\"Name: \")\n", - " self._age=raw_input(\"Age: \")\n", - " self._sex=raw_input(\"Sex: \")\n", - " \n", - " self._height=raw_input(\"Height: \")\n", - " self._weight=raw_input(\"Weight: \")\n", - " \n", - " def show(self): #Display values of all the data members\n", - " print \"Name:\",self._name\n", - " print \"Age:\",self._age ,\"years\"\n", - " print \"Sex:\",self._sex\n", - " print \"Height:\",self._height ,\"Feet\"\n", - " print \"Weight:\",self._weight ,\"Kg.\"\n", - " \n", - "\n", - "x=A3()\n", - "x.get()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age: 26\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight: 49.5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n", - "Age: 26 years\n", - "Sex: M\n", - "Height: 4 Feet\n", - "Weight: 49.5 Kg.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.8, Page Number:459" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Example of multiple Inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._a=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self._b=None\n", - " \n", - " \n", - "class C:\n", - " def __init__(self):\n", - " self._c=None\n", - " \n", - "class D:\n", - " def __init__(self):\n", - " self._d=None\n", - " \n", - "class E(A,B,C,D): #inherites all the base classes publically\n", - " def __init__(self):\n", - " self.e=None\n", - " \n", - " def getdata(self):\n", - " print \"Enter the value of a,b,c &d &e:\"\n", - " self._a=input()\n", - " self._b=input()\n", - " self._c=input()\n", - " self._d=input()\n", - " self._e=input()\n", - " \n", - " def show(self):\n", - " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", - " \n", - " \n", - "x=E() #x is the instance of the derived class\n", - "x.getdata() #call the methods of derived class through x \n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a,b,c &d &e:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "16\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a= 1 b= 2 c= 4 d= 8 e= 16\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.9, Page Number:461" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class red: #these three base class\n", - " def __init__(self):\n", - " print \"Red\",\n", - " \n", - "class yellow:\n", - " def __init__(self):\n", - " print \"Yellow\",\n", - " \n", - "class blue:\n", - " def __init__(self):\n", - " print \"Blue\",\n", - " \n", - "class orange(red,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Orange\",\n", - " \n", - "class green(blue,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " blue.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Green\",\n", - " \n", - "class violet(red,blue): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " blue.__init__(self)\n", - " print \"=Violet\",\n", - " \n", - "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Reddishbrown\"\n", - " \n", - "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Yellowishbrown\"\n", - " \n", - "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Bluishbrown\"\n", - " \n", - " \n", - " \n", - "r=reddishbrown() #create instances of the derived class\n", - "b=bluishbrown()\n", - "y=yellowishbrown()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", - "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", - "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.10, Page Number:463" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# WAP to create a derived class from multiple base classes\n", - "\n", - "class PLAYER: #these three are the base classes\n", - " def __init__(self):\n", - " self._name=None\n", - " self._gender=None\n", - " self._age\n", - " \n", - "class PHYSIQUE(PLAYER):\n", - " def __init__(self):\n", - " self._height=None\n", - " self._weight=None\n", - " \n", - "class LOCATION:\n", - " def __init__(self):\n", - " self._city=None\n", - " self._pin=None\n", - " \n", - "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", - " def __init__(self):\n", - " self._game=None\n", - " def getdata(self): #Method to take inputes\n", - " print\"Enter the following information\\n\\n\"\n", - " self._name=raw_input(\"Name:\")\n", - " self._gender=raw_input(\"Gender:\")\n", - " self._age=raw_input(\"Age:\")\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " self._city=raw_input(\"City:\")\n", - " self._pin=raw_input(\"Pin:\")\n", - " self._game=raw_input(\"game:\")\n", - " \n", - " \n", - " \n", - " def show(self): #Method for displaying inputes\n", - " print\"Entered Information!!\"\n", - " print\"Name:\",self._name\n", - " print \"Gender:\",self._gender\n", - " print \"Age:\",self._age\n", - " print \"Height:\",self._height\n", - " print \"Weight:\",self._weight\n", - " print \"City :\",self._city\n", - " print \"Pincode:\",self._pin\n", - " print \"Game :\",self._game\n", - " \n", - " \n", - "G=GAME() #create an instance of the derived class\n", - "G.getdata() #call the public methods by the created instances\n", - "G.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the following information\n", - "\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Mahesh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gender:M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:25\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.9\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:55\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "City:Nanded\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Pin:431603\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "game:Cricket\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Entered Information!!\n", - "Name: Mahesh\n", - "Gender: M\n", - "Age: 25\n", - "Height: 4.9\n", - "Weight: 55\n", - "City : Nanded\n", - "Pincode: 431603\n", - "Game : Cricket\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.11, Page Number:467" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Multipath Inheritance,concept of virtual classes\n", - "\n", - "class A1: #Super base class\n", - " def __init__(self):\n", - " self._a1=None\n", - " \n", - "class A2(A1): #base class 1,inherites Super Base class\n", - " def __init__(self):\n", - " self._a2=None\n", - " \n", - "class A3(A1): #base class 2,inherites Super Base class\n", - " def __init__(self):\n", - " self._a3=None\n", - " \n", - "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", - " def __init__(self):\n", - " self.__a4=None\n", - " \n", - " def get(self):\n", - " print \"Enter the value of a1,a2,a3,and a4:\"\n", - " self._a1=input()\n", - " self._a2=input()\n", - " self._a3=input()\n", - " self.__a4=input()\n", - " \n", - " def put(self):\n", - " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", - " \n", - " \n", - " \n", - "a=A4() #create the instance of the derived class\n", - "a.get()\n", - "a.put()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a1,a2,a3,and a4:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 5 a2= 8 a3= 7 a4= 3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.12, Page Number:469" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To show order of execution of the constructors and destructors in multiple inheritance\n", - "\n", - "#**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class A\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class A\"\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class B\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class B\"\n", - "\n", - "class C(A,B):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print\"Zero argument Constructor of base class C\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class C\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "c=C() #create instance of derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument Constructor of base class A\n", - "Zero argument Constructor of base class B\n", - "Zero argument Constructor of base class C\n", - "Destructor of class C\n", - "Destructor of class A\n", - "Destructor of class B\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.13, Page Number:471" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#WAP to use constructor and destructor in all the classess\n", - "\n", - "class A1:\n", - " def __init__(self): #take name and age as input in super base class\n", - " self._name=raw_input(\"Name:\")\n", - " self._age=raw_input(\"Age:\")\n", - " \n", - " def __del__(self):\n", - " print\"Name:\",self._name\n", - " print\"Age\",self._age\n", - " \n", - " \n", - "class A2(A1): #take height and weight as input in base base class,public derivation \n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " \n", - " def __del__(self):\n", - " print\"Height:\",self._height\n", - " print\"Weight:\",self._weight\n", - " A1.__del__(self)\n", - " \n", - " \n", - "class A3(A2): #take sex as input in derived class,derived from class A2\n", - " def __init__(self):\n", - " A2.__init__(self)\n", - " self.__sex=raw_input(\"Sex:\")\n", - " def __del__(self): #display all the input taken by all the base classes\n", - " print\"Sex:\",self.__sex\n", - " A2.__del__(self)\n", - " \n", - " \n", - "x=A3() #create instance x of the class A3\n", - "\n", - "del x #call the destructor" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:40\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex:M\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n", - "Height: 4.5\n", - "Weight: 40\n", - "Name: Ajay\n", - "Age 20\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.14, Page Number:472" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To create derived class from the base class,by constructor and destructor\n", - "class in_t:\n", - " def __init__(self):\n", - " self._i=1\n", - " print\"Constructor in_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor in_t()\"\n", - " \n", - "class floa_t:\n", - " def __init__(self):\n", - " self._f=1.5\n", - " print\"Constructor floa_t()\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor floa_t()\"\n", - " \n", - " \n", - "class cha_r(in_t,floa_t): #multiple derivation\n", - " def __init__(self):\n", - " self._c='A'\n", - " print\"Constructor cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def show(self):\n", - " print\"i=\",self._i\n", - " print \"f=\",self._f\n", - " print \"c=\",self._c\n", - " \n", - " def __del__(self):\n", - " print \"Destructing cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "a=cha_r() #create derived class instance and call the public method of the derived class\n", - "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor cha_r()\n", - "Constructor in_t()\n", - "Constructor floa_t()\n", - "i= 1\n", - "f= 1.5\n", - "c= A\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.15, Page Number:474" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "class I:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " self.__y=None\n", - " \n", - " def set(self,j,k):\n", - " self.x=j\n", - " self.__y=k\n", - " \n", - " def show(self):\n", - " print \"X=\",self.x, \"Y=\",self.__y\n", - " \n", - " \n", - "i=II()\n", - "i.set(4,5)\n", - "i.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "X= 4 Y= 5\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.16, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class I:\n", - " def __init__(self):\n", - " self.x=10\n", - " print \"In the Base class constuctor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " self.__y=None\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In the Base class constuctor\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.17, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class without constructor and derived class with constructor\n", - "class I:\n", - " pass\n", - "class II(I):\n", - " def __init__(self):\n", - " print \"In derived class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In derived class constructor\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.18, Page Number:476" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#both the class have constructor\n", - "class I:\n", - " def __init__(self):\n", - " print \"In base class Constructor\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"In derived Class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class Constructor\n", - "In derived Class constructor\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.19, Page Number:477" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple constructor in base class and single constructor in the derived class\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument base class construtor\"\n", - " \n", - " def __init__(self,k):\n", - " self.x=None\n", - " print \"One argument base class construtor\"\n", - " \n", - " \n", - "class II(I):\n", - " def __init__(self,j,k=None): #default constructor\n", - " I.__init__(self,k)\n", - " self.__y=j\n", - " print \"One argument derived class constructor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class constructor\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.20, Page Number:478" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base and derived class without default constructor\n", - "class I:\n", - " def __init__(self,k):\n", - " self.x=k\n", - " print \"One argument base class construtor\"\n", - " \n", - "class II(I):\n", - " def __init__(self,j):\n", - " I.__init__(self,j)\n", - " self.__y=j\n", - " print \"One argument derived class construtor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class construtor\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.21, Page Number:479" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors and multiple inheritance\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #class III inhrites class II and I\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #create an instance of the base class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.22, Page Number:480" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors in multiple inhritance with invoking constructor of the base classes\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I):\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.23, Page Number:481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple inheritance,invoking the base classes explicitly\n", - "\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.24, Page Number:482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multilevel Inheritance,observation of the execution of the constructors\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.25, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#use object of one class in another class as a member\n", - "class I:\n", - " def __init__(self):\n", - " self.x=20\n", - " print \"Constructor of class I\"\n", - " \n", - "class II:\n", - " \n", - " def __init__(self):\n", - " self.k=30\n", - " y=I()\n", - " print \"Constructor of class II\"\n", - " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", - " \n", - " \n", - " def show(self):\n", - " print \"k=\",self.k\n", - " \n", - "ii=II()\n", - "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class I\n", - "Constructor of class II\n", - "x= 20\n", - "k= 30\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.26, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access a member variable of base class using object,class name, and direct\n", - "\n", - "class A1:\n", - " def __init__(self):\n", - " self.name=None\n", - " self.age=None\n", - " \n", - "class A2(A1):\n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " a=A1()\n", - " print \"Access using name of the class:\"\n", - " A1.name=raw_input(\"Name:\")\n", - " A1.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using object of the class\"\n", - " a.name=raw_input(\"Name:\")\n", - " a.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using direct member variables:\"\n", - " self.name=raw_input(\"Name:\")\n", - " self.age=raw_input(\"Age:\")\n", - " self.__height=raw_input(\"Height:\")\n", - " self.__weight=raw_input(\"Weight:\")\n", - " \n", - " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", - " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", - " print \"Age:\",a.age\n", - " \n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of Derived class\"\n", - " print \"Display using class name\"\n", - " print \"Name:\",A1.name\n", - " print \"Age:\",A1.age\n", - " \n", - " print \"Display using direct member variable\"\n", - " print \"Name:\",self.name\n", - " print \"Age\",self.age\n", - " print \"height:\",self.__height\n", - " print \"Weight:\",self.__weight\n", - " \n", - "x=A2()\n", - "\n", - "del x\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using name of the class:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:21\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using object of the class\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Amit\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using direct member variables:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Arun\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:19\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:5.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:31\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Display using object of the class\n", - "Name: Amit\n", - "Age: 20\n", - "Destructor of Derived class\n", - "Display using class name\n", - "Name: Ajay\n", - "Age: 21\n", - "Display using direct member variable\n", - "Name: Arun\n", - "Age 19\n", - "height: 5.5\n", - "Weight: 31\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.27, Page Number:488" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.a1=None\n", - " \n", - "class B:\n", - " def __init__(self):\n", - " self.b1=None\n", - " \n", - "class AB:\n", - " def __init__(self):\n", - " a=A()\n", - " b=B()\n", - " a.a1=65 #initialize the two data members of the class A and B and Display them\n", - " b.b1=66\n", - " print \"a1=\",a.a1, \"b1=\",b.b1\n", - " \n", - " def __del__(self):\n", - " pass\n", - " \n", - " \n", - "ab=AB()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 65 b1= 66\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.28, Page Number:489" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create derived class from qualifier class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - " class B:\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - " \n", - "class C(A,A.B): #A.B is the inner class of the class A\n", - " def __init__(self,j,k,l):\n", - " self.x=j\n", - " self.y=k\n", - " self.z=l\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", - " \n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 y= 7 z= 1\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.29, Page Number:490" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialize member variable of the base class and derived class using constructor of the derived class\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " self._x=None #protected members\n", - " self._y=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.z=3\n", - " self.__x=1 #private members\n", - " self.__y=2\n", - " \n", - " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", - " \n", - "b=B()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 1 y= 2 z= 3\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.30, Page Number:491" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access data members by object pointer\n", - "\n", - "from ctypes import *\n", - "import ctypes\n", - "class A:\n", - " def __init__(self):\n", - " self.x=1\n", - " self.y=2\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " self.z=3\n", - " \n", - "b=B()\n", - "\n", - "\n", - "i=c_int(b.z)\n", - "p=pointer(i)\n", - "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", - "\n", - "i = c_int(b.y)\n", - "p = pointer(i)\n", - "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", - "\n", - "i = c_int(b.x)\n", - "p = pointer(i)\n", - "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", - "\n", - "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", - "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", - "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Address of z: 57077392 Value of Z: 3\n", - "Address of y: 57074448 Value of y: 2\n", - "Address of x: 57077648 Value of x: 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.31, Page Number:492" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#overload member function in base and derived class\n", - "\n", - "class B:\n", - " def show(self):\n", - " print \"In base class function\"\n", - " \n", - "class D(B):\n", - " def show(self):\n", - " \n", - " print \"In Derived class\"\n", - " \n", - " \n", - "b=B()\n", - "d=D()\n", - "\n", - "b.show()\n", - "d.show()\n", - "\n", - "bp=[B()] #create a base class pointer variable\n", - "bp[0]=d #assign address of the derived class object to the base class pointer\n", - "bp[0].show() #call the derived class method by base class pointer\n", - "b.show() #calling the base class method by base class object" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class function\n", - "In Derived class\n", - "In Derived class\n", - "In base class function\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.32, Page Number:495" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in single inheritance\n", - "class Father:\n", - " def __init__(self):\n", - " print \"Base Class constructor.\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Base class Destructor.\"\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print \"Derived class constructor.\"\n", - " self.__cname=raw_input(\"Enter child name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Derived class destructor.\"\n", - " print \"\",self.__cname,\"\",self.__name\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - " \n", - " \n", - "C=Child()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Base Class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:Manoj\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter child name:Sanjay\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class destructor.\n", - " Sanjay Manoj\n", - "Base class Destructor.\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.33, Page Number:496" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in multilevel inheritance\n", - "\n", - "class Grandfather:\n", - " def __init__(self):\n", - " print\"Constructor of class grandfather\"\n", - " self._gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class grandfather\"\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " Grandfather.__init__(self)\n", - " print\"Constructor of class Father\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Father\"\n", - " Grandfather.__del__(self)\n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " Father.__init__(self)\n", - " print\"Constructor of class Child\"\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class Child\"\n", - " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", - " Father.__del__(self) \n", - " \n", - " \n", - "C=Child()\n", - "\n", - "del C #call the destructor of the derived class\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class grandfather\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:x\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Father\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:y\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Child\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:z\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Destructor of class Child\n", - "Grandfather: x Father: y Child: z\n", - "Destructor of class Father\n", - "Destructor of class grandfather\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.34, Page Number:498" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#program to explain multilevel inheritance with member function\n", - "class Grandfather:\n", - " def __init__(self):\n", - " self.__gname=None\n", - " \n", - " def getg(self):\n", - " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " def showg(self):\n", - " print \"Grandfather Name:\",self.__gname\n", - " \n", - " \n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " self.__name=None\n", - " \n", - " def getf(self):\n", - " self.__name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def showf(self):\n", - " print \"Father Name:\",self.__name\n", - " \n", - " \n", - "class Child(Father):\n", - " def __init__(self):\n", - " self.__cname=None\n", - " \n", - " def getc(self):\n", - " self.getg()\n", - " self.getf()\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " def showc(self):\n", - " self.showg()\n", - " self.showf()\n", - " print \"child Name:\",self.__cname\n", - " \n", - "C=Child()\n", - "C.getc()\n", - "C.showc()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:XXX\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:YYY\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:ZZZ\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Grandfather Name: XXX\n", - "Father Name: YYY\n", - "child Name: ZZZ\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.35, Page Number:499" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B:\n", - " def __init__(self):\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(A,B,C):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self) \n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "x=D() \n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class A\n", - "Destructor of class B\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " A.__del__(self)\n", - " \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - " \n", - "class D(B,C):\n", - " def __init__(self):\n", - " B.__init__(self)\n", - " C.__init__(self)\n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " B.__del__(self)\n", - " C.__del__(self)\n", - " \n", - "x=D() \n", - "del x\n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class B\n", - "Destructor of class A\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrate single inheritance\n", - "\n", - "class A:\n", - " def __init__(self,j=0):\n", - " self._c=j\n", - " \n", - " def show(self):\n", - " print \"c=\",self._c\n", - " \n", - " def inc(self):\n", - " self._c=self._c+1\n", - " return self._c\n", - " \n", - "class B(A):\n", - " \n", - " def __init_(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def dec(self):\n", - " self._c=self._c-1\n", - " return self._c\n", - " \n", - " \n", - "a=B()\n", - "a.inc()\n", - "a.show()\n", - "\n", - "\n", - "a.dec()\n", - "a.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c= 1\n", - "c= 0\n" - ] - } - ], - "prompt_number": 44 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.38, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access method from private inheritance\n", - "class B:\n", - " def one(self):\n", - " print \"one\"\n", - " \n", - " def __two(self):\n", - " print \"two\"\n", - " \n", - "class D(B):\n", - " def __init__(self):\n", - " pass\n", - " \n", - "d=D()\n", - "d.one()\n", - "#d.two() #Not accesible" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "one\n" - ] - } - ], - "prompt_number": 45 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.39, Page Number:503" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "class C(B):\n", - " def __init__(self,j,k,l):\n", - " self.z=l\n", - " self.x=j\n", - " self.y=k\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", - " \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 Y= 7 z= 1\n" - ] - } - ], - "prompt_number": 46 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.40, Page Number:504" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Explicitly call the base constructor in multiple inheritance\n", - "\n", - "class X:\n", - " def __init__(self,a):\n", - " print a,\n", - " \n", - "class Y:\n", - " def __init__(self,b):\n", - " print b,\n", - " \n", - "class Z(X,Y):\n", - " def __init__(self,p,q,r):\n", - " X.__init__(self,p)\n", - " Y.__init__(self,q)\n", - " print r\n", - " \n", - " \n", - "z=Z(1,2,3)\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "1 2 3\n" - ] - } - ], - "prompt_number": 47 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_2.ipynb b/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_2.ipynb deleted file mode 100755 index d92c896a..00000000 --- a/sample_notebooks/AJEET KUMARSINGH/Chapter_11_Inheritance_2.ipynb +++ /dev/null @@ -1,2661 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:4d2b31f88da13c65a205238b2aa0d40205b037d2cf9c5ea74665d1d4bd106552" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.1, Page Number:444" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Public Derivation of a class\n", - "class A: #Base class\n", - " def __init__(self):\n", - " self.x=None\n", - "\n", - " \n", - "class B(A): #derived class\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - "b=B() #declaration of object\n", - "b.x=20\n", - "b.y=30\n", - "\n", - "print 'member of A:',b.x\n", - "print 'Member of B:',b.y" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "member of A: 20\n", - "Member of B: 30\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.2, Page Number:445" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Base class\n", - "class A: #Base class\n", - " def __init__(self): #class A having x as a private data member\n", - " self.__x=20\n", - " \n", - " def showx(self):\n", - " print \"x=\",self.__x\n", - " \n", - "#derived class \n", - "class B(A): #Derived class\n", - " def __init__(self):\n", - " self.y=30 #class B having y as a public data member\n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx()\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B() #declaration of object\n", - " \n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 30\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.3, Page Number:447" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None #x is a public member\n", - " \n", - " \n", - "#derived class\n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 \n", - " A.__x=20 #since it is privately inherites base class ,x become private member of it\n", - " \n", - " def show(self):\n", - " print \"x=\",A.__x\n", - " print \"y=\",self.y\n", - " \n", - "b=B() #declaration of object\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.4, Page Number:448" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#derivation of a class privately\n", - "class A:\n", - " def __init__(self):\n", - " self.__x=20 \n", - " \n", - " def showx(self): \n", - " print \"x=\",self.__x\n", - " \n", - "#derived class \n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=40 \n", - " \n", - " def show(self):\n", - " a=A()\n", - " a.showx() #call the base class method\n", - " print \"y=\",self.y\n", - " \n", - " \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 20\n", - "y= 40\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.5, Page Number:449" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A:\n", - " def __init__(self):\n", - " self._x=None #x is a protected member of the base class\n", - " \n", - " \n", - "class B(A): #private inheritance,x become a private member of the derived class\n", - " def __init__(self):\n", - " self.y=40\n", - " self.__x=30\n", - " \n", - " \n", - " def show(self): #method to display all the values of all the data memeber\n", - " print \"x=\",self.__x\n", - " print \"y=\",self.y\n", - " \n", - " #declaration of object \n", - "b=B()\n", - "b.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 30\n", - "y= 40\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.6, Page Number:456" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class ABC: #Base class\n", - " def __init__(self):\n", - " self._name=None #these 2 are protected data member\n", - " self._age=None\n", - " \n", - "class abc(ABC): #Derived class ,Public derivation\n", - " def __init__(self):\n", - " self.height=None\n", - " self.weight=None\n", - " \n", - " def getdata(self):\n", - " \n", - " self.name=raw_input(\"Enter a name: \") #take inputes to all the data members \n", - " self.age=raw_input(\"Enter a age: \") \n", - " self._height=raw_input(\"Enter a Height: \") \n", - " self._weight=raw_input(\"Enter a Weight: \") \n", - " \n", - " def show(self): #display the value of data members\n", - " print 'Name:',self.name \n", - " print 'Age:',self.age,\"years\"\n", - " print 'Height:',self._height,\"Feets\"\n", - " print 'Weight:',self._weight,\"kg.\"\n", - " \n", - " \n", - "x=abc()\n", - "x.getdata()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a name: Santosh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a age: 24\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Height: 4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter a Weight: 50\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Santosh\n", - "Age: 24 years\n", - "Height: 4.5 Feets\n", - "Weight: 50 kg.\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.7, Page Number:458" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class A1: #super Base class,have 2 protected data members\n", - " def __init__(self):\n", - " self._name=None\n", - " self._age=None\n", - "\n", - " \n", - "class A2(A1): #Public derivation\n", - " def __init(self):\n", - " self._height=None\n", - " self._weight=None\n", - "\n", - "class A3(A2): #public Derivation\n", - " def __init__(self):\n", - " self._sex=None\n", - " \n", - " \n", - " def get(self): #get input \n", - " self._name=raw_input(\"Name: \")\n", - " self._age=raw_input(\"Age: \")\n", - " self._sex=raw_input(\"Sex: \")\n", - " \n", - " self._height=raw_input(\"Height: \")\n", - " self._weight=raw_input(\"Weight: \")\n", - " \n", - " def show(self): #Display values of all the data members\n", - " print \"Name:\",self._name\n", - " print \"Age:\",self._age ,\"years\"\n", - " print \"Sex:\",self._sex\n", - " print \"Height:\",self._height ,\"Feet\"\n", - " print \"Weight:\",self._weight ,\"Kg.\"\n", - " \n", - "\n", - "x=A3()\n", - "x.get()\n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age: 26\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight: 49.5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Balaji\n", - "Age: 26 years\n", - "Sex: M\n", - "Height: 4 Feet\n", - "Weight: 49.5 Kg.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.8, Page Number:459" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Example of multiple Inheritance\n", - "#Base1 class\n", - "class A:\n", - " def __init__(self):\n", - " self._a=None\n", - "#Base2 class\n", - "class B:\n", - " def __init__(self):\n", - " self._b=None\n", - "#Base3 class\n", - "class C:\n", - " def __init__(self):\n", - " self._c=None\n", - "#Base4 class \n", - "class D:\n", - " def __init__(self):\n", - " self._d=None\n", - "#derived class,multiple derivation\n", - "class E(A,B,C,D): #inherites all the base classes publically\n", - " def __init__(self):\n", - " self.e=None\n", - " \n", - " def getdata(self): #member method to take input for all the data members \n", - " print \"Enter the value of a,b,c &d &e:\"\n", - " self._a=input()\n", - " self._b=input()\n", - " self._c=input()\n", - " self._d=input()\n", - " self._e=input()\n", - " \n", - " def show(self): #member method to display for all the data members \n", - " print\"a=\",self._a,\"b=\",self._b,\"c=\",self._c,\"d=\",self._d,\"e=\",self._e\n", - " \n", - " \n", - "x=E() #x is the instance of the derived class\n", - "x.getdata() #call the methods of derived class through x \n", - "x.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a,b,c &d &e:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "16\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a= 1 b= 2 c= 4 d= 8 e= 16\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.9, Page Number:461" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class red: #these three base class\n", - " def __init__(self):\n", - " print \"Red\",\n", - " \n", - "class yellow:\n", - " def __init__(self):\n", - " print \"Yellow\",\n", - " \n", - "class blue:\n", - " def __init__(self):\n", - " print \"Blue\",\n", - " \n", - "class orange(red,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Orange\",\n", - " \n", - "class green(blue,yellow): #public multiple Derivation\n", - " def __init__(self):\n", - " blue.__init__(self)\n", - " yellow.__init__(self)\n", - " print \"=Green\",\n", - " \n", - "class violet(red,blue): #public multiple Derivation\n", - " def __init__(self):\n", - " red.__init__(self)\n", - " blue.__init__(self)\n", - " print \"=Violet\",\n", - " \n", - "class reddishbrown(orange,violet): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Reddishbrown\"\n", - " \n", - "class yellowishbrown(green,orange): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Yellowishbrown\"\n", - " \n", - "class bluishbrown(violet,green): #public multiple & multilevel Derivation\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " print \"=Bluishbrown\"\n", - " \n", - " \n", - " \n", - "r=reddishbrown() #create instances of the derived class\n", - "b=bluishbrown()\n", - "y=yellowishbrown()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Red Yellow =Orange Red Blue =Violet =Reddishbrown\n", - "Red Blue =Violet Blue Yellow =Green =Bluishbrown\n", - "Blue Yellow =Green Red Yellow =Orange =Yellowishbrown\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.10, Page Number:463" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# WAP to create a derived class from multiple base classes\n", - "\n", - "class PLAYER: #these three are the base classes\n", - " def __init__(self):\n", - " self._name=None\n", - " self._gender=None\n", - " self._age\n", - " \n", - "class PHYSIQUE(PLAYER):\n", - " def __init__(self):\n", - " self._height=None\n", - " self._weight=None\n", - " \n", - "class LOCATION:\n", - " def __init__(self):\n", - " self._city=None\n", - " self._pin=None\n", - " \n", - "class GAME(PHYSIQUE,LOCATION): #Multiple derivation\n", - " def __init__(self):\n", - " self._game=None\n", - " def getdata(self): #Method to take inputes\n", - " print\"Enter the following information\\n\\n\"\n", - " self._name=raw_input(\"Name:\")\n", - " self._gender=raw_input(\"Gender:\")\n", - " self._age=raw_input(\"Age:\")\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " self._city=raw_input(\"City:\")\n", - " self._pin=raw_input(\"Pin:\")\n", - " self._game=raw_input(\"game:\")\n", - " \n", - " \n", - " \n", - " def show(self): #Method for displaying inputes\n", - " print\"Entered Information!!\"\n", - " print\"Name:\",self._name\n", - " print \"Gender:\",self._gender\n", - " print \"Age:\",self._age\n", - " print \"Height:\",self._height\n", - " print \"Weight:\",self._weight\n", - " print \"City :\",self._city\n", - " print \"Pincode:\",self._pin\n", - " print \"Game :\",self._game\n", - " \n", - " \n", - "G=GAME() #create an instance of the derived class\n", - "G.getdata() #call the public methods by the created instances\n", - "G.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the following information\n", - "\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Mahesh\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gender:M\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:25\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.9\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:55\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "City:Nanded\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Pin:431603\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "game:Cricket\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Entered Information!!\n", - "Name: Mahesh\n", - "Gender: M\n", - "Age: 25\n", - "Height: 4.9\n", - "Weight: 55\n", - "City : Nanded\n", - "Pincode: 431603\n", - "Game : Cricket\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.11, Page Number:467" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Multipath Inheritance,concept of virtual classes\n", - "\n", - "class A1: #Super base class\n", - " def __init__(self):\n", - " self._a1=None\n", - " \n", - "class A2(A1): #base class 1,inherites Super Base class\n", - " def __init__(self):\n", - " self._a2=None\n", - " \n", - "class A3(A1): #base class 2,inherites Super Base class\n", - " def __init__(self):\n", - " self._a3=None\n", - " \n", - "class A4(A2,A3): #derived class ,public derivation of both the base classes\n", - " def __init__(self):\n", - " self.__a4=None\n", - " \n", - " def get(self):\n", - " print \"Enter the value of a1,a2,a3,and a4:\"\n", - " self._a1=input()\n", - " self._a2=input()\n", - " self._a3=input()\n", - " self.__a4=input()\n", - " \n", - " def put(self):\n", - " print \"a1=\",self._a1,\"a2=\",self._a2,\"a3=\",self._a3,\"a4=\",self.__a4\n", - " \n", - " \n", - " \n", - "a=A4() #create the instance of the derived class\n", - "a.get()\n", - "a.put()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the value of a1,a2,a3,and a4:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 5 a2= 8 a3= 7 a4= 3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.12, Page Number:469" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To show order of execution of the constructors and destructors in multiple inheritance\n", - "\n", - "#Base1 class\n", - "class A:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class A\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class A\"\n", - "#Base2 class \n", - "class B:\n", - " def __init__(self):\n", - " print\"Zero argument Constructor of base class B\"\n", - " \n", - " def __del__(self):\n", - " print\"Destructor of class B\"\n", - "#derived class,multiple derivation\n", - "class C(A,B):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__: #invocation of the constructor of all the base classes\n", - " b.__init__(self)\n", - " print\"Zero argument Constructor of base class C\"\n", - " \n", - " def __del__(self): \n", - " print\"Destructor of class C\"\n", - " for b in self.__class__.__bases__: #invocation of the destructor of all the base classes\n", - " b.__del__(self)\n", - " \n", - "c=C() #create instance of derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument Constructor of base class A\n", - "Zero argument Constructor of base class B\n", - "Zero argument Constructor of base class C\n", - "Destructor of class C\n", - "Destructor of class A\n", - "Destructor of class B\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.13, Page Number:471" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#WAP to use constructor and destructor in all the classess\n", - "\n", - "class A1:\n", - " def __init__(self): #take name and age as input in super base class\n", - " self._name=raw_input(\"Name:\")\n", - " self._age=raw_input(\"Age:\")\n", - " \n", - " def __del__(self): #show name and age as input in super base class\n", - " print\"Name:\",self._name\n", - " print\"Age\",self._age\n", - " \n", - " \n", - "class A2(A1): #take height and weight as input in base base class,public derivation \n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " self._height=raw_input(\"Height:\")\n", - " self._weight=raw_input(\"Weight:\")\n", - " \n", - " def __del__(self): #show height and weight as input in base base class,public derivation \n", - " print\"Height:\",self._height\n", - " print\"Weight:\",self._weight\n", - " A1.__del__(self)\n", - " \n", - " \n", - "class A3(A2): #take sex as input in derived class,derived from class A2\n", - " def __init__(self):\n", - " A2.__init__(self)\n", - " self.__sex=raw_input(\"Sex:\")\n", - " def __del__(self): #display all the input taken by all the base classes\n", - " print\"Sex:\",self.__sex\n", - " A2.__del__(self)\n", - " \n", - " \n", - "x=A3() #create instance x of the class A3\n", - "\n", - "del x #call the destructor" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:4.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:40\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex:M\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sex: M\n", - "Height: 4.5\n", - "Weight: 40\n", - "Name: Ajay\n", - "Age 20\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.14, Page Number:472" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To create derived class from the base class,by constructor and destructor\n", - "#Base1 class\n", - "class in_t:\n", - " def __init__(self): #constructor of base1 class\n", - " self._i=1\n", - " print\"Constructor in_t()\"\n", - " \n", - " def __del__(self): #destructor of base1 class\n", - " print\"Destructor in_t()\"\n", - "\n", - "#Base2 class\n", - "class floa_t:\n", - " def __init__(self): #constructor of base2 class\n", - " self._f=1.5\n", - " print\"Constructor floa_t()\"\n", - " \n", - " def __del__(self): #destructor of base2 class\n", - " print\"Destructor floa_t()\"\n", - " \n", - "#Derived class \n", - "class cha_r(in_t,floa_t): #multiple derivation\n", - " def __init__(self):\n", - " self._c='A'\n", - " print\"Constructor cha_r()\"\n", - " for b in self.__class__.__bases__: #invocation of the base class constructors\n", - " b.__init__(self)\n", - " \n", - " def show(self): #member method to show all the data member \n", - " print\"i=\",self._i\n", - " print \"f=\",self._f\n", - " print \"c=\",self._c\n", - " \n", - " def __del__(self): #Destructor of the derived cladd\n", - " print \"Destructing cha_r()\"\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "a=cha_r() #create derived class instance and call the public method of the derived class\n", - "a.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor cha_r()\n", - "Constructor in_t()\n", - "Constructor floa_t()\n", - "i= 1\n", - "f= 1.5\n", - "c= A\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.15, Page Number:474" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Base class\n", - "class I:\n", - " def __init__(self):\n", - " self.x=None\n", - "#derived class \n", - "class II(I):\n", - " def __init__(self):\n", - " self.__y=None #private member of the classII\n", - " \n", - " def set(self,j,k): #Parametrized constructor \n", - " self.x=j\n", - " self.__y=k\n", - " \n", - " def show(self):\n", - " print \"X=\",self.x, \"Y=\",self.__y\n", - " \n", - " \n", - "i=II() #creation of instance of the Derived class\n", - "i.set(4,5) #invocation of the derived class member method by instance of the derived class\n", - "i.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "X= 4 Y= 5\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.16, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Base class\n", - "class I:\n", - " def __init__(self):\n", - " self.x=10\n", - " print \"In the Base class constuctor\"\n", - "#Derived class\n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self) #invocation of the base class constructor\n", - " self.__y=None\n", - " \n", - "i=II() #instance of the derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In the Base class constuctor\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.17, Page Number:475" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base class without constructor and derived class with constructor\n", - "class I:\n", - " pass #Empty body of the base class\n", - "class II(I):\n", - " def __init__(self):\n", - " print \"In derived class constructor\"\n", - " \n", - "i=II()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In derived class constructor\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.18, Page Number:476" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#both the class have constructor\n", - "class I:\n", - " def __init__(self):\n", - " print \"In base class Constructor\"\n", - "#Derived class \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)#invocation of the base class constructor\n", - " print \"In derived Class constructor\"\n", - " \n", - "i=II()#instance of the derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class Constructor\n", - "In derived Class constructor\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.19, Page Number:477" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple constructor in base class and single constructor in the derived class\n", - "#Base class\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument base class construtor\"\n", - " \n", - " def __init__(self,k): #parametrized constructor\n", - " self.x=None\n", - " print \"One argument base class construtor\"\n", - " \n", - "#Derived class \n", - "class II(I):\n", - " def __init__(self,j,k=None): #default constructor\n", - " I.__init__(self,k)\n", - " self.__y=j\n", - " print \"One argument derived class constructor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class constructor\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.20, Page Number:478" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#base and derived class without default constructor\n", - "class I:\n", - " def __init__(self,k):\n", - " self.x=k\n", - " print \"One argument base class construtor\"\n", - "#Derived class \n", - "class II(I):\n", - " def __init__(self,j):\n", - " I.__init__(self,j) #invlocation of baser class constructor\n", - " self.__y=j\n", - " print \"One argument derived class construtor\"\n", - " \n", - "i=II(2) #create the instance of the base class by passing initial value " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "One argument base class construtor\n", - "One argument derived class construtor\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.21, Page Number:479" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors and multiple inheritance\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #class III inhrites class II and I\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__: #invocation \n", - " b.__init__(self) \n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #create an instance of the base class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.22, Page Number:480" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constructors in multiple inhritance with invoking constructor of the base classes\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - " \n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I):\n", - " def __init__(self):\n", - " II.__init__(self) #invocation of base class constructors\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #instaace of thr derived class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.23, Page Number:481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multiple inheritance,invoking the base classes explicitly\n", - "#Base1 class\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - "#Base2 class\n", - "class II:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II,I): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " I.__init__(self) #invocation of the base classes\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #instane of the Derived class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.24, Page Number:482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#multilevel Inheritance,observation of the execution of the constructors\n", - "class I:\n", - " def __init__(self):\n", - " print \"Zero argument constructor of base class I\"\n", - "#Derived1 class \n", - "class II(I):\n", - " def __init__(self):\n", - " I.__init__(self)\n", - " print \"Zero argument constructor of base class II\"\n", - " \n", - "class III(II): #Class I is virtually inherited so its constructor called first\n", - " def __init__(self):\n", - " II.__init__(self)\n", - " print \"Zero argument constructor of base class III\"\n", - " \n", - "i=III() #instance of the class III" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Zero argument constructor of base class I\n", - "Zero argument constructor of base class II\n", - "Zero argument constructor of base class III\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.25, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#use object of one class in another class as a member\n", - "class I:\n", - " def __init__(self):\n", - " self.x=20\n", - " print \"Constructor of class I\"\n", - " \n", - "class II(I):\n", - " \n", - " def __init__(self):\n", - " self.k=30\n", - " y=I()\n", - " print \"Constructor of class II\"\n", - " print \"x=\",y.x #print here because it become local variable in this scope only,it not visible to def show\n", - " \n", - " \n", - " def show(self):\n", - " print \"k=\",self.k\n", - " \n", - "ii=II()\n", - "ii.show() #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class I\n", - "Constructor of class II\n", - "x= 20\n", - "k= 30\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.26, Page Number:484" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access a member variable of base class using object,class name, and direct\n", - "#Base class\n", - "class A1:\n", - " def __init__(self): #constructor of the base class\n", - " self.name=None\n", - " self.age=None\n", - "\n", - "#Derived class\n", - "class A2(A1):\n", - " def __init__(self):\n", - " A1.__init__(self)\n", - " a=A1() #create the instances of the base classe,to visible in this block\n", - " print \"Access using name of the class:\"\n", - " A1.name=raw_input(\"Name:\")\n", - " A1.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using object of the class\"\n", - " a.name=raw_input(\"Name:\")\n", - " a.age=raw_input(\"Age:\")\n", - " \n", - " print \"Access using direct member variables:\"\n", - " self.name=raw_input(\"Name:\")\n", - " self.age=raw_input(\"Age:\")\n", - " self.__height=raw_input(\"Height:\")\n", - " self.__weight=raw_input(\"Weight:\")\n", - " \n", - " print \"Display using object of the class\" #since object of class A1 has scope in constructor method so we can access it only \n", - " print \"Name:\",a.name # within this method.It is not visible in destructor function.\n", - " print \"Age:\",a.age\n", - " \n", - " \n", - " \n", - " def __del__(self):\n", - " print \"Destructor of Derived class\"\n", - " print \"Display using class name\"\n", - " print \"Name:\",A1.name\n", - " print \"Age:\",A1.age\n", - " \n", - " print \"Display using direct member variable\"\n", - " print \"Name:\",self.name\n", - " print \"Age\",self.age\n", - " print \"height:\",self.__height\n", - " print \"Weight:\",self.__weight\n", - " \n", - "x=A2()\n", - "\n", - "del x #call the destructor of the derived class\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using name of the class:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Ajay\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:21\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using object of the class\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Amit\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:20\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Access using direct member variables:\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name:Arun\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Age:19\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Height:5.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Weight:31\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Display using object of the class\n", - "Name: Amit\n", - "Age: 20\n", - "Destructor of Derived class\n", - "Display using class name\n", - "Name: Ajay\n", - "Age: 21\n", - "Display using direct member variable\n", - "Name: Arun\n", - "Age 19\n", - "height: 5.5\n", - "Weight: 31\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.27, Page Number:488" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#derive a class from two base classes,object of these 2 classes is the member variable of the third class\n", - "#Base1 class\n", - "class A:\n", - " def __init__(self):\n", - " self.a1=None\n", - "#Base2 class \n", - "class B:\n", - " def __init__(self):\n", - " self.b1=None\n", - "#derived class\n", - "class AB:\n", - " def __init__(self):\n", - " a=A() #create the instances of the base classes,to visible in this block\n", - " b=B()\n", - " a.a1=65 #initialize the two data members of the class A and B and Display them\n", - " b.b1=66\n", - " print \"a1=\",a.a1, \"b1=\",b.b1\n", - " \n", - " def __del__(self):\n", - " pass\n", - " \n", - " \n", - "ab=AB() #ab is the instance of the derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a1= 65 b1= 66\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.28, Page Number:489" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create derived class from qualifier class\n", - "#Base class,container class for the class B\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - " class B: #nested class\n", - " def __init__(self):\n", - " self.y=None\n", - " \n", - " \n", - "class C(A,A.B): #A.B is the inner class of the class A\n", - " def __init__(self,j,k,l):\n", - " self.x=j #set the container base class data member\n", - " self.y=k #set the data member of the nested class\n", - " self.z=l\n", - " \n", - " def show(self): #show method to show all the data members\n", - " print \"x=\",self.x,\"y=\",self.y,\"z=\",self.z\n", - " \n", - " \n", - "c=C(4,7,1) #assign all the data members by invocation of the derived class constructor\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 y= 7 z= 1\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.29, Page Number:490" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialize member variable of the base class and derived class using constructor of the derived class\n", - "#Base class\n", - "class A:\n", - " def __init__(self): #constructor\n", - " self._x=None #protected members\n", - " self._y=None\n", - " \n", - "class B(A):\n", - " def __init__(self): #derived class constructor\n", - " self.z=3 \n", - " self.__x=1 #private members\n", - " self.__y=2\n", - " \n", - " print \"x=\",self.__x,\"y=\",self.__y,\"z=\",self.z\n", - " \n", - "b=B() #instance of the derived class" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 1 y= 2 z= 3\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.30, Page Number:491" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access data members by object pointer\n", - "\n", - "from ctypes import *\n", - "import ctypes\n", - "class A:\n", - " def __init__(self):\n", - " self.x=1\n", - " self.y=2\n", - " \n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " self.z=3\n", - " \n", - "b=B()\n", - "\n", - "\n", - "i=c_int(b.z)\n", - "p=pointer(i)\n", - "print \"Address of z:\",addressof(p),\"Value of Z:\",p[0] #access the\n", - "\n", - "i = c_int(b.y)\n", - "p = pointer(i)\n", - "print \"Address of y:\",addressof(p),\"Value of y:\",p[0] \n", - "\n", - "i = c_int(b.x)\n", - "p = pointer(i)\n", - "print \"Address of x:\",addressof(p),\"Value of x:\",p[0] \n", - "\n", - "#**NOTE-In case of C++ the data members of the derived class and base class are stored in contigious memory locations so we can \n", - "#access the three variables by using a pointer of derived class and decrementing its value. But in case of Python they are NOT stored \n", - "#in contogious memory locations so for accessing each data member we have to create individual object pointer for each class." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Address of z: 57077392 Value of Z: 3\n", - "Address of y: 57074448 Value of y: 2\n", - "Address of x: 57077648 Value of x: 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.31, Page Number:492" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#overload member function in base and derived class\n", - "#Base class\n", - "class B:\n", - " def show(self): #method to be ovveriden\n", - " print \"In base class function\"\n", - " \n", - "class D(B):\n", - " def show(self): #Derived class method,ovveride to the base class\n", - " \n", - " print \"In Derived class\"\n", - " \n", - " \n", - "b=B() #b is the base class instance\n", - "d=D() #d is the derived class instance\n", - "\n", - "b.show()\n", - "d.show()\n", - "\n", - "bp=[B()] #create a base class pointer variable\n", - "bp[0]=d #assign address of the derived class object to the base class pointer\n", - "bp[0].show() #call the derived class method by base class pointer\n", - "b.show() #calling the base class method by base class object" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In base class function\n", - "In Derived class\n", - "In Derived class\n", - "In base class function\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.32, Page Number:495" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in single inheritance\n", - "\n", - "#Base class\n", - "class Father:\n", - " def __init__(self): #Constructor to set the data member name\n", - " print \"Base Class constructor.\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def __del__(self):\n", - " print \"Base class Destructor.\"\n", - "\n", - "#Derived class\n", - "class Child(Father):\n", - " def __init__(self):#Constructor to set the data member cname\n", - " Father.__init__(self) #invocation of base class constructor\n", - " print \"Derived class constructor.\"\n", - " self.__cname=raw_input(\"Enter child name:\")\n", - " \n", - " def __del__(self): #destructor to set the data member cname\n", - " print \"Derived class destructor.\"\n", - " print \"\",self.__cname,\"\",self.__name \n", - " for b in self.__class__.__bases__: #invocation of base class destructor\n", - " b.__del__(self)\n", - " \n", - " \n", - " \n", - "C=Child()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Base Class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:Manoj\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class constructor.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter child name:Sanjay\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Derived class destructor.\n", - " Sanjay Manoj\n", - "Base class Destructor.\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.33, Page Number:496" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Constuctor and destructors in multilevel inheritance\n", - "#Base class\n", - "class Grandfather:\n", - " def __init__(self): #Constructor to set the data member gname\n", - " print\"Constructor of class grandfather\"\n", - " self._gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " \n", - " def __del__(self): #Destructor to show the data member gname\n", - " print \"Destructor of class grandfather\"\n", - " \n", - " \n", - "#Derived1 class\n", - "class Father(Grandfather):\n", - " def __init__(self): #Constructor to set the data member name\n", - " Grandfather.__init__(self) #invocation of base class constructor\n", - " print\"Constructor of class Father\"\n", - " self._name=raw_input(\"Enter Father Name:\")\n", - " \n", - " \n", - " def __del__(self): #Destructor to show the data member name\n", - " print \"Destructor of class Father\"\n", - " Grandfather.__del__(self) #invocation of base class destructor\n", - " \n", - "#Derived2 class\n", - "class Child(Father):\n", - " def __init__(self): #Constructor to set the data member cname\n", - " Father.__init__(self) #invocation of base class constructor\n", - " print\"Constructor of class Child\"\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " \n", - " def __del__(self): #Destructor to show the data member name\n", - " print \"Destructor of class Child\"\n", - " print \"Grandfather:\",self._gname,\"Father:\",self._name,\"Child:\",self.__cname\n", - " Father.__del__(self) #invocation of base class destructor\n", - " \n", - "#instance of the Derived2 class \n", - "C=Child()\n", - "\n", - "del C #call the destructor of the derived class\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class grandfather\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:x\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Father\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:y\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Child\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:z\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Destructor of class Child\n", - "Grandfather: x Father: y Child: z\n", - "Destructor of class Father\n", - "Destructor of class grandfather\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.34, Page Number:498" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#program to explain multilevel inheritance with member function\n", - "\n", - "#Base class\n", - "class Grandfather:\n", - " def __init__(self):\n", - " self.__gname=None\n", - " \n", - " def getg(self): #method to set the data member gname\n", - " self.__gname=raw_input(\"Enter Grandfather Name:\")\n", - " \n", - " def showg(self):#method to show the data member gname\n", - " print \"Grandfather Name:\",self.__gname\n", - " \n", - " \n", - "#Derived1 class\n", - "class Father(Grandfather):\n", - " def __init__(self):\n", - " self.__name=None\n", - " \n", - " def getf(self): #method to set the data member name\n", - " self.__name=raw_input(\"Enter Father Name:\")\n", - " \n", - " def showf(self): #method to show the data member name\n", - " print \"Father Name:\",self.__name\n", - " \n", - "#Derived2 class \n", - "class Child(Father):\n", - " def __init__(self):\n", - " self.__cname=None\n", - " \n", - " def getc(self): #method for invocation of base class methods and set the data member cname\n", - " self.getg()\n", - " self.getf()\n", - " self.__cname=raw_input(\"Enter Child Name:\")\n", - " \n", - " def showc(self): #method for invocation of base class methods and set the data member cname\n", - " self.showg()\n", - " self.showf()\n", - " print \"child Name:\",self.__cname\n", - " \n", - "C=Child() #cretaion of a instance of Derived2 class\n", - "C.getc() #invocation of the method of Derived2 class for setting all the data member value\n", - "C.showc()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Grandfather Name:XXX\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Father Name:YYY\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Child Name:ZZZ\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Grandfather Name: XXX\n", - "Father Name: YYY\n", - "child Name: ZZZ\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.35, Page Number:499" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "#Base1 class\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - "#Base2 class \n", - "class B:\n", - " def __init__(self):\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - "#Base3 class \n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - "#Derived class,Multiple Derivation \n", - "class D(A,B,C):\n", - " def __init__(self):\n", - " for b in self.__class__.__bases__: #invoke all the base class constructors\n", - " b.__init__(self) \n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\" #invoke all the base class destructors\n", - " for b in self.__class__.__bases__:\n", - " b.__del__(self)\n", - " \n", - "x=D() \n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class A\n", - "Destructor of class B\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#execution of constructor and destructor in multilevel inheritance\n", - "\n", - "#Base class\n", - "class A:\n", - " def __init__(self):\n", - " print \"Constructor of class A\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class A\"\n", - " \n", - "#Derived1 class\n", - "class B(A):\n", - " def __init__(self):\n", - " A.__init__(self)\n", - " print \"Constructor of class B\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class B\"\n", - " A.__del__(self)\n", - "\n", - "#Derived2 class\n", - "class C:\n", - " def __init__(self):\n", - " print \"Constructor of class C\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class C\"\n", - " \n", - "#Derived3 class,multiple derivation\n", - "class D(B,C):\n", - " def __init__(self):\n", - " B.__init__(self)\n", - " C.__init__(self)\n", - " print \"Constructor of class D\"\n", - " \n", - " def __del__(self):\n", - " print \"Destructor of class D\"\n", - " B.__del__(self)\n", - " C.__del__(self)\n", - " \n", - "x=D() #creation of Derived3 class instance\n", - "del x\n", - " #**NOTE:Python destuctor is called when program goes exit. So output may be differ than c++" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class A\n", - "Constructor of class B\n", - "Constructor of class C\n", - "Constructor of class D\n", - "Destructor of class D\n", - "Destructor of class B\n", - "Destructor of class A\n", - "Destructor of class C\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.37, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrate single inheritance\n", - "\n", - "#Base class\n", - "class A:\n", - " def __init__(self,j=0):\n", - " self._c=j #protected Member\n", - " \n", - " def show(self): #Public member \n", - " print \"c=\",self._c\n", - " \n", - " def inc(self): #public increment method of base class\n", - " self._c=self._c+1\n", - " return self._c\n", - " \n", - "class B(A):\n", - " \n", - " def __init_(self):\n", - " for b in self.__class__.__bases__:\n", - " b.__init__(self)\n", - " \n", - " def dec(self): #public increment method of derived class\n", - " self._c=self._c-1\n", - " return self._c\n", - " \n", - " \n", - "a=B() #create a instance of a derived class\n", - "\n", - "a.inc() #call the base class public member function by derived class instance for increment\n", - "a.show()\n", - "\n", - "\n", - "a.dec() #call the derived class public member function by derived class instance for decrement\n", - "a.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c= 1\n", - "c= 0\n" - ] - } - ], - "prompt_number": 44 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.38, Page Number:502" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#access method from private inheritance\n", - "\n", - "#base class\n", - "class B:\n", - " def one(self): #Public Member\n", - " print \"one\"\n", - " \n", - " def __two(self): #Private Member\n", - " print \"two\"\n", - " \n", - "class D(B):\n", - " def __init__(self):\n", - " pass\n", - " \n", - "d=D()\n", - "d.one()\n", - "#d.two() #Not accesible" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "one\n" - ] - } - ], - "prompt_number": 45 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.39, Page Number:503" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#create a comman constructor in the lowermost class, in the multilevel inheritance\n", - "\n", - "#Base class\n", - "class A:\n", - " def __init__(self):\n", - " self.x=None\n", - " \n", - "#Derived1 class\n", - "class B(A):\n", - " def __init__(self):\n", - " self.y=None\n", - "\n", - "#Derived2 class\n", - "class C(B):\n", - " def __init__(self,j,k,l):\n", - " self.z=l #Initializing the base class data members by calling base class constructor\n", - " self.x=j\n", - " self.y=k\n", - " \n", - " def show(self):\n", - " print \"x=\",self.x,\"Y=\",self.y,\"z=\",self.z\n", - "\n", - "#Creation of instance of derived2 class,with constructor invocation \n", - "c=C(4,7,1)\n", - "c.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x= 4 Y= 7 z= 1\n" - ] - } - ], - "prompt_number": 46 - }, - { - "cell_type": "heading", - "level": 3, - "metadata": {}, - "source": [ - "Example 11.40, Page Number:504" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Explicitly call the base constructor in multiple inheritance\n", - "\n", - "#Base class\n", - "class X:\n", - " def __init__(self,a):\n", - " print a,\n", - "#Base class \n", - "class Y:\n", - " def __init__(self,b):\n", - " print b,\n", - "#multiple Derivation \n", - "class Z(X,Y):\n", - " def __init__(self,p,q,r):\n", - " X.__init__(self,p)\n", - " Y.__init__(self,q)\n", - " print r\n", - " \n", - "#Creation of instance of derived class,with constructor invocation \n", - "z=Z(1,2,3)\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "1 2 3\n" - ] - } - ], - "prompt_number": 47 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ARIJITCHATTERJEE/ARIJITCHATTERJEE_version_backup/chapter1.ipynb b/sample_notebooks/ARIJITCHATTERJEE/ARIJITCHATTERJEE_version_backup/chapter1.ipynb new file mode 100755 index 00000000..d287e069 --- /dev/null +++ b/sample_notebooks/ARIJITCHATTERJEE/ARIJITCHATTERJEE_version_backup/chapter1.ipynb @@ -0,0 +1,904 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Operational Amplifier Fundamentals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1, Page 4" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)\n", + "The overall gain is 60.0 V/V\n", + "The input load is 80.0 % of it's unloaded value\n", + "The output load is 75.0 % of it's unloaded value\n", + "b)\n", + "The overall gain is 53.3 V/V\n", + "The input load is 66.7 % of it's unloaded value\n", + "The output load is 80.0 % of it's unloaded value\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "R0 = 1.0 #ohm\n", + "Ri = 100.0 #kilo ohm\n", + "Aoc = 100.0 #volts per volts\n", + "Rs=0.0 #kilo ohm\n", + "Rl=0.0 #ohm\n", + "gain=0.0\n", + "input_load=0.0\n", + "output_load=0.0\n", + "\n", + "def calculate(): #returns gain\n", + " global input_load, output_load\n", + " input_load = (Ri/(Rs+Ri))\n", + " output_load = (Rl/(R0+Rl))\n", + " ans=input_load*Aoc*output_load # in V/V\n", + " return ans\n", + "#answer part (a)\n", + "Rs=25.0\n", + "Rl=3.0\n", + "gain=calculate()\n", + "print \"a)\"\n", + "print \"The overall gain is \",round(gain,1),\"V/V\"\n", + "print \"The input load is \",input_load*100,\"% of it's unloaded value\"\n", + "print \"The output load is \",output_load*100,\"% of it's unloaded value\"\n", + "\n", + "#answer part (b)\n", + "Rs=50.0\n", + "Rl=4.0\n", + "gain=calculate()\n", + "print \"b)\"\n", + "print \"The overall gain is \",round(gain,1),\"V/V\"\n", + "print \"The input load is \",round(input_load*100,1),\"% of it's unloaded value\"\n", + "print \"The output load is \",round(output_load*100,1),\"% of it's unloaded value\"\n", + " \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2, Page 9" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)Vo = 9.17431 V\n", + "b)Vo = 9.99101 V\n", + "c)Vo = 9.99991 V\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "\n", + "vt = 1.0 # in volt\n", + "R1 = 2.0 # in kilo ohm\n", + "R2 = 18.0 #in kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "def calculate(a): #returns Vo\n", + " global vt,R1,R2\n", + " ans=vt*(1+(R2/R1))/(1+((R2/R1)/a)) #equation 1.11\n", + " return ans\n", + "\n", + "#answer\n", + "print \"a)Vo = \",round(calculate(10**2),5),\"V\"\n", + "print \"b)Vo = \",round(calculate(10**4),5),\"V\"\n", + "print \"c)Vo = \",round(calculate(10**6),5),\"V\"\n", + "\n", + "#textbook contains precision error" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.4, Page 18" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1 = 20 kilo ohm\n", + "R2 = 15 kilo ohm\n", + "R3 = 30 kilo ohm\n", + "Rf = 120 kilo ohm\n" + ] + } + ], + "source": [ + "#Variable declaration\n", + "\n", + "rf1 = 3 # coefficient of V1\n", + "rf2 = 4 # coefficient of V2\n", + "rf3 = 2 # coefficient of V3\n", + "\n", + "#Calculations\n", + "\n", + "rf1*=2 # Common factor 2\n", + "rf2*=2 # Common factor 2\n", + "rf3*=2 # Common factor 2\n", + "r1=20 # assumption\n", + "rf=r1*rf1\n", + "r2=rf/rf2\n", + "r3=rf/rf3\n", + "\n", + "#answer\n", + "\n", + "print \"R1 = \",r1,\"kilo ohm\"\n", + "print \"R2 = \",r2,\"kilo ohm\"\n", + "print \"R3 = \",r3,\"kilo ohm\"\n", + "print \"Rf = \",rf,\"kilo ohm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.5, Page 18" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1 = 10 kilo ohm\n", + "R2 = 300 kilo ohm\n", + "Rf = 100 kilo ohm\n" + ] + } + ], + "source": [ + "#Variable declaration\n", + "\n", + "r1,r2,rf #vo=10*v1+5=-(rf/r1*v1)-rf/r2*(-15)\n", + "\n", + "#Calculation\n", + "\n", + "r1=10\n", + "rf=10*r1; #-rf/r1*v1=10*v1\n", + "r2=rf*15/5 #-rf/r2*(-15)=5\n", + "\n", + "#answer\n", + "\n", + "print \"R1 = \",r1,\"kilo ohm\"\n", + "print \"R2 = \",r2,\"kilo ohm\"\n", + "print \"Rf = \",rf,\"kilo ohm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.6, Page 20" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1 = 100 kilo ohm\n", + "R2 = 300 kilo ohm\n", + "R3 = 25 kilo ohm\n", + "R4 = 75 kilo ohm\n" + ] + } + ], + "source": [ + "#Variable declaration\n", + "\n", + "ri1=100 # in kilo ohm\n", + "ri2=100 # in kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "r1=ri1;\n", + "r2=3*r1; #r2/r1=3\n", + "# r3 + r4 = ri2 and (1+r1/r2)/(1+r3/r4)=1\n", + "#Solving the above two\n", + "r3=ri2/4;\n", + "r4=ri2-r3\n", + "\n", + "#answer\n", + "\n", + "print \"R1 = \",r1,\"kilo ohm\"\n", + "print \"R2 = \",r2,\"kilo ohm\"\n", + "print \"R3 = \",r3,\"kilo ohm\"\n", + "print \"R4 = \",r4,\"kilo ohm\"\n", + "\n", + "#in textbook r3 and r4 values are reversed which doesn't satisfy the equations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.7, Page 25" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)T >= 1000\n", + "b)a >= 100000\n", + "a)Beta = 0.00999\n" + ] + } + ], + "source": [ + "#Variable Declaration\n", + "\n", + "A=100 \n", + "accuracy=0.1\n", + "\n", + "#Calcualtion\n", + "\n", + "T=100/accuracy\n", + "beta=1.0/100.0 # A_ideal=i/beta=100\n", + "a=(10**3)/beta\n", + "beta=(a/100-1)/a # A=a/(1+(a*beta))\n", + "\n", + "#answer\n", + "print \"a)T >= \",int(T)\n", + "print \"b)a >= \",int(a)\n", + "print \"a)Beta = \",beta" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.8, Page 26" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a) A changes by (+-) 0.09901 %\n", + "b) A changes by (+-) 0.0001 %\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "a = 10**5 \n", + "beta\n", + "T\n", + "\n", + "#Calculation\n", + "\n", + "def calculate():\n", + " global a,beta,T\n", + " T=a*beta\n", + " ans=10.0/(1+T) # for a +- 10% change in a\n", + " return ans\n", + "\n", + "#answer\n", + "beta=10**(-3) #given\n", + "desensitivity_factor=calculate(); # stores the answer\n", + "print \"a) A changes by (+-)\",round(desensitivity_factor,6),\"%\" #part a\n", + "\n", + "beta=1 #given\n", + "desensitivity_factor=calculate();\n", + "print \"b) A changes by (+-)\",round(desensitivity_factor,6),\"%\" #part b" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.9, Page 33" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)\n", + " A = 995.024876 V/V\n", + " Ro = 373.134 mili ohm\n", + " Ri = 402.0 Mega ohm\n", + "b)\n", + " A = 0.999995 V/V\n", + " Ro = 0.375 mili ohm\n", + " Ri = 400002.0 Mega ohm\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "rd = 2.0 # Mega ohm\n", + "ro = 75.0 # ohm\n", + "a = 200000.0 # V/V\n", + "\n", + "#Calculation\n", + "\n", + "def calculate(R1,R2):\n", + " global a,ro,rd\n", + " beta=R1/(R1+R2)\n", + " if(R1==float(\"inf\")): # for infinty\n", + " beta=1\n", + " T=a*beta\n", + " A=(1+(R2/R1))/(1+(1/T)) # equation 1.55\n", + " if(R1==float(\"inf\")): # for infinity\n", + " A=1/(1+(1/T))\n", + " Ro=ro/(1+T) # equation 1.61\n", + " Ri=rd*(1+T) # equation 1.59\n", + " print \" A = \",round(A,6),\"V/V\"\n", + " print \" Ro = \",round(Ro*(10**3),3),\"mili ohm\"\n", + " print \" Ri = \", round(Ri,3),\"Mega ohm\"\n", + "\n", + "#answer\n", + "\n", + "print \"a)\"\n", + "calculate(1.0,999)\n", + "print \"b)\"\n", + "calculate(float(\"inf\"),1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.10, Page 35" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)\n", + " A = -0.99999 V/V\n", + " Rn = 0.5 ohm\n", + " Ri = 100000.0 ohm\n", + " Ro = 0.00075 ohm\n", + "b)\n", + " A = -995.01993 V/V\n", + " Rn = 4.99998 ohm\n", + " Ri = 1000.0 ohm\n", + " Ro = 0.37351 ohm\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "a = 200000.0 # V/V\n", + "ro = 75 # ohm\n", + "\n", + "#Calculating function\n", + "\n", + "def calculate(R1,R2):\n", + " global a,ro\n", + " T=a*(R1/(R1+R2)) \n", + " A=(-1)*(R2/R1)/(1+(1/T)) # equation 1.63\n", + " Rn=R2/(1+a) # equation 1.67b\n", + " Ri=R1 # equation 1.68\n", + " Ro=ro/(1+T)\n", + " print \" A = \",round(A,5),\"V/V\"\n", + " print \" Rn = \",round(Rn,5),\"ohm\"\n", + " print \" Ri = \",round(Ri,5),\"ohm\"\n", + " print \" Ro = \",round(Ro,5),\"ohm\"\n", + " \n", + "#answer\n", + "\n", + "print \"a)\"\n", + "calculate(100000.0,100000.0)\n", + "print \"b)\"\n", + "calculate(1000.0,1000000.0)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.11, Page 38" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "317.440162529\n", + "a) A_ideal = -101.1 V/V\n", + "b) A = -100.78 V/V\n", + "Deviation from ideal = 0.31 %\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "R1 = 1000000.0 # ohm\n", + "R2 = 1000000.0 # ohm\n", + "R3 = 100000.0 # ohm\n", + "R4 = 1000.0 # ohm\n", + "RL = 2000.0 # ohm\n", + "rd = 1000000.0 #ohm\n", + "a = 10**5 # V/V\n", + "ro = 100.0 # ohm\n", + "\n", + "#Calculation\n", + "\n", + "A_ideal = (-1)*(R2/R1)*(1+(R3/R2)+(R3/R4)) # ideal op-amp and summing currents at node v1\n", + "T = a/(1+(R2/R1)+(R2/rd))/(1+(ro/(R2+(R1*rd/(R1+rd))))+(ro/RL))/100 #equation 1.73\n", + "A = A_ideal/(1+(1/T)) \n", + "dev=(A_ideal-A)/A_ideal*100\n", + "\n", + "#answer\n", + "print T\n", + "print \"a) A_ideal =\",A_ideal,\"V/V\"\n", + "print \"b) A =\",round(A,2),\"V/V\"\n", + "print \"Deviation from ideal =\",round(dev,2),\"%\"\n", + "\n", + "#book example has precision error so answer is 0.32%" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.12, Page 40" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)\n", + " Beta = 0.016911 V/V\n", + " T = 169.1\n", + "b)\n", + " Vo= -( 29.82 V1 + 14.91 V2 + 9.94 V3 )\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "rd = 1000.0 # kilo ohm\n", + "a = 10**4 # V/V\n", + "ro = 100.0 #ohm\n", + "R1 = 10.0 # kilo ohm\n", + "R2 = 20.0 # kilo ohm\n", + "R3 = 30.0 # kilo ohm\n", + "R4 = 300.0 # kilo ohm\n", + "RL = 2.0 # kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "def parallel(a,b):\n", + " ans=a*b/(a+b)\n", + " return ans\n", + "\n", + "Ra = parallel(R1,parallel(R2,parallel(R3,rd)))\n", + "Rb=Ra+R4\n", + "Rc=parallel(Rb,RL) #After suppressing all input sources\n", + "Rd=Rc+ro/1000 #replacing the op-amp with it's terminal resistances\n", + "Vn=Rb/Ra #and applying a test voltage and analysing the circuit\n", + "Vt=Rd/Rc\n", + "beta=1/Vn/Vt\n", + "T=a*beta\n", + "v1=R4/R1\n", + "v2=R4/R2\n", + "v3=R4/R3\n", + "A=1/(1+1/T)\n", + "\n", + "#answer\n", + "\n", + "print \"a)\"\n", + "print \" Beta =\",round(beta,6),\"V/V\"\n", + "print \" T =\",round(T,1)\n", + "print \"b)\"\n", + "print \" Vo= -(\",round(A*v1,2),\"V1 +\",round(A*v2,2),\"V2 +\",round(A*v3,2),\"V3 )\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.13, Page 41" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Beta = 0.8101 V/V\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "rd = 100.0 # kilo ohm\n", + "ro = 100.0 # ohm\n", + "R1 = 30.0 # kilo ohm\n", + "R2 = 20.0 # kilo ohm\n", + "R3 = 10.0 # kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "def parallel(a,b):\n", + " ans=a*b/(a+b)\n", + " return ans\n", + "\n", + "beta_n = (parallel(R1,rd)+R1)/((ro/1000)+R2+parallel(R1,rd)+R3) # from circuit 1.35 after appyling\n", + "beta_p = R3/((ro/1000)+R2+parallel(R1,rd)+R3) # voltage divide formula twice\n", + "beta=beta_n-beta_p #equation 1.76\n", + "\n", + "#answer\n", + "\n", + "print \"Beta =\",round(beta,4),\"V/V\"\n", + "\n", + "# beta_n calculation in book is wrong" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.14, Page 43" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a)\n", + " Icc = 0.5 mA\n", + " Iee = 3.5 mA\n", + " I0 = 3 mA\n", + "b)\n", + " Power Poa = 42.0 mW\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable Declaration \n", + "\n", + "R1 = 10 #kilo ohm\n", + "R2 = 20 #kilo ohm\n", + "V1 = 3 # V\n", + "Iq = 0.5 # mA\n", + "RL = 2 #kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "V0 = (-1)*R2/R1*V1\n", + "It = abs(V0)/RL # Currents through R1,R2,Rt are i1,i2,It respectively\n", + "i1 = It/R1\n", + "i2 = i1 # applying voltage divider rule\n", + "i0 = i2+It\n", + "icc = Iq\n", + "iee = icc+ i0\n", + "Poa = 30*Iq+((V0+15)*i0) #Whenever current passes through voltage drop, power = vi\n", + "\n", + "#answer\n", + "\n", + "print \"a)\"\n", + "print \" Icc =\",icc,\"mA\"\n", + "print \" Iee =\",iee,\"mA\"\n", + "print \" I0 =\",i0,\"mA\"\n", + "print \"b)\"\n", + "print \" Power Poa =\",Poa,\"mW\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.15, Page 43" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "b)\n", + " Change in v = 3.75 micro Volt -> quite a small change\n" + ] + } + ], + "source": [ + "#Variable Declaration\n", + "\n", + "ro = 75.0 #kilo ohm\n", + "T = 200000.0\n", + "Vs = 10.0 # V\n", + "Rl = 1.0 #kilo ohm\n", + "\n", + "#Calculation\n", + "\n", + "iL = Vs/Rl\n", + "Ro = ro/(1+T)\n", + "del_v = Ro*10*(10**(-3))\n", + "\n", + "#answer\n", + "\n", + "print \"b)\"\n", + "print \" Change in v =\",round(del_v*(10**6),2),\"micro Volt -> quite a small change\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.16, Page 46" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The op-amp saturates at Vo=+-13 V\n", + "With Vn= 20/3-13/3 = 2.3333 V\n" + ] + }, + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEhCAYAAABhpec9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm8lGX9//HXR0BxXzIQFQNNcE1JJDWXoySSAkqZWpqK\ntmmK+XVfvl8oK+3n8q0s9w0qcdfOkcVIPYIKmqwae19MDUNSREVBls/vj+uewzDOmTPnMHPf98y8\nn4/HeTDLfeb+zHWGue5r+1zm7oiIiDRno6QDEBGRdFNFISIiBamiEBGRglRRiIhIQaooRESkI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mRm\nmxMydz4c5VuDsMFOXu7+HPCcmW0JXA7MMbOT3P3xErwPkZJRRSFSvJVZt9dm3V9L+L+0EbA0ao00\nMbN2hMzDAH929+HR45sSWihDgK2BocBfyxW8SFupohBZ34fAlq38HYOQ49/MFprZie7+SJTGeV93\nn0nYuW7dL5j9P0K305PAxe4+owSxi5SFKgqRLO7+rpm9YGavEvavzsz28Kzb5LmduX8qcKuZXU1I\nqz4KmJnnVM8CV7v7p6WMX6QcNOtJREQK0qwnEREpSBWFiIgUpIpCREQKUkUhIiIFqaIQEZGCVFGI\niEhBqihERKQgVRQiIlLQ/wfqhyu+stXumgAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "import matplotlib.pyplot as plt\n", + "import scipy as np\n", + "import math\n", + "\n", + "#Variable Declaration\n", + "\n", + "A = -2 #V/V\n", + "peak = 10 # V\n", + "\n", + "#Calculation \n", + "\n", + "output = np.absolute(A) * peak\n", + "\n", + "#answer\n", + "\n", + "print \"The op-amp saturates at Vo=+-13 V\"\n", + "print \"With Vn= 20/3-13/3 =\",round((20.0/3)-(13.0/3),4),\"V\"\n", + "\n", + "#Graphs\n", + "\n", + "t1 = np.arange(0,1,.0005) # Triangular waveform\n", + "t2 = np.arange(1,3,.0005)\n", + "t3 = np.arange(3,5,.0005)\n", + "\n", + "m1 = np.arange(0,0.65,.0005)\n", + "m2 = np.arange(.65,1.35,.0005)\n", + "m3 = np.arange(1.35,2.65,.0005) # Output Vo wave\n", + "m4 = np.arange(2.65,3.35,.0005)\n", + "m5 = np.arange(3.35,4.65,.0005)\n", + "m6 = np.arange(4.65,5,.0005) # Output Vn wave\n", + "m7 = np.arange(0.65,1,.0005)\n", + "m8 = np.arange(1,1.35,.0005)\n", + "m9 = np.arange(2.65,3,.0005)\n", + "m10 = np.arange(3, 3.35, .0005)\n", + "\n", + "plt.subplot(2,1,1)\n", + "\n", + "plt.suptitle(\"Vt (Blue), Vo (Red) and Vn (Green) Graphs\")\n", + "plt.xlim(0,4.5)\n", + "plt.xlabel(\"time->\")\n", + "plt.ylabel(\"V->\")\n", + "plt.plot(t1,peak*t1,\"b\",)\n", + "plt.plot(t2,(-1)*peak*t2+2*(peak),\"b\",)\n", + "plt.plot(t3,peak*t3-4*(peak),\"b\",)\n", + "\n", + "plt.subplot(2,1,2)\n", + "\n", + "plt.xlim(0,4.5)\n", + "plt.xlabel(\"time->\")\n", + "plt.ylabel(\"V->\")\n", + "plt.plot(m1,-20*m1,\"r\")\n", + "plt.plot(m2,np.full(len(m2),-13),\"r\")\n", + "plt.plot(m3,20*m3-40,\"r\")\n", + "plt.plot(m4,np.full(len(m4),13),\"r\")\n", + "plt.plot(m5,-20*m5+80,\"r\")\n", + "plt.plot(m6,np.full(len(m6),-13),\"r\")\n", + "\n", + "plt.plot(m1,np.full(len(m1),0),\"g\",)\n", + "plt.plot(m7,6.665*m7-4.4,\"g\")\n", + "plt.plot(m8,-6.665*m8+8.8,\"g\")\n", + "plt.plot(m3,np.full(len(m3),0),\"g\")\n", + "plt.plot(m9,6.665*m9-17.6,\"g\")\n", + "plt.plot(m10,-6.665*m10+22.4,\"g\")\n", + "plt.plot(m5,np.full(len(m5),0),\"g\")\n", + "plt.plot(m6,np.full(len(m6),0),\"g\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ARIJITCHATTERJEE/chapter1.ipynb b/sample_notebooks/ARIJITCHATTERJEE/chapter1.ipynb deleted file mode 100755 index d287e069..00000000 --- a/sample_notebooks/ARIJITCHATTERJEE/chapter1.ipynb +++ /dev/null @@ -1,904 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Operational Amplifier Fundamentals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1, Page 4" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "%matplotlib inline" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)\n", - "The overall gain is 60.0 V/V\n", - "The input load is 80.0 % of it's unloaded value\n", - "The output load is 75.0 % of it's unloaded value\n", - "b)\n", - "The overall gain is 53.3 V/V\n", - "The input load is 66.7 % of it's unloaded value\n", - "The output load is 80.0 % of it's unloaded value\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "R0 = 1.0 #ohm\n", - "Ri = 100.0 #kilo ohm\n", - "Aoc = 100.0 #volts per volts\n", - "Rs=0.0 #kilo ohm\n", - "Rl=0.0 #ohm\n", - "gain=0.0\n", - "input_load=0.0\n", - "output_load=0.0\n", - "\n", - "def calculate(): #returns gain\n", - " global input_load, output_load\n", - " input_load = (Ri/(Rs+Ri))\n", - " output_load = (Rl/(R0+Rl))\n", - " ans=input_load*Aoc*output_load # in V/V\n", - " return ans\n", - "#answer part (a)\n", - "Rs=25.0\n", - "Rl=3.0\n", - "gain=calculate()\n", - "print \"a)\"\n", - "print \"The overall gain is \",round(gain,1),\"V/V\"\n", - "print \"The input load is \",input_load*100,\"% of it's unloaded value\"\n", - "print \"The output load is \",output_load*100,\"% of it's unloaded value\"\n", - "\n", - "#answer part (b)\n", - "Rs=50.0\n", - "Rl=4.0\n", - "gain=calculate()\n", - "print \"b)\"\n", - "print \"The overall gain is \",round(gain,1),\"V/V\"\n", - "print \"The input load is \",round(input_load*100,1),\"% of it's unloaded value\"\n", - "print \"The output load is \",round(output_load*100,1),\"% of it's unloaded value\"\n", - " \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2, Page 9" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)Vo = 9.17431 V\n", - "b)Vo = 9.99101 V\n", - "c)Vo = 9.99991 V\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "\n", - "vt = 1.0 # in volt\n", - "R1 = 2.0 # in kilo ohm\n", - "R2 = 18.0 #in kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "def calculate(a): #returns Vo\n", - " global vt,R1,R2\n", - " ans=vt*(1+(R2/R1))/(1+((R2/R1)/a)) #equation 1.11\n", - " return ans\n", - "\n", - "#answer\n", - "print \"a)Vo = \",round(calculate(10**2),5),\"V\"\n", - "print \"b)Vo = \",round(calculate(10**4),5),\"V\"\n", - "print \"c)Vo = \",round(calculate(10**6),5),\"V\"\n", - "\n", - "#textbook contains precision error" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.4, Page 18" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1 = 20 kilo ohm\n", - "R2 = 15 kilo ohm\n", - "R3 = 30 kilo ohm\n", - "Rf = 120 kilo ohm\n" - ] - } - ], - "source": [ - "#Variable declaration\n", - "\n", - "rf1 = 3 # coefficient of V1\n", - "rf2 = 4 # coefficient of V2\n", - "rf3 = 2 # coefficient of V3\n", - "\n", - "#Calculations\n", - "\n", - "rf1*=2 # Common factor 2\n", - "rf2*=2 # Common factor 2\n", - "rf3*=2 # Common factor 2\n", - "r1=20 # assumption\n", - "rf=r1*rf1\n", - "r2=rf/rf2\n", - "r3=rf/rf3\n", - "\n", - "#answer\n", - "\n", - "print \"R1 = \",r1,\"kilo ohm\"\n", - "print \"R2 = \",r2,\"kilo ohm\"\n", - "print \"R3 = \",r3,\"kilo ohm\"\n", - "print \"Rf = \",rf,\"kilo ohm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.5, Page 18" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1 = 10 kilo ohm\n", - "R2 = 300 kilo ohm\n", - "Rf = 100 kilo ohm\n" - ] - } - ], - "source": [ - "#Variable declaration\n", - "\n", - "r1,r2,rf #vo=10*v1+5=-(rf/r1*v1)-rf/r2*(-15)\n", - "\n", - "#Calculation\n", - "\n", - "r1=10\n", - "rf=10*r1; #-rf/r1*v1=10*v1\n", - "r2=rf*15/5 #-rf/r2*(-15)=5\n", - "\n", - "#answer\n", - "\n", - "print \"R1 = \",r1,\"kilo ohm\"\n", - "print \"R2 = \",r2,\"kilo ohm\"\n", - "print \"Rf = \",rf,\"kilo ohm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.6, Page 20" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1 = 100 kilo ohm\n", - "R2 = 300 kilo ohm\n", - "R3 = 25 kilo ohm\n", - "R4 = 75 kilo ohm\n" - ] - } - ], - "source": [ - "#Variable declaration\n", - "\n", - "ri1=100 # in kilo ohm\n", - "ri2=100 # in kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "r1=ri1;\n", - "r2=3*r1; #r2/r1=3\n", - "# r3 + r4 = ri2 and (1+r1/r2)/(1+r3/r4)=1\n", - "#Solving the above two\n", - "r3=ri2/4;\n", - "r4=ri2-r3\n", - "\n", - "#answer\n", - "\n", - "print \"R1 = \",r1,\"kilo ohm\"\n", - "print \"R2 = \",r2,\"kilo ohm\"\n", - "print \"R3 = \",r3,\"kilo ohm\"\n", - "print \"R4 = \",r4,\"kilo ohm\"\n", - "\n", - "#in textbook r3 and r4 values are reversed which doesn't satisfy the equations" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.7, Page 25" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)T >= 1000\n", - "b)a >= 100000\n", - "a)Beta = 0.00999\n" - ] - } - ], - "source": [ - "#Variable Declaration\n", - "\n", - "A=100 \n", - "accuracy=0.1\n", - "\n", - "#Calcualtion\n", - "\n", - "T=100/accuracy\n", - "beta=1.0/100.0 # A_ideal=i/beta=100\n", - "a=(10**3)/beta\n", - "beta=(a/100-1)/a # A=a/(1+(a*beta))\n", - "\n", - "#answer\n", - "print \"a)T >= \",int(T)\n", - "print \"b)a >= \",int(a)\n", - "print \"a)Beta = \",beta" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.8, Page 26" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a) A changes by (+-) 0.09901 %\n", - "b) A changes by (+-) 0.0001 %\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "a = 10**5 \n", - "beta\n", - "T\n", - "\n", - "#Calculation\n", - "\n", - "def calculate():\n", - " global a,beta,T\n", - " T=a*beta\n", - " ans=10.0/(1+T) # for a +- 10% change in a\n", - " return ans\n", - "\n", - "#answer\n", - "beta=10**(-3) #given\n", - "desensitivity_factor=calculate(); # stores the answer\n", - "print \"a) A changes by (+-)\",round(desensitivity_factor,6),\"%\" #part a\n", - "\n", - "beta=1 #given\n", - "desensitivity_factor=calculate();\n", - "print \"b) A changes by (+-)\",round(desensitivity_factor,6),\"%\" #part b" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.9, Page 33" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)\n", - " A = 995.024876 V/V\n", - " Ro = 373.134 mili ohm\n", - " Ri = 402.0 Mega ohm\n", - "b)\n", - " A = 0.999995 V/V\n", - " Ro = 0.375 mili ohm\n", - " Ri = 400002.0 Mega ohm\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "rd = 2.0 # Mega ohm\n", - "ro = 75.0 # ohm\n", - "a = 200000.0 # V/V\n", - "\n", - "#Calculation\n", - "\n", - "def calculate(R1,R2):\n", - " global a,ro,rd\n", - " beta=R1/(R1+R2)\n", - " if(R1==float(\"inf\")): # for infinty\n", - " beta=1\n", - " T=a*beta\n", - " A=(1+(R2/R1))/(1+(1/T)) # equation 1.55\n", - " if(R1==float(\"inf\")): # for infinity\n", - " A=1/(1+(1/T))\n", - " Ro=ro/(1+T) # equation 1.61\n", - " Ri=rd*(1+T) # equation 1.59\n", - " print \" A = \",round(A,6),\"V/V\"\n", - " print \" Ro = \",round(Ro*(10**3),3),\"mili ohm\"\n", - " print \" Ri = \", round(Ri,3),\"Mega ohm\"\n", - "\n", - "#answer\n", - "\n", - "print \"a)\"\n", - "calculate(1.0,999)\n", - "print \"b)\"\n", - "calculate(float(\"inf\"),1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.10, Page 35" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)\n", - " A = -0.99999 V/V\n", - " Rn = 0.5 ohm\n", - " Ri = 100000.0 ohm\n", - " Ro = 0.00075 ohm\n", - "b)\n", - " A = -995.01993 V/V\n", - " Rn = 4.99998 ohm\n", - " Ri = 1000.0 ohm\n", - " Ro = 0.37351 ohm\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "a = 200000.0 # V/V\n", - "ro = 75 # ohm\n", - "\n", - "#Calculating function\n", - "\n", - "def calculate(R1,R2):\n", - " global a,ro\n", - " T=a*(R1/(R1+R2)) \n", - " A=(-1)*(R2/R1)/(1+(1/T)) # equation 1.63\n", - " Rn=R2/(1+a) # equation 1.67b\n", - " Ri=R1 # equation 1.68\n", - " Ro=ro/(1+T)\n", - " print \" A = \",round(A,5),\"V/V\"\n", - " print \" Rn = \",round(Rn,5),\"ohm\"\n", - " print \" Ri = \",round(Ri,5),\"ohm\"\n", - " print \" Ro = \",round(Ro,5),\"ohm\"\n", - " \n", - "#answer\n", - "\n", - "print \"a)\"\n", - "calculate(100000.0,100000.0)\n", - "print \"b)\"\n", - "calculate(1000.0,1000000.0)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.11, Page 38" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "317.440162529\n", - "a) A_ideal = -101.1 V/V\n", - "b) A = -100.78 V/V\n", - "Deviation from ideal = 0.31 %\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "R1 = 1000000.0 # ohm\n", - "R2 = 1000000.0 # ohm\n", - "R3 = 100000.0 # ohm\n", - "R4 = 1000.0 # ohm\n", - "RL = 2000.0 # ohm\n", - "rd = 1000000.0 #ohm\n", - "a = 10**5 # V/V\n", - "ro = 100.0 # ohm\n", - "\n", - "#Calculation\n", - "\n", - "A_ideal = (-1)*(R2/R1)*(1+(R3/R2)+(R3/R4)) # ideal op-amp and summing currents at node v1\n", - "T = a/(1+(R2/R1)+(R2/rd))/(1+(ro/(R2+(R1*rd/(R1+rd))))+(ro/RL))/100 #equation 1.73\n", - "A = A_ideal/(1+(1/T)) \n", - "dev=(A_ideal-A)/A_ideal*100\n", - "\n", - "#answer\n", - "print T\n", - "print \"a) A_ideal =\",A_ideal,\"V/V\"\n", - "print \"b) A =\",round(A,2),\"V/V\"\n", - "print \"Deviation from ideal =\",round(dev,2),\"%\"\n", - "\n", - "#book example has precision error so answer is 0.32%" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.12, Page 40" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)\n", - " Beta = 0.016911 V/V\n", - " T = 169.1\n", - "b)\n", - " Vo= -( 29.82 V1 + 14.91 V2 + 9.94 V3 )\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "rd = 1000.0 # kilo ohm\n", - "a = 10**4 # V/V\n", - "ro = 100.0 #ohm\n", - "R1 = 10.0 # kilo ohm\n", - "R2 = 20.0 # kilo ohm\n", - "R3 = 30.0 # kilo ohm\n", - "R4 = 300.0 # kilo ohm\n", - "RL = 2.0 # kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "def parallel(a,b):\n", - " ans=a*b/(a+b)\n", - " return ans\n", - "\n", - "Ra = parallel(R1,parallel(R2,parallel(R3,rd)))\n", - "Rb=Ra+R4\n", - "Rc=parallel(Rb,RL) #After suppressing all input sources\n", - "Rd=Rc+ro/1000 #replacing the op-amp with it's terminal resistances\n", - "Vn=Rb/Ra #and applying a test voltage and analysing the circuit\n", - "Vt=Rd/Rc\n", - "beta=1/Vn/Vt\n", - "T=a*beta\n", - "v1=R4/R1\n", - "v2=R4/R2\n", - "v3=R4/R3\n", - "A=1/(1+1/T)\n", - "\n", - "#answer\n", - "\n", - "print \"a)\"\n", - "print \" Beta =\",round(beta,6),\"V/V\"\n", - "print \" T =\",round(T,1)\n", - "print \"b)\"\n", - "print \" Vo= -(\",round(A*v1,2),\"V1 +\",round(A*v2,2),\"V2 +\",round(A*v3,2),\"V3 )\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.13, Page 41" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Beta = 0.8101 V/V\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "rd = 100.0 # kilo ohm\n", - "ro = 100.0 # ohm\n", - "R1 = 30.0 # kilo ohm\n", - "R2 = 20.0 # kilo ohm\n", - "R3 = 10.0 # kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "def parallel(a,b):\n", - " ans=a*b/(a+b)\n", - " return ans\n", - "\n", - "beta_n = (parallel(R1,rd)+R1)/((ro/1000)+R2+parallel(R1,rd)+R3) # from circuit 1.35 after appyling\n", - "beta_p = R3/((ro/1000)+R2+parallel(R1,rd)+R3) # voltage divide formula twice\n", - "beta=beta_n-beta_p #equation 1.76\n", - "\n", - "#answer\n", - "\n", - "print \"Beta =\",round(beta,4),\"V/V\"\n", - "\n", - "# beta_n calculation in book is wrong" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.14, Page 43" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a)\n", - " Icc = 0.5 mA\n", - " Iee = 3.5 mA\n", - " I0 = 3 mA\n", - "b)\n", - " Power Poa = 42.0 mW\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable Declaration \n", - "\n", - "R1 = 10 #kilo ohm\n", - "R2 = 20 #kilo ohm\n", - "V1 = 3 # V\n", - "Iq = 0.5 # mA\n", - "RL = 2 #kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "V0 = (-1)*R2/R1*V1\n", - "It = abs(V0)/RL # Currents through R1,R2,Rt are i1,i2,It respectively\n", - "i1 = It/R1\n", - "i2 = i1 # applying voltage divider rule\n", - "i0 = i2+It\n", - "icc = Iq\n", - "iee = icc+ i0\n", - "Poa = 30*Iq+((V0+15)*i0) #Whenever current passes through voltage drop, power = vi\n", - "\n", - "#answer\n", - "\n", - "print \"a)\"\n", - "print \" Icc =\",icc,\"mA\"\n", - "print \" Iee =\",iee,\"mA\"\n", - "print \" I0 =\",i0,\"mA\"\n", - "print \"b)\"\n", - "print \" Power Poa =\",Poa,\"mW\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.15, Page 43" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "b)\n", - " Change in v = 3.75 micro Volt -> quite a small change\n" - ] - } - ], - "source": [ - "#Variable Declaration\n", - "\n", - "ro = 75.0 #kilo ohm\n", - "T = 200000.0\n", - "Vs = 10.0 # V\n", - "Rl = 1.0 #kilo ohm\n", - "\n", - "#Calculation\n", - "\n", - "iL = Vs/Rl\n", - "Ro = ro/(1+T)\n", - "del_v = Ro*10*(10**(-3))\n", - "\n", - "#answer\n", - "\n", - "print \"b)\"\n", - "print \" Change in v =\",round(del_v*(10**6),2),\"micro Volt -> quite a small change\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.16, Page 46" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The op-amp saturates at Vo=+-13 V\n", - "With Vn= 20/3-13/3 = 2.3333 V\n" - ] - }, - { - "data": { - "text/plain": [ - "[]" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEhCAYAAABhpec9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm8lGX9//HXR0BxXzIQFQNNcE1JJDWXoySSAkqZWpqK\ntmmK+XVfvl8oK+3n8q0s9w0qcdfOkcVIPYIKmqwae19MDUNSREVBls/vj+uewzDOmTPnMHPf98y8\nn4/He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/JdxJ3rwNuIqRSmGVmv4gqGZHUSW2uJ5GEWDO3Iex/sBxYbmbvA5ktJl8FvmRm\nmxMydz4c5VuDsMFOXu7+HPCcmW0JXA7MMbOT3P3xErwPkZJRRSFSvJVZt9dm3V9L+L+0EbA0ao00\nMbN2hMzDAH929+HR45sSWihDgK2BocBfyxW8SFupohBZ34fAlq38HYOQ49/MFprZie7+SJTGeV93\nn0nYuW7dL5j9P0K305PAxe4+owSxi5SFKgqRLO7+rpm9YGavEvavzsz28Kzb5LmduX8qcKuZXU1I\nqz4KmJnnVM8CV7v7p6WMX6QcNOtJREQK0qwnEREpSBWFiIgUpIpCREQKUkUhIiIFqaIQEZGCVFGI\niEhBqihERKQgVRQiIlLQ/wfqhyu+stXumgAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "import matplotlib.pyplot as plt\n", - "import scipy as np\n", - "import math\n", - "\n", - "#Variable Declaration\n", - "\n", - "A = -2 #V/V\n", - "peak = 10 # V\n", - "\n", - "#Calculation \n", - "\n", - "output = np.absolute(A) * peak\n", - "\n", - "#answer\n", - "\n", - "print \"The op-amp saturates at Vo=+-13 V\"\n", - "print \"With Vn= 20/3-13/3 =\",round((20.0/3)-(13.0/3),4),\"V\"\n", - "\n", - "#Graphs\n", - "\n", - "t1 = np.arange(0,1,.0005) # Triangular waveform\n", - "t2 = np.arange(1,3,.0005)\n", - "t3 = np.arange(3,5,.0005)\n", - "\n", - "m1 = np.arange(0,0.65,.0005)\n", - "m2 = np.arange(.65,1.35,.0005)\n", - "m3 = np.arange(1.35,2.65,.0005) # Output Vo wave\n", - "m4 = np.arange(2.65,3.35,.0005)\n", - "m5 = np.arange(3.35,4.65,.0005)\n", - "m6 = np.arange(4.65,5,.0005) # Output Vn wave\n", - "m7 = np.arange(0.65,1,.0005)\n", - "m8 = np.arange(1,1.35,.0005)\n", - "m9 = np.arange(2.65,3,.0005)\n", - "m10 = np.arange(3, 3.35, .0005)\n", - "\n", - "plt.subplot(2,1,1)\n", - "\n", - "plt.suptitle(\"Vt (Blue), Vo (Red) and Vn (Green) Graphs\")\n", - "plt.xlim(0,4.5)\n", - "plt.xlabel(\"time->\")\n", - "plt.ylabel(\"V->\")\n", - "plt.plot(t1,peak*t1,\"b\",)\n", - "plt.plot(t2,(-1)*peak*t2+2*(peak),\"b\",)\n", - "plt.plot(t3,peak*t3-4*(peak),\"b\",)\n", - "\n", - "plt.subplot(2,1,2)\n", - "\n", - "plt.xlim(0,4.5)\n", - "plt.xlabel(\"time->\")\n", - "plt.ylabel(\"V->\")\n", - "plt.plot(m1,-20*m1,\"r\")\n", - "plt.plot(m2,np.full(len(m2),-13),\"r\")\n", - "plt.plot(m3,20*m3-40,\"r\")\n", - "plt.plot(m4,np.full(len(m4),13),\"r\")\n", - "plt.plot(m5,-20*m5+80,\"r\")\n", - "plt.plot(m6,np.full(len(m6),-13),\"r\")\n", - "\n", - "plt.plot(m1,np.full(len(m1),0),\"g\",)\n", - "plt.plot(m7,6.665*m7-4.4,\"g\")\n", - "plt.plot(m8,-6.665*m8+8.8,\"g\")\n", - "plt.plot(m3,np.full(len(m3),0),\"g\")\n", - "plt.plot(m9,6.665*m9-17.6,\"g\")\n", - "plt.plot(m10,-6.665*m10+22.4,\"g\")\n", - "plt.plot(m5,np.full(len(m5),0),\"g\")\n", - "plt.plot(m6,np.full(len(m6),0),\"g\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Abu BakkerSiddik/Functions.ipynb b/sample_notebooks/Abu BakkerSiddik/Functions.ipynb new file mode 100755 index 00000000..4a23de26 --- /dev/null +++ b/sample_notebooks/Abu BakkerSiddik/Functions.ipynb @@ -0,0 +1,1441 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:63dae7729725476213c038c75f708a0afd5386cd85264fbfba4fc7a16437b94f" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 6: Functions" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1 page 217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def power(x,n): #Function header\n", + " # Function body starts here....\n", + " result=1.0 #declaration of variable result \n", + " for i in range(1,n+1,1):\n", + " result*=x #computing X to power n\n", + " return result #returning result\n", + "#Function body ends here....\n", + "\n", + "print \"result=%f\" % (power(2,2)) #function call\n", + "print \"result=%f\" % (power(3,3)) #function call" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "result=4.000000\n", + "result=27.000000\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2 page 218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def FtoC(faren): #Function header\n", + " # Function body starts here....\n", + " factor =5.0/9.0\n", + " freezing=32.0 \n", + " celcius=factor*(faren-freezing) #computing temp in celcius\n", + " return celcius #returning result\n", + "#Function body ends here....\n", + "\n", + "print \"result=%f\" % (FtoC(32.0)) #function call" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "result=0.000000\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3 page 218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#prototype not present in Python def sum_(a,b);\n", + "def main():\n", + " a=5\n", + " b=10\n", + " print \"sum=%d\" % (sum_(a,b))\n", + " return\n", + "#Main ends here....\n", + "\n", + "def sum_(x,y):\n", + "# Function body starts here....\n", + " return x+y #returning result\n", + "#Function body ends here....\n", + "main() #Calling main function" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sum=15\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4 page 219" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def leap_yr(yr): #Function Defination\n", + "# Function body starts here....\n", + " if((yr%4==0) and (yr%100!=0) or yr%400==0):\n", + " return 1 #returning result\n", + " else:\n", + " return 0 #returning result\n", + "#Function body ends here.... \n", + "print leap_yr(2016) #Calling function" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5 page 220" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main(): #main starts here\n", + " print \"Temperature in Fahrenheit scale: \"\n", + " tempInF=eval(raw_input())\n", + " tempInC=FtoC(tempInF) #function FtoC() called from In[2]\n", + " print \"%f Fahrenheit equals %f Celcius \\n \" % (tempInF,tempInC)\n", + " return\n", + " #main ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Temperature in Fahrenheit scale: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "32\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "32.000000 Fahrenheit equals 0.000000 Celcius \n", + " \n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6 page 221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main(): \n", + " num=3\n", + " print \"\\n num = %d before function call.\" % (num) #taking input from user\n", + " result=mul_by_10(num) #function call\n", + " print \"\\n result = %d, after return from function.\" % (result) #Displaying result\n", + " print \"\\n num = %d\" % (num)\n", + " return\n", + "#main ends here\n", + "def mul_by_10(num): #Function header\n", + " num*=10; #Function body starts here\n", + " return num #returning result\n", + " #Function body ends here\n", + "main() #calling main function" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " num = 3 before function call.\n", + "\n", + " result = 30, after return from function.\n", + "\n", + " num = 3\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 7 page 222" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main(): #main starts here\n", + " print \"Enter two numbers: \"\n", + " nOne=eval(raw_input()) #taking input from user\n", + " nTwo=eval(raw_input()) #taking input from user\n", + " n=GCD(nOne,nTwo)\n", + " print \"\\nGCD of %d and %d is %d \\n\" %(nOne,nTwo,n) #main ends here\n", + " return\n", + "def GCD(x,y): #function starts here\n", + " result=1\n", + " k=2\n", + " while((k<=x) and (k<=y)): #checking if x and y are greater than k\n", + " if((x%k==0) and (y%k==0)):\n", + " result=k\n", + " k+=1\n", + " return result #function ends here\n", + "main() #function call" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter two numbers: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "GCD of 4 and 8 is 4 \n", + "\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8 page 222" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main(): #main starts here\n", + " print \"\\nEnter the Number: \"\n", + " n=eval(raw_input()) #taking input from user\n", + " print \"\\nPrime factors on %d is...\\n \" % (n) \n", + " for d in range(2,(n/2)+1,1):\n", + " if((n%d==0) and isPrime(d)): #calculating prime factors, isPrime() function\n", + " print \"%d\" % (d)\n", + " return #main ends here \n", + "def isPrime(x): #isPrime() function starts here\n", + " for d in range(2,(x/2)+1,1):\n", + " if(x%d==0):\n", + " return 0\n", + " return 1 #isPrime() function ends here\n", + "main() #calling main" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter the Number: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Prime factors on 2 is...\n", + " \n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9 page 223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main(): #main starts here\n", + " arr=[1,2,3] #Array declaration and initialisation\n", + " change(arr) #calling function\n", + " print \"Elements are %d, %d and %d\" % (arr[0],arr[1],arr[2])\n", + " return #main starts here\n", + "def change(my_array):\n", + " my_array[0]=10 #Changing values\n", + " my_array[1]=20\n", + " return\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Elements are 10, 20 and 3\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 10 page 223 and 224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main():\n", + " arr=[3,2,7,0,6,4,9,8,1,5] #array declaration and initializtion\n", + " print \"The array before sort is: \\n\" \n", + " for i in range(0,10,1): #displaying array values before changing\n", + " print arr[i],\n", + " sort(arr,10)\n", + " print \"\\nThe array after sort is: \\n\"\n", + " for i in range(0,10,1): #displaying array values after changing\n", + " print arr[i],\n", + " return\n", + "#main ends here\n", + "#functions starts here\n", + "def sort(a,n):\n", + " for i in range(0,n-1,1): #sorting array values\n", + " for j in range(0,n-i-1,1):\n", + " if(a[j]>a[j+1]):\n", + " temp=a[j]\n", + " a[j]=a[j+1]\n", + " a[j+1]=temp\n", + " return\n", + "#functions ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The array before sort is: \n", + "\n", + "3 2 7 0 6 4 9 8 1 5 \n", + "The array after sort is: \n", + "\n", + "0 1 2 3 4 5 6 7 8 9\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11 page 224" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main():\n", + " myInts=[1,2,3,4,5,6,7,8,9,10] #Array initialisation and declaration\n", + " size=10\n", + " print \"\\n\\nThe given numbers are:\"\n", + " for i in range(0,size,1): #displaying array values before changing\n", + " print myInts[i],\n", + " doubleThem(myInts,size) #calling function\n", + " print \"\\nThe double numbers are: \"\n", + " for i in range(0,size,1): #displaying array values after changing\n", + " print myInts[i],\n", + " return\n", + "#main ends here\n", + "#*********function defination***********#\n", + "def doubleThem(a,size):\n", + " for i in range(0,size,1): #multplying array values by 2\n", + " a[i]=2*a[i]\n", + " return\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "\n", + "The given numbers are:\n", + "1 2 3 4 5 6 7 8 9 10 \n", + "The double numbers are: \n", + "2 4 6 8 10 12 14 16 18 20\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 12 page 224 and 225" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main():\n", + " b=list() #array declaration\n", + " n=input(\"How many students?\")\n", + " print \"Enter the age of students\\n\"\n", + " for i in range(0,n,1): #taking input from user\n", + " val=input()\n", + " b.append(val)\n", + " average=avg_age(b,n) #calling function\n", + " print \"\\nThe avg age of students is = %f\" % average\n", + " return\n", + "#main ends here\n", + "def avg_age(a,n):\n", + " sum=0.0\n", + " for j in range(0,n,1): #calculating avg age\n", + " sum=sum+a[j]\n", + " return sum/n\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many students?5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the age of students\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "The avg age of students is = 10.000000\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 13 page 225" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main():\n", + " values=list() #array declaration\n", + " print \"Enter 5 numbers\"\n", + " for i in range(0,5,1): #taking input from user\n", + " val=input()\n", + " values.append(val)\n", + " max1=maximum(values,5) #calling function\n", + " print \"Maximum value is %d\\n\" % max1\n", + " return\n", + "#main ends here\n", + "#function begins here\n", + "def maximum(values,n):\n", + " max_value=values[0]\n", + " for i in range(0,n,1): #finding maximum value\n", + " if(values[i]>max_value):\n", + " max_value=values[i]\n", + " return max_value\n", + "#function ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter 5 numbers\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "125\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "365\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "552\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "001\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "-568\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum value is 552\n", + "\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 14 page 225 and 226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def main():\n", + " a=list() #source string\n", + " b=list() #destination string\n", + " print \"Input source string: \"\n", + " a=raw_input() #read input string\n", + " b=string_copy(b,a) #function call\n", + " print \"\\nDestination string: %s\\n\" % b\n", + " return\n", + "#function call\n", + "def string_copy(d,s):\n", + " print \"\\nSource string: %s\" % s \n", + " #copying the string\n", + " d=s\n", + " return d\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Input source string: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "i love python\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Source string: i love python\n", + "\n", + "Destination string: i love python\n", + "\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 15 page 226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "ROW=2 #define row 3\n", + "COLUMN=3 #define col 3\n", + "def main(): \n", + " global ROW,COLUMN\n", + " a=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", + " b=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", + " print \"\\nEnter elements of the first matrix.\\n\"\n", + " #Read first matrix elements\n", + " for i in range(ROW):\n", + " for j in range(COLUMN):\n", + " a[i][j]=input()\n", + " print \"\\nEnter elements of the second matrix.\\n\"\n", + " #Read second matrix elements\n", + " for i in range(ROW):\n", + " for j in range(COLUMN):\n", + " b[i][j]=input()\n", + " mat_arith(a,b) #function call\n", + "def mat_arith(a,b):\n", + " global ROW,COLUMN\n", + " c=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", + " print \"\\nFor addition enter: 1\\n\"\n", + " print \"\\nFor subtraction enter: 2\\n\"\n", + " print \"\\nEnter your choice\\n\"\n", + " choice=eval(raw_input())\n", + " for i in range(ROW):\n", + " for j in range(COLUMN):\n", + " if choice == 1: #checking for addation and subtraction and performing it\n", + " c[i][j]=a[i][j]+b[i][j]\n", + " elif choice == 2:\n", + " c[i][j]=a[i][j]-b[i][j]\n", + " else:\n", + " print \"Invalid choice. Task not done.\"\n", + " return\n", + " print \"\\nThe resulting matrix is:\\n\"\n", + " for i in range(ROW):\n", + " for j in range(COLUMN):\n", + " print c[i][j],\n", + " print(\"\\n\")\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter elements of the first matrix.\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "6\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "10\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter elements of the second matrix.\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "7\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "9\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "11\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "For addition enter: 1\n", + "\n", + "\n", + "For subtraction enter: 2\n", + "\n", + "\n", + "Enter your choice\n", + "\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "The resulting matrix is:\n", + "\n", + "3 7 11 \n", + "\n", + "14 17 21 \n", + "\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 16 page 227 and 228" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main strats here\n", + "def main():\n", + " a=5\n", + " b=7\n", + " print \"In main: a= %d, b= %d\\n\" % (a,b)\n", + " exchange(a,b) #calling function\n", + " print\"\\nBack in main:\"\n", + " print\"a= %d, b= %d\" % (a,b)\n", + " return\n", + "#main ends here\n", + "#function starts here\n", + "def exchange(a,b):\n", + " print\"In function exchange() before change: just received from main... a=%d and b=%d \" % (a,b)\n", + " #exchanging values\n", + " temp=a\n", + " a=b\n", + " b=temp\n", + " print\"In function exchange() after change:\"\n", + " print\"a=%d and b=%d \" % (a,b)\n", + " return\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In main: a= 5, b= 7\n", + "\n", + "In function exchange() before change: just received from main... a=5 and b=7 \n", + "In function exchange() after change:\n", + "a=7 and b=5 \n", + "\n", + "Back in main:\n", + "a= 5, b= 7\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 17 page 228" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "a=5 #declaration of global variables\n", + "b=7\n", + "#main starts here\n", + "def main():\n", + " global a\n", + " global b\n", + " print \"In main: a= %d, b= %d\\n\" % (a,b)\n", + " exchange() #calling function\n", + " print\"\\nBack in main:\",\n", + " print\"a= %d, b= %d\" % (a,b)\n", + "#main ends here\n", + "#function starts here\n", + "def exchange():\n", + " global a\n", + " global b\n", + " print\"In function exchange() before change: just received from main... a=%d and b=%d \" % (a,b)\n", + " temp=a\n", + " a=b\n", + " b=temp\n", + " print\"In function exchange() after change:\",\n", + " print\"a=%d and b=%d \" % (a,b)\n", + " return\n", + "#function ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "In main: a= 5, b= 7\n", + "\n", + "In function exchange() before change: just received from main... a=5 and b=7 \n", + "In function exchange() after change: a=7 and b=5 \n", + "\n", + "Back in main: a= 7, b= 5\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 18 page 229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def fn1():\n", + " #variable declaration in inner block\n", + " x=45\n", + " print\"\\nin inner block x= %d\" % x\n", + "#variable declaration in outer block\n", + "x=3\n", + "print \"\\nin outer block x = %d before executing inner block\" % x\n", + "fn1()\n", + "print \"\\nin outer block x = %d after executing inner block\" % x" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "in outer block x = 3 before executing inner block\n", + "\n", + "in inner block x= 45\n", + "\n", + "in outer block x = 3 after executing inner block\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 19 page 231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#function starts here\n", + "def fn1():\n", + " a=10\n", + " i=4199232\n", + " print \"a=%d\" % a\n", + " print \"i=%d\" % i\n", + "#function ends here\n", + "a=5\n", + "print \"a=%d\" % a\n", + "fn1() #function call\n", + "print \"a=%d\" % a" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a=5\n", + "a=10\n", + "i=4199232\n", + "a=5\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 20 page 232" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "i = 0\n", + "#function starts here\n", + "def show():\n", + " global i\n", + " print 'i =',i\n", + " i+=1\n", + "#function ends here\n", + "print\"\\nFirst call of show()\"\n", + "show() #function call\n", + "print\"\\nSecond call of show()\"\n", + "show() #function call\n", + "print\"\\nThird call of show()\"\n", + "show() #function call" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "First call of show()\n", + "i = 0\n", + "\n", + "Second call of show()\n", + "i = 1\n", + "\n", + "Third call of show()\n", + "i = 2\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 21 page 231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "i = None\n", + "#function starts here\n", + "def show():\n", + " print 'Value of i in pgm2.c =',i\n", + "#function ends here\n", + "i = 10\n", + "#function call\n", + "show()\n", + "print 'Value of i in pgm1.c =',i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of i in pgm2.c = 10\n", + "Value of i in pgm1.c = 10\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 22 page 233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "i = None\n", + "#function starts here\n", + "def show():\n", + " global i\n", + " i = 20\n", + " print \"value of i in pgm2.c = \", i\n", + "#function ends here\n", + "show() #function call\n", + "print\"Value of i in pgm1.c =\",i" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "value of i in pgm2.c = 20\n", + "Value of i in pgm1.c = 20\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 23 page 236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import sys, traceback\n", + "#main starts here\n", + "def main():\n", + " print \"\\nEnter the number of terms: \"\n", + " i=eval(raw_input()) #taking input\n", + " if (i<0): \n", + " print\"\\nError - Number of terms cannot be negative\\n\"\n", + " sys.exit(0)\n", + " print\"Fibonacci sequence for %d terms is: \" % i\n", + " for j in range(1,i+1,1):\n", + " print\"%d\" % fib(j) #function call\n", + "#function ends here\n", + "#function starts here\n", + "def fib(val):\n", + " if(val<=2):\n", + " return 1\n", + " else:\n", + " return(fib(val-1)+fib(val-2))\n", + "#function ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter the number of terms: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Fibonacci sequence for 5 terms is: \n", + "1\n", + "1\n", + "2\n", + "3\n", + "5\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 24 page 237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#main starts here\n", + "def main():\n", + " print\"Enter the numbers: \"\n", + " i=eval(raw_input())\n", + " j=eval(raw_input())\n", + " print\"The GCD of %d and %d is %d\" % (i,j,gcd(i,j)) #calling gcd function\n", + " return\n", + "#function ends here\n", + "#function starts here\n", + "def gcd(a,b):\n", + " remainder=a%b\n", + " if(remainder==0):\n", + " return b\n", + " else:\n", + " return gcd(b,remainder) #recursive call to itself, gcd function\n", + "#function ends here\n", + "main()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the numbers: \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "8\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The GCD of 4 and 8 is 4\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Abu BakkerSiddik/Functions_.ipynb b/sample_notebooks/Abu BakkerSiddik/Functions_.ipynb deleted file mode 100755 index 4a23de26..00000000 --- a/sample_notebooks/Abu BakkerSiddik/Functions_.ipynb +++ /dev/null @@ -1,1441 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:63dae7729725476213c038c75f708a0afd5386cd85264fbfba4fc7a16437b94f" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 6: Functions" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1 page 217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def power(x,n): #Function header\n", - " # Function body starts here....\n", - " result=1.0 #declaration of variable result \n", - " for i in range(1,n+1,1):\n", - " result*=x #computing X to power n\n", - " return result #returning result\n", - "#Function body ends here....\n", - "\n", - "print \"result=%f\" % (power(2,2)) #function call\n", - "print \"result=%f\" % (power(3,3)) #function call" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "result=4.000000\n", - "result=27.000000\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2 page 218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def FtoC(faren): #Function header\n", - " # Function body starts here....\n", - " factor =5.0/9.0\n", - " freezing=32.0 \n", - " celcius=factor*(faren-freezing) #computing temp in celcius\n", - " return celcius #returning result\n", - "#Function body ends here....\n", - "\n", - "print \"result=%f\" % (FtoC(32.0)) #function call" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "result=0.000000\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3 page 218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#prototype not present in Python def sum_(a,b);\n", - "def main():\n", - " a=5\n", - " b=10\n", - " print \"sum=%d\" % (sum_(a,b))\n", - " return\n", - "#Main ends here....\n", - "\n", - "def sum_(x,y):\n", - "# Function body starts here....\n", - " return x+y #returning result\n", - "#Function body ends here....\n", - "main() #Calling main function" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "sum=15\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4 page 219" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def leap_yr(yr): #Function Defination\n", - "# Function body starts here....\n", - " if((yr%4==0) and (yr%100!=0) or yr%400==0):\n", - " return 1 #returning result\n", - " else:\n", - " return 0 #returning result\n", - "#Function body ends here.... \n", - "print leap_yr(2016) #Calling function" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 5 page 220" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def main(): #main starts here\n", - " print \"Temperature in Fahrenheit scale: \"\n", - " tempInF=eval(raw_input())\n", - " tempInC=FtoC(tempInF) #function FtoC() called from In[2]\n", - " print \"%f Fahrenheit equals %f Celcius \\n \" % (tempInF,tempInC)\n", - " return\n", - " #main ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Temperature in Fahrenheit scale: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "32\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "32.000000 Fahrenheit equals 0.000000 Celcius \n", - " \n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6 page 221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main(): \n", - " num=3\n", - " print \"\\n num = %d before function call.\" % (num) #taking input from user\n", - " result=mul_by_10(num) #function call\n", - " print \"\\n result = %d, after return from function.\" % (result) #Displaying result\n", - " print \"\\n num = %d\" % (num)\n", - " return\n", - "#main ends here\n", - "def mul_by_10(num): #Function header\n", - " num*=10; #Function body starts here\n", - " return num #returning result\n", - " #Function body ends here\n", - "main() #calling main function" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " num = 3 before function call.\n", - "\n", - " result = 30, after return from function.\n", - "\n", - " num = 3\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 7 page 222" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def main(): #main starts here\n", - " print \"Enter two numbers: \"\n", - " nOne=eval(raw_input()) #taking input from user\n", - " nTwo=eval(raw_input()) #taking input from user\n", - " n=GCD(nOne,nTwo)\n", - " print \"\\nGCD of %d and %d is %d \\n\" %(nOne,nTwo,n) #main ends here\n", - " return\n", - "def GCD(x,y): #function starts here\n", - " result=1\n", - " k=2\n", - " while((k<=x) and (k<=y)): #checking if x and y are greater than k\n", - " if((x%k==0) and (y%k==0)):\n", - " result=k\n", - " k+=1\n", - " return result #function ends here\n", - "main() #function call" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter two numbers: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "GCD of 4 and 8 is 4 \n", - "\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 8 page 222" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def main(): #main starts here\n", - " print \"\\nEnter the Number: \"\n", - " n=eval(raw_input()) #taking input from user\n", - " print \"\\nPrime factors on %d is...\\n \" % (n) \n", - " for d in range(2,(n/2)+1,1):\n", - " if((n%d==0) and isPrime(d)): #calculating prime factors, isPrime() function\n", - " print \"%d\" % (d)\n", - " return #main ends here \n", - "def isPrime(x): #isPrime() function starts here\n", - " for d in range(2,(x/2)+1,1):\n", - " if(x%d==0):\n", - " return 0\n", - " return 1 #isPrime() function ends here\n", - "main() #calling main" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter the Number: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Prime factors on 2 is...\n", - " \n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9 page 223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def main(): #main starts here\n", - " arr=[1,2,3] #Array declaration and initialisation\n", - " change(arr) #calling function\n", - " print \"Elements are %d, %d and %d\" % (arr[0],arr[1],arr[2])\n", - " return #main starts here\n", - "def change(my_array):\n", - " my_array[0]=10 #Changing values\n", - " my_array[1]=20\n", - " return\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Elements are 10, 20 and 3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 10 page 223 and 224" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main():\n", - " arr=[3,2,7,0,6,4,9,8,1,5] #array declaration and initializtion\n", - " print \"The array before sort is: \\n\" \n", - " for i in range(0,10,1): #displaying array values before changing\n", - " print arr[i],\n", - " sort(arr,10)\n", - " print \"\\nThe array after sort is: \\n\"\n", - " for i in range(0,10,1): #displaying array values after changing\n", - " print arr[i],\n", - " return\n", - "#main ends here\n", - "#functions starts here\n", - "def sort(a,n):\n", - " for i in range(0,n-1,1): #sorting array values\n", - " for j in range(0,n-i-1,1):\n", - " if(a[j]>a[j+1]):\n", - " temp=a[j]\n", - " a[j]=a[j+1]\n", - " a[j+1]=temp\n", - " return\n", - "#functions ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The array before sort is: \n", - "\n", - "3 2 7 0 6 4 9 8 1 5 \n", - "The array after sort is: \n", - "\n", - "0 1 2 3 4 5 6 7 8 9\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11 page 224" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main():\n", - " myInts=[1,2,3,4,5,6,7,8,9,10] #Array initialisation and declaration\n", - " size=10\n", - " print \"\\n\\nThe given numbers are:\"\n", - " for i in range(0,size,1): #displaying array values before changing\n", - " print myInts[i],\n", - " doubleThem(myInts,size) #calling function\n", - " print \"\\nThe double numbers are: \"\n", - " for i in range(0,size,1): #displaying array values after changing\n", - " print myInts[i],\n", - " return\n", - "#main ends here\n", - "#*********function defination***********#\n", - "def doubleThem(a,size):\n", - " for i in range(0,size,1): #multplying array values by 2\n", - " a[i]=2*a[i]\n", - " return\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "\n", - "The given numbers are:\n", - "1 2 3 4 5 6 7 8 9 10 \n", - "The double numbers are: \n", - "2 4 6 8 10 12 14 16 18 20\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 12 page 224 and 225" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main():\n", - " b=list() #array declaration\n", - " n=input(\"How many students?\")\n", - " print \"Enter the age of students\\n\"\n", - " for i in range(0,n,1): #taking input from user\n", - " val=input()\n", - " b.append(val)\n", - " average=avg_age(b,n) #calling function\n", - " print \"\\nThe avg age of students is = %f\" % average\n", - " return\n", - "#main ends here\n", - "def avg_age(a,n):\n", - " sum=0.0\n", - " for j in range(0,n,1): #calculating avg age\n", - " sum=sum+a[j]\n", - " return sum/n\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many students?5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the age of students\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "The avg age of students is = 10.000000\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 13 page 225" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main():\n", - " values=list() #array declaration\n", - " print \"Enter 5 numbers\"\n", - " for i in range(0,5,1): #taking input from user\n", - " val=input()\n", - " values.append(val)\n", - " max1=maximum(values,5) #calling function\n", - " print \"Maximum value is %d\\n\" % max1\n", - " return\n", - "#main ends here\n", - "#function begins here\n", - "def maximum(values,n):\n", - " max_value=values[0]\n", - " for i in range(0,n,1): #finding maximum value\n", - " if(values[i]>max_value):\n", - " max_value=values[i]\n", - " return max_value\n", - "#function ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter 5 numbers\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "125\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "365\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "552\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "001\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "-568\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum value is 552\n", - "\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 14 page 225 and 226" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def main():\n", - " a=list() #source string\n", - " b=list() #destination string\n", - " print \"Input source string: \"\n", - " a=raw_input() #read input string\n", - " b=string_copy(b,a) #function call\n", - " print \"\\nDestination string: %s\\n\" % b\n", - " return\n", - "#function call\n", - "def string_copy(d,s):\n", - " print \"\\nSource string: %s\" % s \n", - " #copying the string\n", - " d=s\n", - " return d\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Input source string: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "i love python\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Source string: i love python\n", - "\n", - "Destination string: i love python\n", - "\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 15 page 226" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "ROW=2 #define row 3\n", - "COLUMN=3 #define col 3\n", - "def main(): \n", - " global ROW,COLUMN\n", - " a=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", - " b=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", - " print \"\\nEnter elements of the first matrix.\\n\"\n", - " #Read first matrix elements\n", - " for i in range(ROW):\n", - " for j in range(COLUMN):\n", - " a[i][j]=input()\n", - " print \"\\nEnter elements of the second matrix.\\n\"\n", - " #Read second matrix elements\n", - " for i in range(ROW):\n", - " for j in range(COLUMN):\n", - " b[i][j]=input()\n", - " mat_arith(a,b) #function call\n", - "def mat_arith(a,b):\n", - " global ROW,COLUMN\n", - " c=[[0 for row in range(0,COLUMN)] for col in range(0,ROW)]\n", - " print \"\\nFor addition enter: 1\\n\"\n", - " print \"\\nFor subtraction enter: 2\\n\"\n", - " print \"\\nEnter your choice\\n\"\n", - " choice=eval(raw_input())\n", - " for i in range(ROW):\n", - " for j in range(COLUMN):\n", - " if choice == 1: #checking for addation and subtraction and performing it\n", - " c[i][j]=a[i][j]+b[i][j]\n", - " elif choice == 2:\n", - " c[i][j]=a[i][j]-b[i][j]\n", - " else:\n", - " print \"Invalid choice. Task not done.\"\n", - " return\n", - " print \"\\nThe resulting matrix is:\\n\"\n", - " for i in range(ROW):\n", - " for j in range(COLUMN):\n", - " print c[i][j],\n", - " print(\"\\n\")\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter elements of the first matrix.\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "6\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "10\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter elements of the second matrix.\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "7\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "9\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "11\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "For addition enter: 1\n", - "\n", - "\n", - "For subtraction enter: 2\n", - "\n", - "\n", - "Enter your choice\n", - "\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "The resulting matrix is:\n", - "\n", - "3 7 11 \n", - "\n", - "14 17 21 \n", - "\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 16 page 227 and 228" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main strats here\n", - "def main():\n", - " a=5\n", - " b=7\n", - " print \"In main: a= %d, b= %d\\n\" % (a,b)\n", - " exchange(a,b) #calling function\n", - " print\"\\nBack in main:\"\n", - " print\"a= %d, b= %d\" % (a,b)\n", - " return\n", - "#main ends here\n", - "#function starts here\n", - "def exchange(a,b):\n", - " print\"In function exchange() before change: just received from main... a=%d and b=%d \" % (a,b)\n", - " #exchanging values\n", - " temp=a\n", - " a=b\n", - " b=temp\n", - " print\"In function exchange() after change:\"\n", - " print\"a=%d and b=%d \" % (a,b)\n", - " return\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In main: a= 5, b= 7\n", - "\n", - "In function exchange() before change: just received from main... a=5 and b=7 \n", - "In function exchange() after change:\n", - "a=7 and b=5 \n", - "\n", - "Back in main:\n", - "a= 5, b= 7\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 17 page 228" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "a=5 #declaration of global variables\n", - "b=7\n", - "#main starts here\n", - "def main():\n", - " global a\n", - " global b\n", - " print \"In main: a= %d, b= %d\\n\" % (a,b)\n", - " exchange() #calling function\n", - " print\"\\nBack in main:\",\n", - " print\"a= %d, b= %d\" % (a,b)\n", - "#main ends here\n", - "#function starts here\n", - "def exchange():\n", - " global a\n", - " global b\n", - " print\"In function exchange() before change: just received from main... a=%d and b=%d \" % (a,b)\n", - " temp=a\n", - " a=b\n", - " b=temp\n", - " print\"In function exchange() after change:\",\n", - " print\"a=%d and b=%d \" % (a,b)\n", - " return\n", - "#function ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "In main: a= 5, b= 7\n", - "\n", - "In function exchange() before change: just received from main... a=5 and b=7 \n", - "In function exchange() after change: a=7 and b=5 \n", - "\n", - "Back in main: a= 7, b= 5\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 18 page 229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def fn1():\n", - " #variable declaration in inner block\n", - " x=45\n", - " print\"\\nin inner block x= %d\" % x\n", - "#variable declaration in outer block\n", - "x=3\n", - "print \"\\nin outer block x = %d before executing inner block\" % x\n", - "fn1()\n", - "print \"\\nin outer block x = %d after executing inner block\" % x" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "in outer block x = 3 before executing inner block\n", - "\n", - "in inner block x= 45\n", - "\n", - "in outer block x = 3 after executing inner block\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 19 page 231" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#function starts here\n", - "def fn1():\n", - " a=10\n", - " i=4199232\n", - " print \"a=%d\" % a\n", - " print \"i=%d\" % i\n", - "#function ends here\n", - "a=5\n", - "print \"a=%d\" % a\n", - "fn1() #function call\n", - "print \"a=%d\" % a" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a=5\n", - "a=10\n", - "i=4199232\n", - "a=5\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 20 page 232" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "i = 0\n", - "#function starts here\n", - "def show():\n", - " global i\n", - " print 'i =',i\n", - " i+=1\n", - "#function ends here\n", - "print\"\\nFirst call of show()\"\n", - "show() #function call\n", - "print\"\\nSecond call of show()\"\n", - "show() #function call\n", - "print\"\\nThird call of show()\"\n", - "show() #function call" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "First call of show()\n", - "i = 0\n", - "\n", - "Second call of show()\n", - "i = 1\n", - "\n", - "Third call of show()\n", - "i = 2\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 21 page 231" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "i = None\n", - "#function starts here\n", - "def show():\n", - " print 'Value of i in pgm2.c =',i\n", - "#function ends here\n", - "i = 10\n", - "#function call\n", - "show()\n", - "print 'Value of i in pgm1.c =',i" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Value of i in pgm2.c = 10\n", - "Value of i in pgm1.c = 10\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 22 page 233" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "i = None\n", - "#function starts here\n", - "def show():\n", - " global i\n", - " i = 20\n", - " print \"value of i in pgm2.c = \", i\n", - "#function ends here\n", - "show() #function call\n", - "print\"Value of i in pgm1.c =\",i" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "value of i in pgm2.c = 20\n", - "Value of i in pgm1.c = 20\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 23 page 236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import sys, traceback\n", - "#main starts here\n", - "def main():\n", - " print \"\\nEnter the number of terms: \"\n", - " i=eval(raw_input()) #taking input\n", - " if (i<0): \n", - " print\"\\nError - Number of terms cannot be negative\\n\"\n", - " sys.exit(0)\n", - " print\"Fibonacci sequence for %d terms is: \" % i\n", - " for j in range(1,i+1,1):\n", - " print\"%d\" % fib(j) #function call\n", - "#function ends here\n", - "#function starts here\n", - "def fib(val):\n", - " if(val<=2):\n", - " return 1\n", - " else:\n", - " return(fib(val-1)+fib(val-2))\n", - "#function ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter the number of terms: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Fibonacci sequence for 5 terms is: \n", - "1\n", - "1\n", - "2\n", - "3\n", - "5\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 24 page 237" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#main starts here\n", - "def main():\n", - " print\"Enter the numbers: \"\n", - " i=eval(raw_input())\n", - " j=eval(raw_input())\n", - " print\"The GCD of %d and %d is %d\" % (i,j,gcd(i,j)) #calling gcd function\n", - " return\n", - "#function ends here\n", - "#function starts here\n", - "def gcd(a,b):\n", - " remainder=a%b\n", - " if(remainder==0):\n", - " return b\n", - " else:\n", - " return gcd(b,remainder) #recursive call to itself, gcd function\n", - "#function ends here\n", - "main()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the numbers: \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "8\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The GCD of 4 and 8 is 4\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8.ipynb b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8.ipynb new file mode 100755 index 00000000..cbd1971a --- /dev/null +++ b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8.ipynb @@ -0,0 +1,390 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.2" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", + "(b) The force acting = 2 Gm²\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", + "y=math.radians(x) # The angle in radians\n", + "a=math.cos(y)\n", + "b=math.sin(y)\n", + "v1=(0,1,0)\n", + "v2=(-a,-b,0)\n", + "v3=(a,-b,0)\n", + "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", + "\n", + "# Calculation\n", + "\n", + "#(a)\n", + "F1=[y * c for y in v1] # F(GA)\n", + "F2=[y * c for y in v2] # F(GB)\n", + "F3=[y * c for y in v3] # F(GC)\n", + "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", + "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", + "\n", + "#(b)\n", + "# By symmetry the x-component of the force cancels out and the y-component survives\n", + "Fb=4-2 # 4Gm² j - 2Gm² j\n", + "\n", + "# Result\n", + "\n", + "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", + "print(\"(b) The force acting =\",Fb,\"Gm²\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.3 " + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", + "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "l=1 # For convenience,side of the square is assumed to be unity \n", + "c=(G*pow(m,2))/l\n", + "n=4 # Number of particles\n", + "\n", + "# Calculation\n", + "\n", + "d=math.sqrt(2)\n", + "# If the side of a square is l then the diagonal distance is √2l\n", + "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", + "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", + "w=(-n-(2/d)) \n", + "# If the side of a square is l then the diagonal distance from the centre to corner is \n", + "# Since the Gravitational Potential at the centre of the square\n", + "u=-n*(2/d)\n", + "\n", + "# Result\n", + "\n", + "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", + "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.4" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", + "M=1 # For convenience,mass is assumed to be unity \n", + "m1=M # Mass of the first sphere\n", + "m2=6*M # Mass of the second sphere\n", + "m=1 # Since the mass of the projectile is unknown,take it as unity\n", + "d=6*R # Distance between the centres of both the spheres\n", + "r=1 # The distance from the centre of first sphere to the neutral point N\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "\n", + "# Calculation\n", + "\n", + "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", + "r=2*R\n", + "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", + "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", + "# From the principle of conservation of mechanical energy; Et = En and we get\n", + "v_sqr=2*((4/5)-(1/2))\n", + "\n", + "# Result\n", + "\n", + "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.5 " + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i) Mass of Mars = 6.475139697520706e+23 kg\n", + "(ii) Period of revolution of Mars = 684.0033777694376 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "π=3.14 # Constant pi\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", + "T=459*60\n", + "Te=365 # Period of revolution of Earth\n", + "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", + "\n", + "# Calculation\n", + "\n", + "# (i) \n", + "R=R*pow(10,3)\n", + "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", + "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", + "\n", + "# (ii)\n", + "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", + "Tm=pow(r,(3/2))*365\n", + "\n", + "\n", + "# Result\n", + "\n", + "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", + "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.6" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mass of the Earth = 5.967906881559221e+24 kg\n", + "Mass of the Earth = 6.017752855396305e+24 kg\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "g=9.81 # Acceleration due to gravity\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", + "T=27.3 # Period of revolution of Moon in days\n", + "π=3.14 # Constant pi\n", + "\n", + "# Calculation\n", + "\n", + "# I Method\n", + "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", + "Me1=(g*pow(Re,2))/G\n", + "\n", + "# II Method\n", + "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", + "T1=T*24*60*60\n", + "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", + "\n", + "#Result\n", + "\n", + "print(\"Mass of the Earth =\",Me1,\"kg\")\n", + "print(\"Mass of the Earth =\",Me2,\"kg\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.7 " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Period of revolution of Moon = 27.5 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "k=pow(10,-13) # A constant = 4π² / GME\n", + "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", + "\n", + "# Calculation\n", + "\n", + "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", + "T2=k*pow(Re,3)\n", + "T=math.sqrt(T2) # Period of revolution of Moon in days\n", + "\n", + "# Result\n", + "\n", + "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "###Example 8.8 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Change in Kinetic Energy = 3124485000.0 J\n", + "Change in Potential Energy = 6248970000.0 J\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "m=400 # Mass of satellite in kg\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "g=9.81 # Acceleration due to gravity\n", + "\n", + "# Calculation\n", + "\n", + "# Change in energy is E=Ef-Ei\n", + "ΔE=(g*m*Re)/8 # Change in Total energy\n", + "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", + "ΔV=2*ΔE # Change in Potential Energy in J\n", + "\n", + "# Result\n", + "\n", + "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", + "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-.ipynb b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-.ipynb new file mode 100755 index 00000000..c08a4250 --- /dev/null +++ b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-.ipynb @@ -0,0 +1,390 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2 , page : 187" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", + "(b) The force acting = 2 Gm²\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", + "y=math.radians(x) # The angle in radians\n", + "a=math.cos(y)\n", + "b=math.sin(y)\n", + "v1=(0,1,0)\n", + "v2=(-a,-b,0)\n", + "v3=(a,-b,0)\n", + "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", + "\n", + "# Calculation\n", + "\n", + "#(a)\n", + "F1=[y * c for y in v1] # F(GA)\n", + "F2=[y * c for y in v2] # F(GB)\n", + "F3=[y * c for y in v3] # F(GC)\n", + "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", + "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", + "\n", + "#(b)\n", + "# By symmetry the x-component of the force cancels out and the y-component survives\n", + "Fb=4-2 # 4Gm² j - 2Gm² j\n", + "\n", + "# Result\n", + "\n", + "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", + "print(\"(b) The force acting =\",Fb,\"Gm²\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3 , page : 192" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", + "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "l=1 # For convenience,side of the square is assumed to be unity \n", + "c=(G*pow(m,2))/l\n", + "n=4 # Number of particles\n", + "\n", + "# Calculation\n", + "\n", + "d=math.sqrt(2)\n", + "# If the side of a square is l then the diagonal distance is √2l\n", + "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", + "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", + "w=(-n-(2/d)) \n", + "# If the side of a square is l then the diagonal distance from the centre to corner is \n", + "# Since the Gravitational Potential at the centre of the square\n", + "u=-n*(2/d)\n", + "\n", + "# Result\n", + "\n", + "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", + "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.4 , page : 193" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", + "M=1 # For convenience,mass is assumed to be unity \n", + "m1=M # Mass of the first sphere\n", + "m2=6*M # Mass of the second sphere\n", + "m=1 # Since the mass of the projectile is unknown,take it as unity\n", + "d=6*R # Distance between the centres of both the spheres\n", + "r=1 # The distance from the centre of first sphere to the neutral point N\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "\n", + "# Calculation\n", + "\n", + "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", + "r=2*R\n", + "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", + "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", + "# From the principle of conservation of mechanical energy; Et = En and we get\n", + "v_sqr=2*((4/5)-(1/2))\n", + "\n", + "# Result\n", + "\n", + "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.5 , page : 195" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i) Mass of Mars = 6.475139697520706e+23 kg\n", + "(ii) Period of revolution of Mars = 684.0033777694376 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "π=3.14 # Constant pi\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", + "T=459*60\n", + "Te=365 # Period of revolution of Earth\n", + "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", + "\n", + "# Calculation\n", + "\n", + "# (i) \n", + "R=R*pow(10,3)\n", + "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", + "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", + "\n", + "# (ii)\n", + "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", + "Tm=pow(r,(3/2))*365\n", + "\n", + "\n", + "# Result\n", + "\n", + "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", + "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.6 , page : 195" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mass of the Earth = 5.967906881559221e+24 kg\n", + "Mass of the Earth = 6.017752855396305e+24 kg\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "g=9.81 # Acceleration due to gravity\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", + "T=27.3 # Period of revolution of Moon in days\n", + "π=3.14 # Constant pi\n", + "\n", + "# Calculation\n", + "\n", + "# I Method\n", + "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", + "Me1=(g*pow(Re,2))/G\n", + "\n", + "# II Method\n", + "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", + "T1=T*24*60*60\n", + "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", + "\n", + "#Result\n", + "\n", + "print(\"Mass of the Earth =\",Me1,\"kg\")\n", + "print(\"Mass of the Earth =\",Me2,\"kg\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.7 , page : 195 " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Period of revolution of Moon = 27.5 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "k=pow(10,-13) # A constant = 4π² / GME\n", + "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", + "\n", + "# Calculation\n", + "\n", + "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", + "T2=k*pow(Re,3)\n", + "T=math.sqrt(T2) # Period of revolution of Moon in days\n", + "\n", + "# Result\n", + "\n", + "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.8 , page : 196 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Change in Kinetic Energy = 3124485000.0 J\n", + "Change in Potential Energy = 6248970000.0 J\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "m=400 # Mass of satellite in kg\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "g=9.81 # Acceleration due to gravity\n", + "\n", + "# Calculation\n", + "\n", + "# Change in energy is E=Ef-Ei\n", + "ΔE=(g*m*Re)/8 # Change in Total energy\n", + "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", + "ΔV=2*ΔE # Change in Potential Energy in J\n", + "\n", + "# Result\n", + "\n", + "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", + "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-_Gravitation_1.ipynb b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-_Gravitation_1.ipynb new file mode 100755 index 00000000..c08a4250 --- /dev/null +++ b/sample_notebooks/AdityaAnand/AdityaAnand_version_backup/Chapter_8_-_Gravitation_1.ipynb @@ -0,0 +1,390 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.2 , page : 187" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", + "(b) The force acting = 2 Gm²\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", + "y=math.radians(x) # The angle in radians\n", + "a=math.cos(y)\n", + "b=math.sin(y)\n", + "v1=(0,1,0)\n", + "v2=(-a,-b,0)\n", + "v3=(a,-b,0)\n", + "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", + "\n", + "# Calculation\n", + "\n", + "#(a)\n", + "F1=[y * c for y in v1] # F(GA)\n", + "F2=[y * c for y in v2] # F(GB)\n", + "F3=[y * c for y in v3] # F(GC)\n", + "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", + "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", + "\n", + "#(b)\n", + "# By symmetry the x-component of the force cancels out and the y-component survives\n", + "Fb=4-2 # 4Gm² j - 2Gm² j\n", + "\n", + "# Result\n", + "\n", + "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", + "print(\"(b) The force acting =\",Fb,\"Gm²\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3 , page : 192" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", + "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "m=1 # For convenience,mass is assumed to be unity \n", + "l=1 # For convenience,side of the square is assumed to be unity \n", + "c=(G*pow(m,2))/l\n", + "n=4 # Number of particles\n", + "\n", + "# Calculation\n", + "\n", + "d=math.sqrt(2)\n", + "# If the side of a square is l then the diagonal distance is √2l\n", + "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", + "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", + "w=(-n-(2/d)) \n", + "# If the side of a square is l then the diagonal distance from the centre to corner is \n", + "# Since the Gravitational Potential at the centre of the square\n", + "u=-n*(2/d)\n", + "\n", + "# Result\n", + "\n", + "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", + "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.4 , page : 193" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", + "M=1 # For convenience,mass is assumed to be unity \n", + "m1=M # Mass of the first sphere\n", + "m2=6*M # Mass of the second sphere\n", + "m=1 # Since the mass of the projectile is unknown,take it as unity\n", + "d=6*R # Distance between the centres of both the spheres\n", + "r=1 # The distance from the centre of first sphere to the neutral point N\n", + "\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "\n", + "# Calculation\n", + "\n", + "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", + "r=2*R\n", + "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", + "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", + "# From the principle of conservation of mechanical energy; Et = En and we get\n", + "v_sqr=2*((4/5)-(1/2))\n", + "\n", + "# Result\n", + "\n", + "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.5 , page : 195" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i) Mass of Mars = 6.475139697520706e+23 kg\n", + "(ii) Period of revolution of Mars = 684.0033777694376 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "π=3.14 # Constant pi\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", + "T=459*60\n", + "Te=365 # Period of revolution of Earth\n", + "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", + "\n", + "# Calculation\n", + "\n", + "# (i) \n", + "R=R*pow(10,3)\n", + "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", + "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", + "\n", + "# (ii)\n", + "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", + "Tm=pow(r,(3/2))*365\n", + "\n", + "\n", + "# Result\n", + "\n", + "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", + "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.6 , page : 195" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Mass of the Earth = 5.967906881559221e+24 kg\n", + "Mass of the Earth = 6.017752855396305e+24 kg\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "g=9.81 # Acceleration due to gravity\n", + "G=6.67*pow(10,-11) # Gravitational constant\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", + "T=27.3 # Period of revolution of Moon in days\n", + "π=3.14 # Constant pi\n", + "\n", + "# Calculation\n", + "\n", + "# I Method\n", + "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", + "Me1=(g*pow(Re,2))/G\n", + "\n", + "# II Method\n", + "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", + "T1=T*24*60*60\n", + "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", + "\n", + "#Result\n", + "\n", + "print(\"Mass of the Earth =\",Me1,\"kg\")\n", + "print(\"Mass of the Earth =\",Me2,\"kg\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.7 , page : 195 " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Period of revolution of Moon = 27.5 days\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "k=pow(10,-13) # A constant = 4π² / GME\n", + "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", + "\n", + "# Calculation\n", + "\n", + "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", + "T2=k*pow(Re,3)\n", + "T=math.sqrt(T2) # Period of revolution of Moon in days\n", + "\n", + "# Result\n", + "\n", + "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.8 , page : 196 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Change in Kinetic Energy = 3124485000.0 J\n", + "Change in Potential Energy = 6248970000.0 J\n" + ] + } + ], + "source": [ + "# Importing module\n", + "\n", + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "m=400 # Mass of satellite in kg\n", + "Re=6.37*pow(10,6) # Radius of Earth in m\n", + "g=9.81 # Acceleration due to gravity\n", + "\n", + "# Calculation\n", + "\n", + "# Change in energy is E=Ef-Ei\n", + "ΔE=(g*m*Re)/8 # Change in Total energy\n", + "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", + "ΔV=2*ΔE # Change in Potential Energy in J\n", + "\n", + "# Result\n", + "\n", + "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", + "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AdityaAnand/Chapter_8.ipynb b/sample_notebooks/AdityaAnand/Chapter_8.ipynb deleted file mode 100755 index cbd1971a..00000000 --- a/sample_notebooks/AdityaAnand/Chapter_8.ipynb +++ /dev/null @@ -1,390 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.2" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", - "(b) The force acting = 2 Gm²\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", - "y=math.radians(x) # The angle in radians\n", - "a=math.cos(y)\n", - "b=math.sin(y)\n", - "v1=(0,1,0)\n", - "v2=(-a,-b,0)\n", - "v3=(a,-b,0)\n", - "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", - "\n", - "# Calculation\n", - "\n", - "#(a)\n", - "F1=[y * c for y in v1] # F(GA)\n", - "F2=[y * c for y in v2] # F(GB)\n", - "F3=[y * c for y in v3] # F(GC)\n", - "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", - "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", - "\n", - "#(b)\n", - "# By symmetry the x-component of the force cancels out and the y-component survives\n", - "Fb=4-2 # 4Gm² j - 2Gm² j\n", - "\n", - "# Result\n", - "\n", - "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", - "print(\"(b) The force acting =\",Fb,\"Gm²\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.3 " - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", - "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "l=1 # For convenience,side of the square is assumed to be unity \n", - "c=(G*pow(m,2))/l\n", - "n=4 # Number of particles\n", - "\n", - "# Calculation\n", - "\n", - "d=math.sqrt(2)\n", - "# If the side of a square is l then the diagonal distance is √2l\n", - "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", - "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", - "w=(-n-(2/d)) \n", - "# If the side of a square is l then the diagonal distance from the centre to corner is \n", - "# Since the Gravitational Potential at the centre of the square\n", - "u=-n*(2/d)\n", - "\n", - "# Result\n", - "\n", - "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", - "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.4" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", - "M=1 # For convenience,mass is assumed to be unity \n", - "m1=M # Mass of the first sphere\n", - "m2=6*M # Mass of the second sphere\n", - "m=1 # Since the mass of the projectile is unknown,take it as unity\n", - "d=6*R # Distance between the centres of both the spheres\n", - "r=1 # The distance from the centre of first sphere to the neutral point N\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "\n", - "# Calculation\n", - "\n", - "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", - "r=2*R\n", - "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", - "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", - "# From the principle of conservation of mechanical energy; Et = En and we get\n", - "v_sqr=2*((4/5)-(1/2))\n", - "\n", - "# Result\n", - "\n", - "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.5 " - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i) Mass of Mars = 6.475139697520706e+23 kg\n", - "(ii) Period of revolution of Mars = 684.0033777694376 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "π=3.14 # Constant pi\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", - "T=459*60\n", - "Te=365 # Period of revolution of Earth\n", - "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", - "\n", - "# Calculation\n", - "\n", - "# (i) \n", - "R=R*pow(10,3)\n", - "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", - "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", - "\n", - "# (ii)\n", - "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", - "Tm=pow(r,(3/2))*365\n", - "\n", - "\n", - "# Result\n", - "\n", - "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", - "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.6" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Mass of the Earth = 5.967906881559221e+24 kg\n", - "Mass of the Earth = 6.017752855396305e+24 kg\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "g=9.81 # Acceleration due to gravity\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", - "T=27.3 # Period of revolution of Moon in days\n", - "π=3.14 # Constant pi\n", - "\n", - "# Calculation\n", - "\n", - "# I Method\n", - "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", - "Me1=(g*pow(Re,2))/G\n", - "\n", - "# II Method\n", - "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", - "T1=T*24*60*60\n", - "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", - "\n", - "#Result\n", - "\n", - "print(\"Mass of the Earth =\",Me1,\"kg\")\n", - "print(\"Mass of the Earth =\",Me2,\"kg\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.7 " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Period of revolution of Moon = 27.5 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "k=pow(10,-13) # A constant = 4π² / GME\n", - "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", - "\n", - "# Calculation\n", - "\n", - "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", - "T2=k*pow(Re,3)\n", - "T=math.sqrt(T2) # Period of revolution of Moon in days\n", - "\n", - "# Result\n", - "\n", - "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "###Example 8.8 " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Change in Kinetic Energy = 3124485000.0 J\n", - "Change in Potential Energy = 6248970000.0 J\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "m=400 # Mass of satellite in kg\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "g=9.81 # Acceleration due to gravity\n", - "\n", - "# Calculation\n", - "\n", - "# Change in energy is E=Ef-Ei\n", - "ΔE=(g*m*Re)/8 # Change in Total energy\n", - "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", - "ΔV=2*ΔE # Change in Potential Energy in J\n", - "\n", - "# Result\n", - "\n", - "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", - "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation.ipynb b/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation.ipynb deleted file mode 100755 index c08a4250..00000000 --- a/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation.ipynb +++ /dev/null @@ -1,390 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.2 , page : 187" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", - "(b) The force acting = 2 Gm²\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", - "y=math.radians(x) # The angle in radians\n", - "a=math.cos(y)\n", - "b=math.sin(y)\n", - "v1=(0,1,0)\n", - "v2=(-a,-b,0)\n", - "v3=(a,-b,0)\n", - "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", - "\n", - "# Calculation\n", - "\n", - "#(a)\n", - "F1=[y * c for y in v1] # F(GA)\n", - "F2=[y * c for y in v2] # F(GB)\n", - "F3=[y * c for y in v3] # F(GC)\n", - "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", - "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", - "\n", - "#(b)\n", - "# By symmetry the x-component of the force cancels out and the y-component survives\n", - "Fb=4-2 # 4Gm² j - 2Gm² j\n", - "\n", - "# Result\n", - "\n", - "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", - "print(\"(b) The force acting =\",Fb,\"Gm²\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.3 , page : 192" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", - "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "l=1 # For convenience,side of the square is assumed to be unity \n", - "c=(G*pow(m,2))/l\n", - "n=4 # Number of particles\n", - "\n", - "# Calculation\n", - "\n", - "d=math.sqrt(2)\n", - "# If the side of a square is l then the diagonal distance is √2l\n", - "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", - "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", - "w=(-n-(2/d)) \n", - "# If the side of a square is l then the diagonal distance from the centre to corner is \n", - "# Since the Gravitational Potential at the centre of the square\n", - "u=-n*(2/d)\n", - "\n", - "# Result\n", - "\n", - "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", - "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.4 , page : 193" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", - "M=1 # For convenience,mass is assumed to be unity \n", - "m1=M # Mass of the first sphere\n", - "m2=6*M # Mass of the second sphere\n", - "m=1 # Since the mass of the projectile is unknown,take it as unity\n", - "d=6*R # Distance between the centres of both the spheres\n", - "r=1 # The distance from the centre of first sphere to the neutral point N\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "\n", - "# Calculation\n", - "\n", - "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", - "r=2*R\n", - "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", - "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", - "# From the principle of conservation of mechanical energy; Et = En and we get\n", - "v_sqr=2*((4/5)-(1/2))\n", - "\n", - "# Result\n", - "\n", - "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.5 , page : 195" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i) Mass of Mars = 6.475139697520706e+23 kg\n", - "(ii) Period of revolution of Mars = 684.0033777694376 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "π=3.14 # Constant pi\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", - "T=459*60\n", - "Te=365 # Period of revolution of Earth\n", - "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", - "\n", - "# Calculation\n", - "\n", - "# (i) \n", - "R=R*pow(10,3)\n", - "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", - "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", - "\n", - "# (ii)\n", - "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", - "Tm=pow(r,(3/2))*365\n", - "\n", - "\n", - "# Result\n", - "\n", - "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", - "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.6 , page : 195" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Mass of the Earth = 5.967906881559221e+24 kg\n", - "Mass of the Earth = 6.017752855396305e+24 kg\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "g=9.81 # Acceleration due to gravity\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", - "T=27.3 # Period of revolution of Moon in days\n", - "π=3.14 # Constant pi\n", - "\n", - "# Calculation\n", - "\n", - "# I Method\n", - "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", - "Me1=(g*pow(Re,2))/G\n", - "\n", - "# II Method\n", - "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", - "T1=T*24*60*60\n", - "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", - "\n", - "#Result\n", - "\n", - "print(\"Mass of the Earth =\",Me1,\"kg\")\n", - "print(\"Mass of the Earth =\",Me2,\"kg\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.7 , page : 195 " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Period of revolution of Moon = 27.5 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "k=pow(10,-13) # A constant = 4π² / GME\n", - "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", - "\n", - "# Calculation\n", - "\n", - "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", - "T2=k*pow(Re,3)\n", - "T=math.sqrt(T2) # Period of revolution of Moon in days\n", - "\n", - "# Result\n", - "\n", - "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.8 , page : 196 " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Change in Kinetic Energy = 3124485000.0 J\n", - "Change in Potential Energy = 6248970000.0 J\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "m=400 # Mass of satellite in kg\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "g=9.81 # Acceleration due to gravity\n", - "\n", - "# Calculation\n", - "\n", - "# Change in energy is E=Ef-Ei\n", - "ΔE=(g*m*Re)/8 # Change in Total energy\n", - "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", - "ΔV=2*ΔE # Change in Potential Energy in J\n", - "\n", - "# Result\n", - "\n", - "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", - "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation_1.ipynb b/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation_1.ipynb deleted file mode 100755 index c08a4250..00000000 --- a/sample_notebooks/AdityaAnand/Chapter_8_-_Gravitation_1.ipynb +++ /dev/null @@ -1,390 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.2 , page : 187" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The force acting = [0.0, 2.5849394142282115e-26, 0.0] ≈ 0\n", - "(b) The force acting = 2 Gm²\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "x=30 # The angle between GC and the positive x-axis is 30° and so is the angle between GB and the negative x-axis\n", - "y=math.radians(x) # The angle in radians\n", - "a=math.cos(y)\n", - "b=math.sin(y)\n", - "v1=(0,1,0)\n", - "v2=(-a,-b,0)\n", - "v3=(a,-b,0)\n", - "c=(2*G*pow(m,2))/1 # 2Gm²/1\n", - "\n", - "# Calculation\n", - "\n", - "#(a)\n", - "F1=[y * c for y in v1] # F(GA)\n", - "F2=[y * c for y in v2] # F(GB)\n", - "F3=[y * c for y in v3] # F(GC)\n", - "# From the principle of superposition and the law of vector addition, the resultant gravitational force FR on (2m) is given by\n", - "Fa=[sum(x) for x in zip(F1,F2,F3)]\n", - "\n", - "#(b)\n", - "# By symmetry the x-component of the force cancels out and the y-component survives\n", - "Fb=4-2 # 4Gm² j - 2Gm² j\n", - "\n", - "# Result\n", - "\n", - "print(\"(a) The force acting =\",Fa,\"≈ 0\")\n", - "print(\"(b) The force acting =\",Fb,\"Gm²\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.3 , page : 192" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Potential energy of a system of four particles = -5.414213562373095 Gm²/l\n", - "The gravitational potential at the centre of the square = -5.65685424949238 Gm²/l\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "m=1 # For convenience,mass is assumed to be unity \n", - "l=1 # For convenience,side of the square is assumed to be unity \n", - "c=(G*pow(m,2))/l\n", - "n=4 # Number of particles\n", - "\n", - "# Calculation\n", - "\n", - "d=math.sqrt(2)\n", - "# If the side of a square is l then the diagonal distance is √2l\n", - "# We have four mass pairs at distance l and two diagonal pairs at distance √2l \n", - "# Since the Potential Energy of a system of four particles is -4Gm²/l) - 2Gm²/dl\n", - "w=(-n-(2/d)) \n", - "# If the side of a square is l then the diagonal distance from the centre to corner is \n", - "# Since the Gravitational Potential at the centre of the square\n", - "u=-n*(2/d)\n", - "\n", - "# Result\n", - "\n", - "print (\"Potential energy of a system of four particles =\",w,\"Gm²/l\")\n", - "print(\"The gravitational potential at the centre of the square =\",u,\"Gm²/l\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.4 , page : 193" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum speed of the projectile to reach the surface of the second sphere = ( 0.6 GM/R ) ^(1/2)\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "R=1 # For convenience,radii of both the spheres is assumed to be unity \n", - "M=1 # For convenience,mass is assumed to be unity \n", - "m1=M # Mass of the first sphere\n", - "m2=6*M # Mass of the second sphere\n", - "m=1 # Since the mass of the projectile is unknown,take it as unity\n", - "d=6*R # Distance between the centres of both the spheres\n", - "r=1 # The distance from the centre of first sphere to the neutral point N\n", - "\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "\n", - "# Calculation\n", - "\n", - "# Since N is the neutral point; GMm/r² = 4GMm/(6R-r)² and we get\n", - "r=2*R\n", - "# The mechanical energy at the surface of M is; Et = m(v^2)/2 - GMm/R - 4GMm/5R\n", - "# The mechanical energy at N is; En = -GMm/2R - 4GMm/4R\n", - "# From the principle of conservation of mechanical energy; Et = En and we get\n", - "v_sqr=2*((4/5)-(1/2))\n", - "\n", - "# Result\n", - "\n", - "print(\"Minimum speed of the projectile to reach the surface of the second sphere =\",\"(\",round(v_sqr,5),\"GM/R\",\")\",\"^(1/2)\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.5 , page : 195" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i) Mass of Mars = 6.475139697520706e+23 kg\n", - "(ii) Period of revolution of Mars = 684.0033777694376 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "π=3.14 # Constant pi\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "R=9.4*pow(10,3) # Orbital radius of Mars in km\n", - "T=459*60\n", - "Te=365 # Period of revolution of Earth\n", - "r=1.52 # Ratio of Rms/Res, where Rms is the mars-sun distance and Res is the earth-sun distance. \n", - "\n", - "# Calculation\n", - "\n", - "# (i) \n", - "R=R*pow(10,3)\n", - "# Using Kepler's 3rd law:T²=4π²(R^3)/GMm\n", - "Mm=(4*pow(π,2)*pow(R,3))/(G*pow(T,2))\n", - "\n", - "# (ii)\n", - "# Using Kepler's 3rd law: Tm²/Te² = (Rms^3/Res^3)\n", - "Tm=pow(r,(3/2))*365\n", - "\n", - "\n", - "# Result\n", - "\n", - "print(\"(i) Mass of Mars =\",Mm,\"kg\")\n", - "print(\"(ii) Period of revolution of Mars =\",Tm,\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.6 , page : 195" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Mass of the Earth = 5.967906881559221e+24 kg\n", - "Mass of the Earth = 6.017752855396305e+24 kg\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "g=9.81 # Acceleration due to gravity\n", - "G=6.67*pow(10,-11) # Gravitational constant\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "R=3.84*pow(10,8) # Distance of Moon from Earth in m\n", - "T=27.3 # Period of revolution of Moon in days\n", - "π=3.14 # Constant pi\n", - "\n", - "# Calculation\n", - "\n", - "# I Method\n", - "# Using Newton's 2nd law of motion:g = F/m = GMe/Re²\n", - "Me1=(g*pow(Re,2))/G\n", - "\n", - "# II Method\n", - "# Using Kepler's 3rd law: T²= 4π²(R^3)/GMe\n", - "T1=T*24*60*60\n", - "Me2=(4*pow(π,2)*pow(R,3))/(G*pow(T1,2))\n", - "\n", - "#Result\n", - "\n", - "print(\"Mass of the Earth =\",Me1,\"kg\")\n", - "print(\"Mass of the Earth =\",Me2,\"kg\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.7 , page : 195 " - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Period of revolution of Moon = 27.5 days\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "k=pow(10,-13) # A constant = 4π² / GME\n", - "Re=3.84*pow(10,5) # Distance of the Moon from the Earth in m\n", - "\n", - "# Calculation\n", - "\n", - "k=pow(10,-13)*(pow(1/(24*60*60),2))*(1/pow((1/1000),3))\n", - "T2=k*pow(Re,3)\n", - "T=math.sqrt(T2) # Period of revolution of Moon in days\n", - "\n", - "# Result\n", - "\n", - "print(\"Period of revolution of Moon =\",round(T,1),\"days\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.8 , page : 196 " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Change in Kinetic Energy = 3124485000.0 J\n", - "Change in Potential Energy = 6248970000.0 J\n" - ] - } - ], - "source": [ - "# Importing module\n", - "\n", - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "m=400 # Mass of satellite in kg\n", - "Re=6.37*pow(10,6) # Radius of Earth in m\n", - "g=9.81 # Acceleration due to gravity\n", - "\n", - "# Calculation\n", - "\n", - "# Change in energy is E=Ef-Ei\n", - "ΔE=(g*m*Re)/8 # Change in Total energy\n", - "# Since Potential Energy is twice as the change in Total Energy (V = Vf - Vi)\n", - "ΔV=2*ΔE # Change in Potential Energy in J\n", - "\n", - "# Result\n", - "\n", - "print(\"Change in Kinetic Energy =\",round(ΔE,4),\"J\")\n", - "print(\"Change in Potential Energy =\",round(ΔV,4),\"J\")" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AdityaR/AdityaR_version_backup/Chapter_5-Sample.ipynb b/sample_notebooks/AdityaR/AdityaR_version_backup/Chapter_5-Sample.ipynb new file mode 100755 index 00000000..a77ec491 --- /dev/null +++ b/sample_notebooks/AdityaR/AdityaR_version_backup/Chapter_5-Sample.ipynb @@ -0,0 +1,279 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5 General Case of Forces in a plane" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 5.2 Equations of equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('The reaction at P is', 5656.85424949238, 'N')\n", + "('The reaction at Q is ', 4000.0, 'N')\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Initialization of Variables\n", + "W=2000 #N\n", + "Lab=2 #m #length of the member from the vertical to the 1st load of 2000 N\n", + "Lac=5 #m #length of the member from the vertical to the 2nd load of 2000 N\n", + "Lpq=3.5 #m\n", + "\n", + "#Calculations\n", + "Rq=((W*Lab)+(W*Lac))/Lpq #N #take moment abt. pt P\n", + "Xp=Rq #N #sum Fx=0\n", + "Yp=2*W #N #sum Fy=0\n", + "Rp=math.sqrt(Xp**2+Yp**2) #N\n", + "\n", + "#Resuts\n", + "print('The reaction at P is' ,Rp ,'N')\n", + "print('The reaction at Q is ',Rq ,'N')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 5.3 Equations of equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('The reaction at A i.e Ra is ', matrix([[ 120.27406887]]), 'N')\n", + "('The reaction at B i.e Rb is ', matrix([[ 35.13703443]]), 'N')\n", + "('The required tension in the string is ', matrix([[ 40.57275258]]), 'N')\n" + ] + } + ], + "source": [ + "import math,numpy\n", + "#Initilization of vaiables\n", + "W=25 #N # self weight of the ladder\n", + "M=75 #N # weight of the man standing o the ladder\n", + "theta=63.43 #degree # angle which the ladder makes with the horizontal\n", + "alpha=30 #degree # angle made by the string with the horizontal\n", + "Loa=2 #m # spacing between the wall and the ladder\n", + "Lob=4 #m #length from the horizontal to the top of the ladder touching the wall(vertical)\n", + "\n", + "#Calculations\n", + "#Using matrix to solve the simultaneous eqn's 3 & 4\n", + "A=numpy.matrix('2 -4; 1 -0.577')\n", + "B=numpy.matrix('100;100')\n", + "C=numpy.linalg.inv(A)*B\n", + "\n", + "#Results\n", + "print('The reaction at A i.e Ra is ',C[0] ,'N')\n", + "print('The reaction at B i.e Rb is ',C[1] ,'N')\n", + "\n", + "#Calculations\n", + "T=C[1]/math.cos(math.radians(alpha)) #N # from (eqn 1)\n", + "\n", + "#Results\n", + "print('The required tension in the string is ',T, 'N')" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 5.4 Equations of Equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('The reaction at B i.e Rb is ', 25.0, 'N')\n", + "('The horizontal reaction at A i.e Xa is ', 21.650635094610966, 'N')\n", + "('The vertical reaction at A i.e Ya is ', 112.5, 'N')\n" + ] + } + ], + "source": [ + "import math\n", + "#Initilization of variables\n", + "W=100 #N\n", + "theta=60 #degree angle made by the ladder with the horizontal\n", + "alpha=30 #degree angle made by the ladder with the vertical wall\n", + "Lob=4 #m length from the horizontal to the top of the ladder touching the wall(vertical)\n", + "Lcd=2 #m length from the horizontal to the centre of the ladder where the man stands\n", + "\n", + "#Calculations\n", + "Lab=Lob*(1/math.cos(math.radians(alpha))) #m length of the ladder\n", + "Lad=Lcd*math.tan(math.radians(alpha)) #m\n", + "Rb=(W*Lad)/Lab #N take moment at A\n", + "Xa=Rb*math.sin(math.radians(theta)) #N From eq'n 1\n", + "Ya=W+Rb*math.cos(math.radians(theta)) #N From eq'n 2\n", + "\n", + "#Results\n", + "print('The reaction at B i.e Rb is ',Rb, 'N')\n", + "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", + "print('The vertical reaction at A i.e Ya is ',Ya,'N')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 5.5 Equations of Equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('The horizontal reaction at A i.e Xa is ', 28.867513459481287, 'N')\n", + "('The vertical reaction at A i.e Ya is ', 100, 'N')\n", + "('The reaction at B i.e Rb is ', 28.867513459481287, 'N')\n" + ] + } + ], + "source": [ + "import math\n", + "#Initilization of variables\n", + "W=100 #N self weight of the man\n", + "alpha=30 #degree angle made by the ladder with the wall\n", + "Lob=4 #m length from the horizontal to the top of the ladder touching the wall(vertical)\n", + "Lcd=2 #m\n", + "\n", + "#Calculations\n", + "# using the equiblirium equations\n", + "Ya=W #N From eq'n 2\n", + "Lad=Lcd*math.tan(math.radians(alpha)) #m Lad is the distance fom pt A to the point where the line from the cg intersects the horizontal\n", + "Rb=(W*Lad)/Lob #N Taking sum of moment abt A\n", + "Xa=Rb #N From eq'n 1\n", + "\n", + "#Results\n", + "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", + "print('The vertical reaction at A i.e Ya is ',Ya,'N' )\n", + "print('The reaction at B i.e Rb is ',Rb ,'N')\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 5.6 Equations of Equilibrium" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('The horizontal reaction at A i.e Xa is ', 3.84, 'N')\n", + "('The vertical reaction at A i.e Ya is ', 7.12, 'N')\n", + "('Therefore the reaction at A i.e Ra is ', 8.089499366462674, 'N')\n", + "('The reaction at D i.e Rd is ', 4.8, 'N')\n" + ] + } + ], + "source": [ + "import math\n", + "#Initilization of variables\n", + "d=0.09 #m diametre of the right circular cylinder\n", + "h=0.12 #m height of the cyinder\n", + "W=10 #N self weight of the bar\n", + "l=0.24 #m length of the bar\n", + "\n", + "#Calculations\n", + "theta=math.degrees(math.atan(h/d)) #angle which the bar makes with the horizontal\n", + "Lad=math.sqrt(d**2+h**2) #m Lad is the length of the bar from point A to point B\n", + "Rd=(W*h*(math.cos(theta*math.pi/180)))/Lad #N Taking moment at A\n", + "Xa=Rd*(math.sin(theta*math.pi/180)) #N sum Fx=0.... From eq'n 1\n", + "Ya=W-(Rd*(math.cos(theta*math.pi/180))) #N sum Fy=0..... From eq'n 2\n", + "Ra=math.sqrt(Xa**2+Ya**2) #resultant of Xa & Ya\n", + "\n", + "#Results\n", + "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", + "print('The vertical reaction at A i.e Ya is ',Ya, 'N')\n", + "print('Therefore the reaction at A i.e Ra is ',Ra,'N')\n", + "print('The reaction at D i.e Rd is ',Rd,'N')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + }, + "widgets": { + "state": {}, + "version": "1.1.2" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AdityaR/Chapter_5-Sample_Notebook.ipynb b/sample_notebooks/AdityaR/Chapter_5-Sample_Notebook.ipynb deleted file mode 100755 index a77ec491..00000000 --- a/sample_notebooks/AdityaR/Chapter_5-Sample_Notebook.ipynb +++ /dev/null @@ -1,279 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 5 General Case of Forces in a plane" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 5.2 Equations of equilibrium" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('The reaction at P is', 5656.85424949238, 'N')\n", - "('The reaction at Q is ', 4000.0, 'N')\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Initialization of Variables\n", - "W=2000 #N\n", - "Lab=2 #m #length of the member from the vertical to the 1st load of 2000 N\n", - "Lac=5 #m #length of the member from the vertical to the 2nd load of 2000 N\n", - "Lpq=3.5 #m\n", - "\n", - "#Calculations\n", - "Rq=((W*Lab)+(W*Lac))/Lpq #N #take moment abt. pt P\n", - "Xp=Rq #N #sum Fx=0\n", - "Yp=2*W #N #sum Fy=0\n", - "Rp=math.sqrt(Xp**2+Yp**2) #N\n", - "\n", - "#Resuts\n", - "print('The reaction at P is' ,Rp ,'N')\n", - "print('The reaction at Q is ',Rq ,'N')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 5.3 Equations of equilibrium" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('The reaction at A i.e Ra is ', matrix([[ 120.27406887]]), 'N')\n", - "('The reaction at B i.e Rb is ', matrix([[ 35.13703443]]), 'N')\n", - "('The required tension in the string is ', matrix([[ 40.57275258]]), 'N')\n" - ] - } - ], - "source": [ - "import math,numpy\n", - "#Initilization of vaiables\n", - "W=25 #N # self weight of the ladder\n", - "M=75 #N # weight of the man standing o the ladder\n", - "theta=63.43 #degree # angle which the ladder makes with the horizontal\n", - "alpha=30 #degree # angle made by the string with the horizontal\n", - "Loa=2 #m # spacing between the wall and the ladder\n", - "Lob=4 #m #length from the horizontal to the top of the ladder touching the wall(vertical)\n", - "\n", - "#Calculations\n", - "#Using matrix to solve the simultaneous eqn's 3 & 4\n", - "A=numpy.matrix('2 -4; 1 -0.577')\n", - "B=numpy.matrix('100;100')\n", - "C=numpy.linalg.inv(A)*B\n", - "\n", - "#Results\n", - "print('The reaction at A i.e Ra is ',C[0] ,'N')\n", - "print('The reaction at B i.e Rb is ',C[1] ,'N')\n", - "\n", - "#Calculations\n", - "T=C[1]/math.cos(math.radians(alpha)) #N # from (eqn 1)\n", - "\n", - "#Results\n", - "print('The required tension in the string is ',T, 'N')" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 5.4 Equations of Equilibrium" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('The reaction at B i.e Rb is ', 25.0, 'N')\n", - "('The horizontal reaction at A i.e Xa is ', 21.650635094610966, 'N')\n", - "('The vertical reaction at A i.e Ya is ', 112.5, 'N')\n" - ] - } - ], - "source": [ - "import math\n", - "#Initilization of variables\n", - "W=100 #N\n", - "theta=60 #degree angle made by the ladder with the horizontal\n", - "alpha=30 #degree angle made by the ladder with the vertical wall\n", - "Lob=4 #m length from the horizontal to the top of the ladder touching the wall(vertical)\n", - "Lcd=2 #m length from the horizontal to the centre of the ladder where the man stands\n", - "\n", - "#Calculations\n", - "Lab=Lob*(1/math.cos(math.radians(alpha))) #m length of the ladder\n", - "Lad=Lcd*math.tan(math.radians(alpha)) #m\n", - "Rb=(W*Lad)/Lab #N take moment at A\n", - "Xa=Rb*math.sin(math.radians(theta)) #N From eq'n 1\n", - "Ya=W+Rb*math.cos(math.radians(theta)) #N From eq'n 2\n", - "\n", - "#Results\n", - "print('The reaction at B i.e Rb is ',Rb, 'N')\n", - "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", - "print('The vertical reaction at A i.e Ya is ',Ya,'N')\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 5.5 Equations of Equilibrium" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('The horizontal reaction at A i.e Xa is ', 28.867513459481287, 'N')\n", - "('The vertical reaction at A i.e Ya is ', 100, 'N')\n", - "('The reaction at B i.e Rb is ', 28.867513459481287, 'N')\n" - ] - } - ], - "source": [ - "import math\n", - "#Initilization of variables\n", - "W=100 #N self weight of the man\n", - "alpha=30 #degree angle made by the ladder with the wall\n", - "Lob=4 #m length from the horizontal to the top of the ladder touching the wall(vertical)\n", - "Lcd=2 #m\n", - "\n", - "#Calculations\n", - "# using the equiblirium equations\n", - "Ya=W #N From eq'n 2\n", - "Lad=Lcd*math.tan(math.radians(alpha)) #m Lad is the distance fom pt A to the point where the line from the cg intersects the horizontal\n", - "Rb=(W*Lad)/Lob #N Taking sum of moment abt A\n", - "Xa=Rb #N From eq'n 1\n", - "\n", - "#Results\n", - "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", - "print('The vertical reaction at A i.e Ya is ',Ya,'N' )\n", - "print('The reaction at B i.e Rb is ',Rb ,'N')\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 5.6 Equations of Equilibrium" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('The horizontal reaction at A i.e Xa is ', 3.84, 'N')\n", - "('The vertical reaction at A i.e Ya is ', 7.12, 'N')\n", - "('Therefore the reaction at A i.e Ra is ', 8.089499366462674, 'N')\n", - "('The reaction at D i.e Rd is ', 4.8, 'N')\n" - ] - } - ], - "source": [ - "import math\n", - "#Initilization of variables\n", - "d=0.09 #m diametre of the right circular cylinder\n", - "h=0.12 #m height of the cyinder\n", - "W=10 #N self weight of the bar\n", - "l=0.24 #m length of the bar\n", - "\n", - "#Calculations\n", - "theta=math.degrees(math.atan(h/d)) #angle which the bar makes with the horizontal\n", - "Lad=math.sqrt(d**2+h**2) #m Lad is the length of the bar from point A to point B\n", - "Rd=(W*h*(math.cos(theta*math.pi/180)))/Lad #N Taking moment at A\n", - "Xa=Rd*(math.sin(theta*math.pi/180)) #N sum Fx=0.... From eq'n 1\n", - "Ya=W-(Rd*(math.cos(theta*math.pi/180))) #N sum Fy=0..... From eq'n 2\n", - "Ra=math.sqrt(Xa**2+Ya**2) #resultant of Xa & Ya\n", - "\n", - "#Results\n", - "print('The horizontal reaction at A i.e Xa is ',Xa, 'N')\n", - "print('The vertical reaction at A i.e Ya is ',Ya, 'N')\n", - "print('Therefore the reaction at A i.e Ra is ',Ra,'N')\n", - "print('The reaction at D i.e Rd is ',Rd,'N')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - }, - "widgets": { - "state": {}, - "version": "1.1.2" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler.ipynb b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler.ipynb new file mode 100755 index 00000000..51134ef9 --- /dev/null +++ b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler.ipynb @@ -0,0 +1,231 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:ef32575f9668e7c75384fec9d19e3d17f6260e600de2d26c9157520e2a39253b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 1 : MOLE BALANCES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "k = 0.23; #min**-1\n", + "v0 = 10;#dm**3/min\n", + "#CA = 0.1*CA0;\n", + "V = (v0/k)*math.log(1/0.1);\n", + "print \"V =\",round(V,4),\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "V = 100.1124 dm**3\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "CA0 = 0.1444 mol/dm**3\n", + "FA0 = 0.8665 mol/s\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = 0.8;\n", + "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "V = FA0*X*(1/-rA)\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", + "print \"V =\",round(V,4),\"dm**3\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.8665 mol/s\n", + "V = 0.6932 dm**3\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", + "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "#V = FA0*X*(1/-rA)\n", + "\n", + "V = FA0*np.interp(0.42,X,p)\n", + "print \"FA0 =\",FA0,\"mol/s\"\n", + "print \"V =\",V,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.866541114487 mol/s\n", + "V = 225.820614435 dm**3\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "FA0 = 5; # mol/s\n", + "rAat=-0.0025;\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", + "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", + "\n", + "VCSTR = FA0*X[6]*(1/-rAat);\n", + "VPFR = FA0*np.interp(0.00017,X,p)\n", + "print \"VCSTR =\",VCSTR,\"dm**3\"\n", + "print \"VPFR =\",VPFR,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VCSTR = 1200.0 dm**3\n", + "VPFR = 945.0255 dm**3\n" + ] + } + ], + "prompt_number": 37 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED.ipynb b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED.ipynb new file mode 100755 index 00000000..a2bda001 --- /dev/null +++ b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED.ipynb @@ -0,0 +1,231 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:37859c50b0a22beb7e2005b729edef7d0375ee40d0e34f554e83e84af89eab44" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 1 : MOLE BALANCES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.3 : PAGE NUMBER 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "k = 0.23; #min**-1\n", + "v0 = 10;#dm**3/min\n", + "#CA = 0.1*CA0;\n", + "V = (v0/k)*math.log(1/0.1);\n", + "print \"V =\",round(V,4),\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "V = 100.1124 dm**3\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.1 : PAGE NUMBER 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "CA0 = 0.1444 mol/dm**3\n", + "FA0 = 0.8665 mol/s\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.2 : PAGE NUMBER 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = 0.8;\n", + "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "V = FA0*X*(1/-rA)\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", + "print \"V =\",round(V,4),\"dm**3\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.8665 mol/s\n", + "V = 0.6932 dm**3\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.3 : PAGE NUMBER 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", + "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "#V = FA0*X*(1/-rA)\n", + "\n", + "V = FA0*np.interp(0.42,X,p)\n", + "print \"FA0 =\",FA0,\"mol/s\"\n", + "print \"V =\",V,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.866541114487 mol/s\n", + "V = 225.820614435 dm**3\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.4 : PAGE NUMBER 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "FA0 = 5; # mol/s\n", + "rAat=-0.0025;\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", + "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", + "\n", + "VCSTR = FA0*X[6]*(1/-rAat);\n", + "VPFR = FA0*np.interp(0.00017,X,p)\n", + "print \"VCSTR =\",VCSTR,\"dm**3\"\n", + "print \"VPFR =\",VPFR,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VCSTR = 1200.0 dm**3\n", + "VPFR = 945.0255 dm**3\n" + ] + } + ], + "prompt_number": 37 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED_(1).ipynb b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED_(1).ipynb new file mode 100755 index 00000000..2b950ef8 --- /dev/null +++ b/sample_notebooks/AjaySatish/AjaySatish_version_backup/Sample.S._Fogler_UPDATED_(1).ipynb @@ -0,0 +1,191 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:6aa7321c51ecc68ee01a5bb4aa554a936a01c87ebd6725c56b8e0edb6adbcf78" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.1 : PAGE NUMBER 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " \n", + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "CA0 = 0.1444 mol/dm**3\n", + "FA0 = 0.8665 mol/s\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.2 : PAGE NUMBER 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = 0.8;\n", + "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "V = FA0*X*(1/-rA)\n", + "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", + "print \"V =\",round(V,4),\"dm**3\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.8665 mol/s\n", + "V = 0.6932 dm**3\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.3 : PAGE NUMBER 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + "P0 = 10; #atm\n", + "yA0 = 0.5;\n", + "T0 = 422.2;#K\n", + "R = 0.082;# dm**3.atm/mol.K\n", + "v0 = 6;#dm**3/s\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", + "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", + "CA0=(yA0*P0)/(R*T0);\n", + "FA0 = CA0*v0;\n", + "#V = FA0*X*(1/-rA)\n", + "\n", + "V = FA0*np.interp(0.42,X,p)\n", + "print \"FA0 =\",FA0,\"mol/s\"\n", + "print \"V =\",V,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "FA0 = 0.866541114487 mol/s\n", + "V = 225.820614435 dm**3\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.4 : PAGE NUMBER 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "FA0 = 5; # mol/s\n", + "rAat=-0.0025;\n", + "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", + "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", + "\n", + "VCSTR = FA0*X[6]*(1/-rAat);\n", + "VPFR = FA0*np.interp(0.00017,X,p)\n", + "print \"VCSTR =\",VCSTR,\"dm**3\"\n", + "print \"VPFR =\",VPFR,\"dm**3\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VCSTR = 1200.0 dm**3\n", + "VPFR = 945.0255 dm**3\n" + ] + } + ], + "prompt_number": 37 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AjaySatish/Sample_H.S._Fogler.ipynb b/sample_notebooks/AjaySatish/Sample_H.S._Fogler.ipynb deleted file mode 100755 index 51134ef9..00000000 --- a/sample_notebooks/AjaySatish/Sample_H.S._Fogler.ipynb +++ /dev/null @@ -1,231 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:ef32575f9668e7c75384fec9d19e3d17f6260e600de2d26c9157520e2a39253b" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 1 : MOLE BALANCES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "k = 0.23; #min**-1\n", - "v0 = 10;#dm**3/min\n", - "#CA = 0.1*CA0;\n", - "V = (v0/k)*math.log(1/0.1);\n", - "print \"V =\",round(V,4),\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "V = 100.1124 dm**3\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " \n", - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "CA0 = 0.1444 mol/dm**3\n", - "FA0 = 0.8665 mol/s\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.2" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = 0.8;\n", - "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "V = FA0*X*(1/-rA)\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", - "print \"V =\",round(V,4),\"dm**3\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.8665 mol/s\n", - "V = 0.6932 dm**3\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", - "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "#V = FA0*X*(1/-rA)\n", - "\n", - "V = FA0*np.interp(0.42,X,p)\n", - "print \"FA0 =\",FA0,\"mol/s\"\n", - "print \"V =\",V,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.866541114487 mol/s\n", - "V = 225.820614435 dm**3\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "FA0 = 5; # mol/s\n", - "rAat=-0.0025;\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", - "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", - "\n", - "VCSTR = FA0*X[6]*(1/-rAat);\n", - "VPFR = FA0*np.interp(0.00017,X,p)\n", - "print \"VCSTR =\",VCSTR,\"dm**3\"\n", - "print \"VPFR =\",VPFR,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "VCSTR = 1200.0 dm**3\n", - "VPFR = 945.0255 dm**3\n" - ] - } - ], - "prompt_number": 37 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED.ipynb b/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED.ipynb deleted file mode 100755 index a2bda001..00000000 --- a/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED.ipynb +++ /dev/null @@ -1,231 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:37859c50b0a22beb7e2005b729edef7d0375ee40d0e34f554e83e84af89eab44" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 1 : MOLE BALANCES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.3 : PAGE NUMBER 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "k = 0.23; #min**-1\n", - "v0 = 10;#dm**3/min\n", - "#CA = 0.1*CA0;\n", - "V = (v0/k)*math.log(1/0.1);\n", - "print \"V =\",round(V,4),\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "V = 100.1124 dm**3\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.1 : PAGE NUMBER 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " \n", - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "CA0 = 0.1444 mol/dm**3\n", - "FA0 = 0.8665 mol/s\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.2 : PAGE NUMBER 42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = 0.8;\n", - "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "V = FA0*X*(1/-rA)\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", - "print \"V =\",round(V,4),\"dm**3\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.8665 mol/s\n", - "V = 0.6932 dm**3\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.3 : PAGE NUMBER 44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", - "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "#V = FA0*X*(1/-rA)\n", - "\n", - "V = FA0*np.interp(0.42,X,p)\n", - "print \"FA0 =\",FA0,\"mol/s\"\n", - "print \"V =\",V,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.866541114487 mol/s\n", - "V = 225.820614435 dm**3\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.4 : PAGE NUMBER 46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "FA0 = 5; # mol/s\n", - "rAat=-0.0025;\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", - "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", - "\n", - "VCSTR = FA0*X[6]*(1/-rAat);\n", - "VPFR = FA0*np.interp(0.00017,X,p)\n", - "print \"VCSTR =\",VCSTR,\"dm**3\"\n", - "print \"VPFR =\",VPFR,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "VCSTR = 1200.0 dm**3\n", - "VPFR = 945.0255 dm**3\n" - ] - } - ], - "prompt_number": 37 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED_(1).ipynb b/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED_(1).ipynb deleted file mode 100755 index 2b950ef8..00000000 --- a/sample_notebooks/AjaySatish/Sample_H.S._Fogler_UPDATED_(1).ipynb +++ /dev/null @@ -1,191 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:6aa7321c51ecc68ee01a5bb4aa554a936a01c87ebd6725c56b8e0edb6adbcf78" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "ELEMENTS OF CHEMICAL ENGINEERING BY H.S. FOGLER" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 2 : CONVERSION AND REACTOR SIZING" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.1 : PAGE NUMBER 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " \n", - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "print \"CA0 =\",round(CA0,4),\"mol/dm**3\"\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "CA0 = 0.1444 mol/dm**3\n", - "FA0 = 0.8665 mol/s\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.2 : PAGE NUMBER 42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = 0.8;\n", - "rA = -1/800;#1/-rA = 800#dm**3.s/mol\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "V = FA0*X*(1/-rA)\n", - "print \"FA0 =\",round(FA0,4),\"mol/s\"\n", - "print \"V =\",round(V,4),\"dm**3\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.8665 mol/s\n", - "V = 0.6932 dm**3\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.3 : PAGE NUMBER 44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - "P0 = 10; #atm\n", - "yA0 = 0.5;\n", - "T0 = 422.2;#K\n", - "R = 0.082;# dm**3.atm/mol.K\n", - "v0 = 6;#dm**3/s\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8];\n", - "p = [189,192,200,222,250,303,400,556,800];#1/-rA = 800#dm**3.s/mols\n", - "CA0=(yA0*P0)/(R*T0);\n", - "FA0 = CA0*v0;\n", - "#V = FA0*X*(1/-rA)\n", - "\n", - "V = FA0*np.interp(0.42,X,p)\n", - "print \"FA0 =\",FA0,\"mol/s\"\n", - "print \"V =\",V,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "FA0 = 0.866541114487 mol/s\n", - "V = 225.820614435 dm**3\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.4 : PAGE NUMBER 46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "FA0 = 5; # mol/s\n", - "rAat=-0.0025;\n", - "X = [0,0.1,0.2,0.3,0.4,0.5,0.6];\n", - "p = [189,192,200,222,250,303,400];#1/-rA = 800#dm**3.s/mols\n", - "\n", - "VCSTR = FA0*X[6]*(1/-rAat);\n", - "VPFR = FA0*np.interp(0.00017,X,p)\n", - "print \"VCSTR =\",VCSTR,\"dm**3\"\n", - "print \"VPFR =\",VPFR,\"dm**3\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "VCSTR = 1200.0 dm**3\n", - "VPFR = 945.0255 dm**3\n" - ] - } - ], - "prompt_number": 37 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Akshay Ghogare/AKSHAY_GHOGARE.ipynb b/sample_notebooks/Akshay Ghogare/AKSHAY_GHOGARE.ipynb deleted file mode 100755 index fa395760..00000000 --- a/sample_notebooks/Akshay Ghogare/AKSHAY_GHOGARE.ipynb +++ /dev/null @@ -1,249 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:4b26d5a062c7df178b102bcb49ca0f8363642f2c290f44d66b774e90f3dc8f59" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "SAMPLE EXAMPLE 1" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 2.18.1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "W1=12.5;#CaCO3 in water in mg/lit#\n", - "W2=8.4;#MgCO3 in water in mg/lit#\n", - "W3=22.2;#CaCl2 in water in mg/lit#\n", - "W4=9.5;#MgCl2 in water in mg/lit#\n", - "W5=33;#CO2 in water in mg/lit#\n", - "W6=6.68;#NaHCO3 in water in mg/lit#\n", - "M1=100.0/100.0;#multiplication factor of CaCO3#\n", - "M2=100.0/84;#multiplication factor of MgCO3#\n", - "M3=100.0/111;#multiplication factor of CaCl2#\n", - "M4=100.0/95;#multiplication factor of MgCl2#\n", - "M6=100.0/84;#multiplication factor of NaHCO3#\n", - "P1=W1*M1;#CaCO3 in terms of CaCO3#\n", - "P2=W2*M2;#MgCO3 in terms of CaCO3#\n", - "P3=W3*M3;#CaCl2 in terms of CaCO3#\n", - "P4=W4*M4;#MgCl2 in terms of CaCO3#\n", - "P6=W6*M6;#NaHCO3 in terms of CaCO3#\n", - "print\"We do not take CO2 since it does not contribute to hardness \" ;\n", - "C=P1+P2+P6;\n", - "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", - "NC=P3+P4;\n", - "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "We do not take CO2 since it does not contribute to hardness \n", - " Carbonate hardness is 30.4523809524 mg/l or ppm\n", - " Non Carbonate hardness is 30.0 mg/l or ppm\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 2.18.2" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "W1=40.5;\n", - "W2=33.3;\n", - "W3=41;\n", - "W4=101;\n", - "W5=33.6;\n", - "M1=100.0/162;\n", - "M2=100.0/111;\n", - "M3=100.0/164;\n", - "M5=100.0/84;\n", - "P1=W1*M1;\n", - "P2=W2*M2;\n", - "P3=W3*M3;\n", - "P5=W5*M5;\n", - "print \"We do not take KNO3 since it does not contribute to hardness \"\n", - "C=P1+P5;\n", - "print \"Carbonate hardness is\",C,\" mg/l or ppm\"\n", - "NC=P2+P3;\n", - "print \"Non Carbonate hardness is\",NC,\" mg/l or ppm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "We do not take KNO3 since it does not contribute to hardness \n", - "Carbonate hardness is 65.0 mg/l or ppm\n", - "Non Carbonate hardness is 55.0 mg/l or ppm\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 2.18.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "W1=29.1;#Mg(HCO3 2 in water in mg/lit#\n", - "W2=40.5;#Ca(HCO3 2 in water in mg/lit#\n", - "W3=11.1;#CaCl2 in water in mg/lit#\n", - "W4=15.82;#MgCl2 in water in mg/lit#\n", - "W5=28.5;#NaCl in water in mg/lit#\n", - "W6=22.0;#CO2 in water in mg/lit#\n", - "M1=100.0/146.007;#multiplication factor of Mg(HCO3 2#\n", - "M2=100.0/162;#multiplication factor of Ca(HCO3 2#\n", - "M3=100.0/111;#multiplication factor of CaCl2#\n", - "M4=100.0/95.005;#multiplication factor of MgCl2#\n", - "P1=W1*M1;#Mg(HCO3 2 in terms of CaCO3#\n", - "P2=W2*M2;#Ca(HCO3 2 in terms of CaCO3#\n", - "P3=W3*M3;#CaCl2 in terms of CaCO3#\n", - "P4=W4*M4;#MgCl2 in terms of CaCO3#\n", - "print\"We do not take NaCl and CO2 since they do not contribute to hardness \" ;\n", - "C=P1+P2;\n", - "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", - "NC=P3+P4;\n", - "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 2.18.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "W1=16.2;#Ca(HCO3 2 in water in mg/lit#\n", - "W2=14.6;#Mg(HCO3 2 in water in mg/lit#\n", - "W3=9.5;#MgCl2 in water in mg/lit#\n", - "W4=48;#MgSO4 in water in mg/lit#\n", - "W5=12;#KCl in water in mg/lit#\n", - "M1=100.0/162;#multiplication factor of Ca(HCO3 2#\n", - "M2=100.0/146;#multiplication factor of Mg(HCO3 2 #\n", - "M3=100.0/95;#multiplication factor of MgCl2#\n", - "M4=100.0/120;#multiplication factor of MgSO4#\n", - "P1=W1*M1;#Ca(HCO3 2 in terms of CaCO3#\n", - "P2=W2*M2;#Mg(HCO3 2 in terms of CaCO3#\n", - "P3=W3*M3;#MgCl2 in terms of CaCO3#\n", - "P4=W4*M4;#MgSO4 in terms of CaCO3#\n", - "print\"We do not take KCl since it does not contribute to hardness \" ;\n", - "C=P1+P2;\n", - "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", - "NC=P3+P4;\n", - "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 2.18.5" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "W1=16.2;#Ca(HCO3 2 in water in mg/lit#\n", - "W2=14.6;#Mg(HCO3 2 in water in mg/lit#\n", - "W3=9.5;#MgCl2 in water in mg/lit#\n", - "W4=48;#MgSO4 in water in mg/lit#\n", - "W5=12;#KCl in water in mg/lit#\n", - "M1=100.0/162;#multiplication factor of Ca(HCO3 2#\n", - "M2=100.0/146;#multiplication factor of Mg(HCO3 2 #\n", - "M3=100.0/95;#multiplication factor of MgCl2#\n", - "M4=100.0/120;#multiplication factor of MgSO4#\n", - "P1=W1*M1;#Ca(HCO3 2 in terms of CaCO3#\n", - "P2=W2*M2;#Mg(HCO3 2 in terms of CaCO3#\n", - "P3=W3*M3;#MgCl2 in terms of CaCO3#\n", - "P4=W4*M4;#MgSO4 in terms of CaCO3#\n", - "print\"We do not take KCl since it does not contribute to hardness \" ;\n", - "C=P1+P2;\n", - "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", - "NC=P3+P4;\n", - "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "We do not take KCl since it does not contribute to hardness \n", - " Carbonate hardness is 20.0 mg/l or ppm\n", - " Non Carbonate hardness is 50.0 mg/l or ppm\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Akshay Ghogare/Akshay Ghogare_version_backup/AKSHAY.ipynb b/sample_notebooks/Akshay Ghogare/Akshay Ghogare_version_backup/AKSHAY.ipynb new file mode 100755 index 00000000..fa395760 --- /dev/null +++ b/sample_notebooks/Akshay Ghogare/Akshay Ghogare_version_backup/AKSHAY.ipynb @@ -0,0 +1,249 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:4b26d5a062c7df178b102bcb49ca0f8363642f2c290f44d66b774e90f3dc8f59" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "SAMPLE EXAMPLE 1" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 2.18.1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "W1=12.5;#CaCO3 in water in mg/lit#\n", + "W2=8.4;#MgCO3 in water in mg/lit#\n", + "W3=22.2;#CaCl2 in water in mg/lit#\n", + "W4=9.5;#MgCl2 in water in mg/lit#\n", + "W5=33;#CO2 in water in mg/lit#\n", + "W6=6.68;#NaHCO3 in water in mg/lit#\n", + "M1=100.0/100.0;#multiplication factor of CaCO3#\n", + "M2=100.0/84;#multiplication factor of MgCO3#\n", + "M3=100.0/111;#multiplication factor of CaCl2#\n", + "M4=100.0/95;#multiplication factor of MgCl2#\n", + "M6=100.0/84;#multiplication factor of NaHCO3#\n", + "P1=W1*M1;#CaCO3 in terms of CaCO3#\n", + "P2=W2*M2;#MgCO3 in terms of CaCO3#\n", + "P3=W3*M3;#CaCl2 in terms of CaCO3#\n", + "P4=W4*M4;#MgCl2 in terms of CaCO3#\n", + "P6=W6*M6;#NaHCO3 in terms of CaCO3#\n", + "print\"We do not take CO2 since it does not contribute to hardness \" ;\n", + "C=P1+P2+P6;\n", + "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", + "NC=P3+P4;\n", + "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "We do not take CO2 since it does not contribute to hardness \n", + " Carbonate hardness is 30.4523809524 mg/l or ppm\n", + " Non Carbonate hardness is 30.0 mg/l or ppm\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 2.18.2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "W1=40.5;\n", + "W2=33.3;\n", + "W3=41;\n", + "W4=101;\n", + "W5=33.6;\n", + "M1=100.0/162;\n", + "M2=100.0/111;\n", + "M3=100.0/164;\n", + "M5=100.0/84;\n", + "P1=W1*M1;\n", + "P2=W2*M2;\n", + "P3=W3*M3;\n", + "P5=W5*M5;\n", + "print \"We do not take KNO3 since it does not contribute to hardness \"\n", + "C=P1+P5;\n", + "print \"Carbonate hardness is\",C,\" mg/l or ppm\"\n", + "NC=P2+P3;\n", + "print \"Non Carbonate hardness is\",NC,\" mg/l or ppm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "We do not take KNO3 since it does not contribute to hardness \n", + "Carbonate hardness is 65.0 mg/l or ppm\n", + "Non Carbonate hardness is 55.0 mg/l or ppm\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 2.18.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "W1=29.1;#Mg(HCO3 2 in water in mg/lit#\n", + "W2=40.5;#Ca(HCO3 2 in water in mg/lit#\n", + "W3=11.1;#CaCl2 in water in mg/lit#\n", + "W4=15.82;#MgCl2 in water in mg/lit#\n", + "W5=28.5;#NaCl in water in mg/lit#\n", + "W6=22.0;#CO2 in water in mg/lit#\n", + "M1=100.0/146.007;#multiplication factor of Mg(HCO3 2#\n", + "M2=100.0/162;#multiplication factor of Ca(HCO3 2#\n", + "M3=100.0/111;#multiplication factor of CaCl2#\n", + "M4=100.0/95.005;#multiplication factor of MgCl2#\n", + "P1=W1*M1;#Mg(HCO3 2 in terms of CaCO3#\n", + "P2=W2*M2;#Ca(HCO3 2 in terms of CaCO3#\n", + "P3=W3*M3;#CaCl2 in terms of CaCO3#\n", + "P4=W4*M4;#MgCl2 in terms of CaCO3#\n", + "print\"We do not take NaCl and CO2 since they do not contribute to hardness \" ;\n", + "C=P1+P2;\n", + "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", + "NC=P3+P4;\n", + "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 2.18.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "W1=16.2;#Ca(HCO3 2 in water in mg/lit#\n", + "W2=14.6;#Mg(HCO3 2 in water in mg/lit#\n", + "W3=9.5;#MgCl2 in water in mg/lit#\n", + "W4=48;#MgSO4 in water in mg/lit#\n", + "W5=12;#KCl in water in mg/lit#\n", + "M1=100.0/162;#multiplication factor of Ca(HCO3 2#\n", + "M2=100.0/146;#multiplication factor of Mg(HCO3 2 #\n", + "M3=100.0/95;#multiplication factor of MgCl2#\n", + "M4=100.0/120;#multiplication factor of MgSO4#\n", + "P1=W1*M1;#Ca(HCO3 2 in terms of CaCO3#\n", + "P2=W2*M2;#Mg(HCO3 2 in terms of CaCO3#\n", + "P3=W3*M3;#MgCl2 in terms of CaCO3#\n", + "P4=W4*M4;#MgSO4 in terms of CaCO3#\n", + "print\"We do not take KCl since it does not contribute to hardness \" ;\n", + "C=P1+P2;\n", + "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", + "NC=P3+P4;\n", + "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 2.18.5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "W1=16.2;#Ca(HCO3 2 in water in mg/lit#\n", + "W2=14.6;#Mg(HCO3 2 in water in mg/lit#\n", + "W3=9.5;#MgCl2 in water in mg/lit#\n", + "W4=48;#MgSO4 in water in mg/lit#\n", + "W5=12;#KCl in water in mg/lit#\n", + "M1=100.0/162;#multiplication factor of Ca(HCO3 2#\n", + "M2=100.0/146;#multiplication factor of Mg(HCO3 2 #\n", + "M3=100.0/95;#multiplication factor of MgCl2#\n", + "M4=100.0/120;#multiplication factor of MgSO4#\n", + "P1=W1*M1;#Ca(HCO3 2 in terms of CaCO3#\n", + "P2=W2*M2;#Mg(HCO3 2 in terms of CaCO3#\n", + "P3=W3*M3;#MgCl2 in terms of CaCO3#\n", + "P4=W4*M4;#MgSO4 in terms of CaCO3#\n", + "print\"We do not take KCl since it does not contribute to hardness \" ;\n", + "C=P1+P2;\n", + "print\" Carbonate hardness is\",C,\"mg/l or ppm\";\n", + "NC=P3+P4;\n", + "print\" Non Carbonate hardness is\",NC,\"mg/l or ppm\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "We do not take KCl since it does not contribute to hardness \n", + " Carbonate hardness is 20.0 mg/l or ppm\n", + " Non Carbonate hardness is 50.0 mg/l or ppm\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AkshayPatil/AkshayPatil_version_backup/chapter1.ipynb b/sample_notebooks/AkshayPatil/AkshayPatil_version_backup/chapter1.ipynb new file mode 100755 index 00000000..8411e8ec --- /dev/null +++ b/sample_notebooks/AkshayPatil/AkshayPatil_version_backup/chapter1.ipynb @@ -0,0 +1,190 @@ +{ + "metadata": { + "name": "chapter1.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Introduction and Basic Concepts" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1-2,Page No:19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Declaration\n", + "UnitCostOfEnergy=0.09 #Unit cost of Energy in $/kWh\n", + "TimeInterval=2200 # Time Interval in hours\n", + "EnergyperUnitTime=30 # Rated Power kW\n", + "\n", + "#Calculation\n", + "TotalEnergy=EnergyperUnitTime*TimeInterval # Total Energy in kWh\n", + " \n", + "#Money Saved\n", + "MoneySaved=TotalEnergy*UnitCostOfEnergy # Money Saved in $\n", + "\n", + "#Calculations in Joules\n", + "Tot=EnergyperUnitTime*TimeInterval*(3600) #Total Energy in kJ\n", + "\n", + "#Result\n", + "print\"The Total Energy Generated is\",round(TotalEnergy),\"kWh\"\n", + "print\"The Total Money Saved is\",round(MoneySaved),\"$\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Total Energy Generated is 66000.0 kWh\n", + "The Total Money Saved is 5940.0 $\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1-3,Page No:20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Decleration\n", + "rho=850 #density of oil in kg/m^3\n", + "V=2 #Volume of tank in m^3\n", + "\n", + "#Calculations\n", + "#We intend to find m\n", + "m=rho*V #mass in the tank in kg\n", + "\n", + "#Result\n", + "print\"The mass in the tank is\", round(m),\"kg\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The mass in the tank is 1700.0 kg\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1-4,Page No:21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Decleration\n", + "m=1 #mass in lbm\n", + "g=32.174 #Gravatational Acceleration in ft/s^2\n", + "\n", + "#Calculations\n", + "W=(m*g)*(1/g) #weight in lbf\n", + "\n", + "#Result\n", + "print\"The weight in lbf is \",round(W),\"lbf\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The weight in lbf is 1.0 lbf\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1-6, Page No:30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable Decleration\n", + "V=1.1 #Volume of water collected in gal \n", + "delt=45.62 # time required in s\n", + "gal_conv=3.785*10**-3 #Gal conversion constant\n", + "mi=60 #1 minute equals 60 seconds \n", + "\n", + "#Calculations\n", + "V_dot=(V/delt)*(gal_conv/1)*(mi/1) #Volume flow rate in m^3/min\n", + "\n", + "#Result\n", + "print\"The volume flow rate is \",round(V_dot,4), \"m^3/min\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The volume flow rate is 0.0055 m^3/min\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AkshayPatil/chapter1.ipynb b/sample_notebooks/AkshayPatil/chapter1.ipynb deleted file mode 100755 index 8411e8ec..00000000 --- a/sample_notebooks/AkshayPatil/chapter1.ipynb +++ /dev/null @@ -1,190 +0,0 @@ -{ - "metadata": { - "name": "chapter1.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Introduction and Basic Concepts" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1-2,Page No:19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable Declaration\n", - "UnitCostOfEnergy=0.09 #Unit cost of Energy in $/kWh\n", - "TimeInterval=2200 # Time Interval in hours\n", - "EnergyperUnitTime=30 # Rated Power kW\n", - "\n", - "#Calculation\n", - "TotalEnergy=EnergyperUnitTime*TimeInterval # Total Energy in kWh\n", - " \n", - "#Money Saved\n", - "MoneySaved=TotalEnergy*UnitCostOfEnergy # Money Saved in $\n", - "\n", - "#Calculations in Joules\n", - "Tot=EnergyperUnitTime*TimeInterval*(3600) #Total Energy in kJ\n", - "\n", - "#Result\n", - "print\"The Total Energy Generated is\",round(TotalEnergy),\"kWh\"\n", - "print\"The Total Money Saved is\",round(MoneySaved),\"$\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Total Energy Generated is 66000.0 kWh\n", - "The Total Money Saved is 5940.0 $\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1-3,Page No:20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable Decleration\n", - "rho=850 #density of oil in kg/m^3\n", - "V=2 #Volume of tank in m^3\n", - "\n", - "#Calculations\n", - "#We intend to find m\n", - "m=rho*V #mass in the tank in kg\n", - "\n", - "#Result\n", - "print\"The mass in the tank is\", round(m),\"kg\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The mass in the tank is 1700.0 kg\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1-4,Page No:21" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable Decleration\n", - "m=1 #mass in lbm\n", - "g=32.174 #Gravatational Acceleration in ft/s^2\n", - "\n", - "#Calculations\n", - "W=(m*g)*(1/g) #weight in lbf\n", - "\n", - "#Result\n", - "print\"The weight in lbf is \",round(W),\"lbf\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The weight in lbf is 1.0 lbf\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1-6, Page No:30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable Decleration\n", - "V=1.1 #Volume of water collected in gal \n", - "delt=45.62 # time required in s\n", - "gal_conv=3.785*10**-3 #Gal conversion constant\n", - "mi=60 #1 minute equals 60 seconds \n", - "\n", - "#Calculations\n", - "V_dot=(V/delt)*(gal_conv/1)*(mi/1) #Volume flow rate in m^3/min\n", - "\n", - "#Result\n", - "print\"The volume flow rate is \",round(V_dot,4), \"m^3/min\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The volume flow rate is 0.0055 m^3/min\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AkshayShende/AkshayShende_version_backup/chapter2.ipynb b/sample_notebooks/AkshayShende/AkshayShende_version_backup/chapter2.ipynb new file mode 100755 index 00000000..d82b3395 --- /dev/null +++ b/sample_notebooks/AkshayShende/AkshayShende_version_backup/chapter2.ipynb @@ -0,0 +1,65 @@ +{ + "metadata": { + "name": "chapter2.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2:Concurrent Forces in A Plane" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2-1, Page No:10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "P=50 #N\n", + "Q=100 #N\n", + "beta=150 #degree # angle between P & the horizontal\n", + "\n", + "#Calculations\n", + "\n", + "R=(P**2+Q**2-(2*P*Q*cos(beta*(pi/180))))**0.5 # using the Trignometric solution\n", + "Alpha=(arcsin(((sin(beta*(pi/180))*Q)/R)))*(180/pi)+15 #Angle in degrees\n", + "\n", + "#Result\n", + "print \"The magnitude of resultant is\",round(R,2),\"N\"\n", + "print \"The direction of resultant is\",round(Alpha,2),\"degrees\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The magnitude of resultant is 145.47 N\n", + "The direction of resultant is 35.1 degrees\n" + ] + } + ], + "prompt_number": 19 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AkshayShende/chapter2.ipynb b/sample_notebooks/AkshayShende/chapter2.ipynb deleted file mode 100755 index d82b3395..00000000 --- a/sample_notebooks/AkshayShende/chapter2.ipynb +++ /dev/null @@ -1,65 +0,0 @@ -{ - "metadata": { - "name": "chapter2.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2:Concurrent Forces in A Plane" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2-1, Page No:10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "P=50 #N\n", - "Q=100 #N\n", - "beta=150 #degree # angle between P & the horizontal\n", - "\n", - "#Calculations\n", - "\n", - "R=(P**2+Q**2-(2*P*Q*cos(beta*(pi/180))))**0.5 # using the Trignometric solution\n", - "Alpha=(arcsin(((sin(beta*(pi/180))*Q)/R)))*(180/pi)+15 #Angle in degrees\n", - "\n", - "#Result\n", - "print \"The magnitude of resultant is\",round(R,2),\"N\"\n", - "print \"The direction of resultant is\",round(Alpha,2),\"degrees\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The magnitude of resultant is 145.47 N\n", - "The direction of resultant is 35.1 degrees\n" - ] - } - ], - "prompt_number": 19 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AlokDadlani/ALOK_DADLANI.ipynb b/sample_notebooks/AlokDadlani/ALOK_DADLANI.ipynb deleted file mode 100755 index 91d82daf..00000000 --- a/sample_notebooks/AlokDadlani/ALOK_DADLANI.ipynb +++ /dev/null @@ -1,181 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:257a8f491d964b9b4b60a222b425920b6deeb80bc5dff761617e08199ac997af" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "SAMPLE EXAMPLES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given that\n", - "D=80# separation between source and screen in cm\n", - "d=0.18# separation between sources in cm \n", - "n=4# order of fringe\n", - "x_n=1.08# distance from central bright fringe in cm \n", - "print \"Standard formula used x_n= n*lambda1*D/d \"\n", - "\n", - "lambda1=d*x_n/(D*n)*1e7\n", - "print \"Wavelength of light used is\" ,lambda1, \"Angstrom.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Standard formula used x_n= n*lambda1*D/d \n", - "Wavelength of light used is 6075.0 Angstrom.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given that\n", - "beta=0.0320#fringe width in cm\n", - "D=100# separation between source and screen in cm\n", - "d=0.184# separation between sources in cm \n", - "print \" Standard formula used beta=lambda1*D/d \"\n", - "lambda1=d*beta/D*1e8\n", - "print \"Wavelength of light used is\" ,lambda1,\"Angstrom.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Standard formula used beta=lambda1*D/d \n", - "Wavelength of light used is 5888.0 Angstrom.\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " #Given that\n", - "beta=0.02 #fringe width in cm\n", - "D=100 # separation between source and screen in cm\n", - "u=30 # separation between slit and convex lens in cm\n", - "I=0.7 # separation between two images of slits on screen in cm\n", - "print\" Standard formula used beta=lambda1*D/d \" \n", - "v=100-u\n", - "O=I*u/v\n", - "d=O\n", - "lambda1=d*beta/D*1e8\n", - "print\" Wavelength of light used is\",lambda1, \"Angstrom.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Standard formula used beta=lambda1*D/d \n", - " Wavelength of light used is 6000.0 Angstrom.\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given that\n", - "x_n=1.88# fringe separation of nth fringe from central fringe in cm \n", - "N=20# order of fringe\n", - "beta=0.02#fringe width in cm\n", - "D=120# separation between source and eyepiece in cm\n", - "d=0.076# separation between sources in cm \n", - "print \" Standard formula used beta= lambda1*D/d \"\n", - "beta=x_n/N # calculation of angle formed\n", - "lambda1=d*beta/D*1e8 # calculation of Wavelength of light\n", - "print \" Wavelength of light used is\", round(lambda1,4) , \"Angstrom.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Standard formula used beta= lambda1*D/d \n", - " Wavelength of light used is 5953.3333 Angstrom.\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AlokDadlani/AlokDadlani_version_backup/ALOK.ipynb b/sample_notebooks/AlokDadlani/AlokDadlani_version_backup/ALOK.ipynb new file mode 100755 index 00000000..91d82daf --- /dev/null +++ b/sample_notebooks/AlokDadlani/AlokDadlani_version_backup/ALOK.ipynb @@ -0,0 +1,181 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:257a8f491d964b9b4b60a222b425920b6deeb80bc5dff761617e08199ac997af" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "SAMPLE EXAMPLES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given that\n", + "D=80# separation between source and screen in cm\n", + "d=0.18# separation between sources in cm \n", + "n=4# order of fringe\n", + "x_n=1.08# distance from central bright fringe in cm \n", + "print \"Standard formula used x_n= n*lambda1*D/d \"\n", + "\n", + "lambda1=d*x_n/(D*n)*1e7\n", + "print \"Wavelength of light used is\" ,lambda1, \"Angstrom.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard formula used x_n= n*lambda1*D/d \n", + "Wavelength of light used is 6075.0 Angstrom.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given that\n", + "beta=0.0320#fringe width in cm\n", + "D=100# separation between source and screen in cm\n", + "d=0.184# separation between sources in cm \n", + "print \" Standard formula used beta=lambda1*D/d \"\n", + "lambda1=d*beta/D*1e8\n", + "print \"Wavelength of light used is\" ,lambda1,\"Angstrom.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Standard formula used beta=lambda1*D/d \n", + "Wavelength of light used is 5888.0 Angstrom.\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " #Given that\n", + "beta=0.02 #fringe width in cm\n", + "D=100 # separation between source and screen in cm\n", + "u=30 # separation between slit and convex lens in cm\n", + "I=0.7 # separation between two images of slits on screen in cm\n", + "print\" Standard formula used beta=lambda1*D/d \" \n", + "v=100-u\n", + "O=I*u/v\n", + "d=O\n", + "lambda1=d*beta/D*1e8\n", + "print\" Wavelength of light used is\",lambda1, \"Angstrom.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Standard formula used beta=lambda1*D/d \n", + " Wavelength of light used is 6000.0 Angstrom.\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given that\n", + "x_n=1.88# fringe separation of nth fringe from central fringe in cm \n", + "N=20# order of fringe\n", + "beta=0.02#fringe width in cm\n", + "D=120# separation between source and eyepiece in cm\n", + "d=0.076# separation between sources in cm \n", + "print \" Standard formula used beta= lambda1*D/d \"\n", + "beta=x_n/N # calculation of angle formed\n", + "lambda1=d*beta/D*1e8 # calculation of Wavelength of light\n", + "print \" Wavelength of light used is\", round(lambda1,4) , \"Angstrom.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Standard formula used beta= lambda1*D/d \n", + " Wavelength of light used is 5953.3333 Angstrom.\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Aman KumarJain/Aman KumarJain_version_backup/Chapter_6_Objects_and.ipynb b/sample_notebooks/Aman KumarJain/Aman KumarJain_version_backup/Chapter_6_Objects_and.ipynb new file mode 100755 index 00000000..89a18f99 --- /dev/null +++ b/sample_notebooks/Aman KumarJain/Aman KumarJain_version_backup/Chapter_6_Objects_and.ipynb @@ -0,0 +1,934 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:bd4e7931ddf89d8dc8befb681e1e57c7a9c742cd8abe8e18a494a55156d56cee" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 6: Objects and Classes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.1, Page Number: 216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class smallobj: #define a class\n", + " \n", + " def setdata(self,d): #member function to set class variable somdata\n", + " self.__somedata = d\n", + " \n", + " def showdata(self): #member function to display somedata \n", + " print 'Data is ' , self.__somedata\n", + "\n", + "\n", + "#define two objects of class smallobj\n", + "s1=smallobj()\n", + "s2=smallobj()\n", + "\n", + "#call member function to set data \n", + "s1.setdata(1066)\n", + "s2.setdata(1776)\n", + "\n", + "#call member function to display data \n", + "s1.showdata()\n", + "s2.showdata()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1066\n", + "Data is 1776\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.2, Page Number: 223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class part: #define class \n", + " \n", + " def setpart(self,mn,pn,c): #set data\n", + " self.__modelnumber = mn\n", + " self.__partnumber = pn\n", + " self.__cost = c\n", + " \n", + " def showpart(self): #display data \n", + " print 'Model' , self.__modelnumber ,\n", + " print ', part' , self.__partnumber , \n", + " print ', costs $',self.__cost\n", + " \n", + "#define object of class part \n", + "part1 = part()\n", + "\n", + "#call member function setpart\n", + "part1.setpart(6244,373,217.55)\n", + "\n", + "#call member function showpart\n", + "part1.showpart()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Model 6244 , part 373 , costs $ 217.55\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.3, Page Number: 225" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from turtle import * #importing turtles library\n", + "\n", + "class circle: #defining circle class\n", + " \n", + " def set(self,x,y,r,fc): #sets circle attribute\n", + " self._xCo = x\n", + " self._yCo = y\n", + " self._radius = r\n", + " self._fillcolor = fc\n", + " \n", + " def draw(self): #draws the circle \n", + " setup() #set screen\n", + " turtle = Turtle() #object of Turtle class\n", + " turtle.begin_fill() #start filling color in circle\n", + " turtle.color(self._fillcolor) #color\n", + " turtle.up()\n", + " turtle.goto(self._xCo,self._yCo) #set center of circle\n", + " turtle.circle(self._radius) #draw circle of radius self.__radius\n", + " turtle.end_fill() #stop filling\n", + " turtle.hideturtle()\n", + " done()\n", + "\n", + "#creating objects of class circle \n", + "c1 = circle()\n", + "c2 = circle()\n", + "c3 = circle()\n", + "\n", + "#sending the value to set fnction\n", + "c1.set(15,7,5,\"blue\")\n", + "c2.set(41,12,7,\"red\")\n", + "c3.set(65,18,4,\"green\")\n", + "\n", + "#draw circle\n", + "c1.draw()\n", + "c2.draw()\n", + "c3.draw()\n", + "\n", + "#In the above example the cirlcle's in the book are constructed using 'X' and 'O' but such feature is not available in Python.\n", + "#So i have created a simple circle filled with color" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.4, Page Number: 226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance: #Distance class\n", + " \n", + " def setdist(self,ft,inc): #set distance to class variables\n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " \n", + " def getdist(self): #get distance from user\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self): #display distance\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + "\n", + "#define two distance\n", + "dist1 = Distance()\n", + "dist2 = Distance()\n", + "\n", + "dist1.setdist(11,6.25) #set dist1\n", + "dist2.getdist() #set dist2 from user\n", + "\n", + "#show distances\n", + "print \"dist1 = \",\n", + "dist1.showdist()\n", + "print 'dist2 = ',\n", + "dist2.showdist()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter feet:17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter inches:5.75\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dist1 = 11 ' - 6.25 \"\n", + "dist2 = 17 ' - 5.75 \"\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.5, Page Number: 228" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Counter:\n", + " \n", + " def __init__(self): #constructor\n", + " self.__count = 0\n", + " \n", + " def inc_count(self): #increment count\n", + " self.__count = self.__count + 1\n", + " \n", + " def get_count(self): #return count\n", + " return self.__count\n", + "\n", + "#define and initialize class objects\n", + "c1=Counter()\n", + "c2=Counter()\n", + "\n", + "#display count for each object\n", + "print 'c1 =',c1.get_count()\n", + "print 'c2 =',c2.get_count()\n", + "\n", + "\n", + "c1.inc_count() #increment c1\n", + "c2.inc_count() #increment c2\n", + "c2.inc_count() #increment c2\n", + "\n", + "#display count again for each object\n", + "print 'c1 =',c1.get_count()\n", + "print 'c2 =',c2.get_count()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c1 = 0\n", + "c2 = 0\n", + "c1 = 1\n", + "c2 = 2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6, Page Number: 231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from turtle import * #importing turtles library\n", + "\n", + "class circle: #defining circle class\n", + " \n", + " def __init__(self,x,y,r,fc): #constructor for set circle attribute\n", + " self._xCo = x\n", + " self._yCo = y\n", + " self._radius = r\n", + " self._fillcolor = fc\n", + " \n", + " def draw(self): #draws the circle\n", + " setup()\n", + " turtle = Turtle()\n", + " turtle.begin_fill()\n", + " turtle.color(self._fillcolor)\n", + " turtle.up()\n", + " turtle.goto(self._xCo,self._yCo)\n", + " turtle.down()\n", + " turtle.circle(self._radius)\n", + " turtle.end_fill()\n", + " turtle.hideturtle()\n", + " done()\n", + "\n", + "#creating objects of class circle \n", + "c1 = circle(15,7,5,\"blue\") \n", + "c2 = circle(41,12,7,\"red\")\n", + "c3 = circle(65,18,4,\"green\")\n", + "\n", + "#draw circle\n", + "c1.draw()\n", + "c2.draw()\n", + "c3.draw()" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.7, Page Number: 233" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance: #Distance class\n", + " \n", + " def __init__(self,ft=0,inc=0): #constructor \n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " \n", + " def getdist(self): #get length from user\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self): #display distance\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + " \n", + " def add_dist(self,d2,d3): #add length d2 and d3\n", + " self.__inches = d2.__inches + d3.__inches #add inches\n", + " self.__feet = 0\n", + " if self.__inches >= 12.0: #if total exceeds 12.0\n", + " self.__inches = self.__inches - 12.0 #then decrease inches by 12.0\n", + " self.__feet = self.__feet + 1 #and increase feet by 1\n", + " self.__feet = self.__feet + d2.__feet + d3.__feet #add the feet\n", + "\n", + "#define two length\n", + "dist1 = Distance()\n", + "dist3 = Distance()\n", + "\n", + "#define and initialize dist2\n", + "dist2 = Distance(11,6.25)\n", + "\n", + "#get dist1 from user\n", + "dist1.getdist()\n", + "\n", + "#dist3 = dist1 + dist2\n", + "dist3.add_dist(dist1,dist2)\n", + "\n", + "#display all lengths\n", + "print 'dist1 = ',\n", + "dist1.showdist()\n", + "print 'dist2 = ',\n", + "dist2.showdist()\n", + "print 'dist3 = ',\n", + "dist3.showdist()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter feet:17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter inches:5.75\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dist1 = 17 ' - 5.75 \"\n", + "dist2 = 11 ' - 6.25 \"\n", + "dist3 = 29 ' - 0.0 \"\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.8, Page Number: 238" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance: #Distance class\n", + " \n", + " def __init__(self,ft=0,inc=0): #overloaded constructor that takes no arguments or two args or one object(copy constructor)\n", + " if isinstance(ft,int):\n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " else:\n", + " self.__feet = ft.__feet\n", + " self.__inches = ft.__inches\n", + " \n", + " def getdist(self): #get length from user\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self): #display distance\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + "\n", + "#two argument constructor\n", + "dist1 = Distance(11,6.25)\n", + "\n", + "#one argument(object) constructor explicitly pass\n", + "dist2 = Distance(dist1)\n", + "\n", + "#also one argument(object) constructor implicitly pass\n", + "dist3 = dist1\n", + "\n", + "#display all lengths\n", + "print 'dist1 = ',\n", + "dist1.showdist()\n", + "print 'dist2 = ',\n", + "dist2.showdist()\n", + "print 'dist3 = ',\n", + "dist3.showdist()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dist1 = 11 ' - 6.25 \"\n", + "dist2 = 11 ' - 6.25 \"\n", + "dist3 = 11 ' - 6.25 \"\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.9, Page Number: 240" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance: #Distance class\n", + " \n", + " def __init__(self,ft=0,inc=0): #constructor \n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " \n", + " def getdist(self): #get length from user\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self): #display distance\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + " \n", + " def add_dist(self,d2): #add this length to d2 and return object\n", + " temp = Distance() #temporary object\n", + " temp.__inches = self.__inches + d2.__inches\n", + " if temp.__inches >= 12.0:\n", + " temp.__inches = temp.__inches - 12.0\n", + " temp.__feet = 1\n", + " temp.__feet = temp.__feet + self.__feet + d2.__feet\n", + " return temp #return sum as object\n", + "\n", + "#define two length\n", + "dist1 = Distance()\n", + "dist3 = Distance()\n", + "\n", + "#define and initialize dist2\n", + "dist2 = Distance(11,6.25)\n", + "\n", + "#get dist1 from user\n", + "dist1.getdist()\n", + "\n", + "#dist3 = dist1 + dist2\n", + "dist3 = dist1.add_dist(dist2)\n", + "\n", + "#display all lengths\n", + "print 'dist1 = ',\n", + "dist1.showdist()\n", + "print 'dist2 = ',\n", + "dist2.showdist()\n", + "print 'dist3 = ',\n", + "dist3.showdist()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter feet:17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter inches:5.75\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dist1 = 17 ' - 5.75 \"\n", + "dist2 = 11 ' - 6.25 \"\n", + "dist3 = 29 ' - 0.0 \"\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.10, Page Number: 243" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Suit = [\"clubs\",\"diamonds\",\"hearts\",\"spades\"] \n", + "\n", + "(clubs,diamonds,hearts,spades) = (0,1,2,3) #Atteching the names with number \n", + "\n", + "\n", + "#from 2 to 10 are integers without names\n", + "jack = 11 \n", + "queen = 12 \n", + "king = 13\n", + "ace = 14\n", + "\n", + "\n", + "class card: \n", + " \n", + " def __init__(self,n=None,s=None): #constructor\n", + " self.__number = n #2 to 10, jack, queen, king, ace\n", + " self.__suit = s #clubs, diamonds, hearts, spades\n", + " \n", + " def display(self): #display the cards\n", + " \n", + " if self.__number >= 2 and self.__number<=10:\n", + " print self.__number , 'of',\n", + " \n", + " else:\n", + " if self.__number == jack:\n", + " print 'jack of',\n", + " elif self.__number == queen:\n", + " print 'queen of',\n", + " elif self.__number == king:\n", + " print 'king of',\n", + " else:\n", + " print 'ace of',\n", + " \n", + " if self.__suit == clubs:\n", + " print 'clubs'\n", + " elif self.__suit == diamonds:\n", + " print 'diamonds'\n", + " elif self.__suit == hearts:\n", + " print 'hearts'\n", + " else:\n", + " print 'spades'\n", + " \n", + " def isEqual(self,c2): #return 1 if cards equal\n", + " \n", + " if self.__number == c2.__number and self.__suit == c2.__suit:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "\n", + "#define various cards\n", + "temp = card()\n", + "chosen = card()\n", + "prize = card()\n", + "\n", + "\n", + "#define and initialize card1\n", + "card1 = card(7,clubs)\n", + "print 'card 1 is the',\n", + "card1.display() #display card1\n", + "\n", + "#define and initialize card2\n", + "card2 = card(jack,hearts)\n", + "print 'card 2 is the',\n", + "card2.display() #display card2\n", + "\n", + "#define and initialize card3\n", + "card3 = card(ace,spades)\n", + "print 'card 3 is the',\n", + "card3.display() #display card3\n", + "\n", + "\n", + "#prize is the card to guess\n", + "prize = card3\n", + "\n", + "\n", + "#swapping cards\n", + "print 'I\\'m swapping card 1 and card 3'\n", + "temp = card3\n", + "card3 = card1\n", + "card1 = temp\n", + "\n", + "print 'I\\'m swapping card 2 and card 3'\n", + "temp = card2\n", + "card3 = card2\n", + "card2 = temp\n", + "\n", + "print 'I\\'m swapping card 1 and card 2'\n", + "temp = card2\n", + "card2 = card1\n", + "card1 = temp\n", + "\n", + "print 'Now, where (1,2, or 3) is the',\n", + "prize.display() #display prize\n", + "print '?'\n", + "\n", + "position = input() #get user's guess of position\n", + "\n", + "\n", + "#set chosen to user's choice \n", + "if position == 1:\n", + " chosen = card1\n", + "elif position == 2:\n", + " chosen = card2\n", + "else:\n", + " chosen = card3\n", + "\n", + "#is chosen card the prize?\n", + "\n", + "x=chosen.isEqual(prize)\n", + "\n", + "if x==1:\n", + " print 'That\\'s right! You win!'\n", + "else:\n", + " print 'Sorry. You lose.'\n", + "\n", + "print 'You choose the',\n", + "\n", + "#display chosen card\n", + "chosen.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "card 1 is the 7 of clubs\n", + "card 2 is the jack of hearts\n", + "card 3 is the ace of spades\n", + "I'm swapping card 1 and card 3\n", + "I'm swapping card 2 and card 3\n", + "I'm swapping card 1 and card 2\n", + "Now, where (1,2, or 3) is the ace of spades\n", + "?\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "That's right! You win!\n", + "You choose the ace of spades\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.11, Page Number: 249" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class foo: \n", + " \n", + " __count = 0 #only one data item for all objects\n", + " \n", + " def __init__(self):\n", + " foo.__count = foo.__count + 1 #increment count when object created\n", + " \n", + " def getcount(self): #returns count\n", + " return foo.__count\n", + "\n", + "#create three objecs\n", + "f1 = foo()\n", + "f2 = foo()\n", + "f3 = foo()\n", + "\n", + "#Each object displays the same count value\n", + "print 'count is', f1.getcount()\n", + "print 'count is', f2.getcount()\n", + "print 'count is', f3.getcount()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "count is 3\n", + "count is 3\n", + "count is 3\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.12, Page Number: 253" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance: #Distance class\n", + " \n", + " def __init__(self,ft=0,inc=0.0): #constructor \n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " \n", + " def getdist(self): #get length from user\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self): #display distance\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + "\n", + "#There's no const keyword \n", + " \n", + " def add_dist(self,d2): #add this length to d2 and return object\n", + " \n", + " temp = Distance()\n", + " temp.__inches = self.__inches + d2.__inches\n", + " \n", + " if temp.__inches >= 12.0:\n", + " temp.__inches = temp.__inches - 12.0\n", + " temp.__feet = 1\n", + " \n", + " temp.__feet = temp.__feet + self.__feet + d2.__feet\n", + " \n", + " return temp #return sum as object\n", + " \n", + "dist1 = Distance()\n", + "dist3 = Distance()\n", + "dist2 = Distance(11,6.25)\n", + "\n", + "dist1.getdist()\n", + "\n", + "dist3 = dist1.add_dist(dist2)\n", + "\n", + "print 'dist1 = ',\n", + "dist1.showdist()\n", + "print 'dist2 = ',\n", + "dist2.showdist()\n", + "print 'dist3 = ',\n", + "dist3.showdist()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter feet:17\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter inches:5.75\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "dist1 = 17 ' - 5.75 \"\n", + "dist2 = 11 ' - 6.25 \"\n", + "dist3 = 29 ' - 0.0 \"\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.13, Page Number: 255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Distance:\n", + " \n", + " def __init__(self,ft,inc):\n", + " self.__feet = ft\n", + " self.__inches = inc\n", + " \n", + " def getdist(self):\n", + " self.__feet = input('Enter feet:')\n", + " self.__inches = input('Enter inches:')\n", + " \n", + " def showdist(self):\n", + " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", + "\n", + "football = Distance(300,0)\n", + "\n", + "print 'football = ',\n", + "football.showdist()\n", + "\n", + "#There's no const keyword in python" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "football = 300 ' - 0 \"\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Aman KumarJain/Chapter_6_Objects_and_Classes.ipynb b/sample_notebooks/Aman KumarJain/Chapter_6_Objects_and_Classes.ipynb deleted file mode 100755 index 89a18f99..00000000 --- a/sample_notebooks/Aman KumarJain/Chapter_6_Objects_and_Classes.ipynb +++ /dev/null @@ -1,934 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:bd4e7931ddf89d8dc8befb681e1e57c7a9c742cd8abe8e18a494a55156d56cee" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 6: Objects and Classes" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.1, Page Number: 216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class smallobj: #define a class\n", - " \n", - " def setdata(self,d): #member function to set class variable somdata\n", - " self.__somedata = d\n", - " \n", - " def showdata(self): #member function to display somedata \n", - " print 'Data is ' , self.__somedata\n", - "\n", - "\n", - "#define two objects of class smallobj\n", - "s1=smallobj()\n", - "s2=smallobj()\n", - "\n", - "#call member function to set data \n", - "s1.setdata(1066)\n", - "s2.setdata(1776)\n", - "\n", - "#call member function to display data \n", - "s1.showdata()\n", - "s2.showdata()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1066\n", - "Data is 1776\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.2, Page Number: 223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class part: #define class \n", - " \n", - " def setpart(self,mn,pn,c): #set data\n", - " self.__modelnumber = mn\n", - " self.__partnumber = pn\n", - " self.__cost = c\n", - " \n", - " def showpart(self): #display data \n", - " print 'Model' , self.__modelnumber ,\n", - " print ', part' , self.__partnumber , \n", - " print ', costs $',self.__cost\n", - " \n", - "#define object of class part \n", - "part1 = part()\n", - "\n", - "#call member function setpart\n", - "part1.setpart(6244,373,217.55)\n", - "\n", - "#call member function showpart\n", - "part1.showpart()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Model 6244 , part 373 , costs $ 217.55\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.3, Page Number: 225" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from turtle import * #importing turtles library\n", - "\n", - "class circle: #defining circle class\n", - " \n", - " def set(self,x,y,r,fc): #sets circle attribute\n", - " self._xCo = x\n", - " self._yCo = y\n", - " self._radius = r\n", - " self._fillcolor = fc\n", - " \n", - " def draw(self): #draws the circle \n", - " setup() #set screen\n", - " turtle = Turtle() #object of Turtle class\n", - " turtle.begin_fill() #start filling color in circle\n", - " turtle.color(self._fillcolor) #color\n", - " turtle.up()\n", - " turtle.goto(self._xCo,self._yCo) #set center of circle\n", - " turtle.circle(self._radius) #draw circle of radius self.__radius\n", - " turtle.end_fill() #stop filling\n", - " turtle.hideturtle()\n", - " done()\n", - "\n", - "#creating objects of class circle \n", - "c1 = circle()\n", - "c2 = circle()\n", - "c3 = circle()\n", - "\n", - "#sending the value to set fnction\n", - "c1.set(15,7,5,\"blue\")\n", - "c2.set(41,12,7,\"red\")\n", - "c3.set(65,18,4,\"green\")\n", - "\n", - "#draw circle\n", - "c1.draw()\n", - "c2.draw()\n", - "c3.draw()\n", - "\n", - "#In the above example the cirlcle's in the book are constructed using 'X' and 'O' but such feature is not available in Python.\n", - "#So i have created a simple circle filled with color" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.4, Page Number: 226" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance: #Distance class\n", - " \n", - " def setdist(self,ft,inc): #set distance to class variables\n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " \n", - " def getdist(self): #get distance from user\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self): #display distance\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - "\n", - "#define two distance\n", - "dist1 = Distance()\n", - "dist2 = Distance()\n", - "\n", - "dist1.setdist(11,6.25) #set dist1\n", - "dist2.getdist() #set dist2 from user\n", - "\n", - "#show distances\n", - "print \"dist1 = \",\n", - "dist1.showdist()\n", - "print 'dist2 = ',\n", - "dist2.showdist()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter feet:17\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter inches:5.75\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "dist1 = 11 ' - 6.25 \"\n", - "dist2 = 17 ' - 5.75 \"\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.5, Page Number: 228" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Counter:\n", - " \n", - " def __init__(self): #constructor\n", - " self.__count = 0\n", - " \n", - " def inc_count(self): #increment count\n", - " self.__count = self.__count + 1\n", - " \n", - " def get_count(self): #return count\n", - " return self.__count\n", - "\n", - "#define and initialize class objects\n", - "c1=Counter()\n", - "c2=Counter()\n", - "\n", - "#display count for each object\n", - "print 'c1 =',c1.get_count()\n", - "print 'c2 =',c2.get_count()\n", - "\n", - "\n", - "c1.inc_count() #increment c1\n", - "c2.inc_count() #increment c2\n", - "c2.inc_count() #increment c2\n", - "\n", - "#display count again for each object\n", - "print 'c1 =',c1.get_count()\n", - "print 'c2 =',c2.get_count()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c1 = 0\n", - "c2 = 0\n", - "c1 = 1\n", - "c2 = 2\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6, Page Number: 231" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from turtle import * #importing turtles library\n", - "\n", - "class circle: #defining circle class\n", - " \n", - " def __init__(self,x,y,r,fc): #constructor for set circle attribute\n", - " self._xCo = x\n", - " self._yCo = y\n", - " self._radius = r\n", - " self._fillcolor = fc\n", - " \n", - " def draw(self): #draws the circle\n", - " setup()\n", - " turtle = Turtle()\n", - " turtle.begin_fill()\n", - " turtle.color(self._fillcolor)\n", - " turtle.up()\n", - " turtle.goto(self._xCo,self._yCo)\n", - " turtle.down()\n", - " turtle.circle(self._radius)\n", - " turtle.end_fill()\n", - " turtle.hideturtle()\n", - " done()\n", - "\n", - "#creating objects of class circle \n", - "c1 = circle(15,7,5,\"blue\") \n", - "c2 = circle(41,12,7,\"red\")\n", - "c3 = circle(65,18,4,\"green\")\n", - "\n", - "#draw circle\n", - "c1.draw()\n", - "c2.draw()\n", - "c3.draw()" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.7, Page Number: 233" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance: #Distance class\n", - " \n", - " def __init__(self,ft=0,inc=0): #constructor \n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " \n", - " def getdist(self): #get length from user\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self): #display distance\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - " \n", - " def add_dist(self,d2,d3): #add length d2 and d3\n", - " self.__inches = d2.__inches + d3.__inches #add inches\n", - " self.__feet = 0\n", - " if self.__inches >= 12.0: #if total exceeds 12.0\n", - " self.__inches = self.__inches - 12.0 #then decrease inches by 12.0\n", - " self.__feet = self.__feet + 1 #and increase feet by 1\n", - " self.__feet = self.__feet + d2.__feet + d3.__feet #add the feet\n", - "\n", - "#define two length\n", - "dist1 = Distance()\n", - "dist3 = Distance()\n", - "\n", - "#define and initialize dist2\n", - "dist2 = Distance(11,6.25)\n", - "\n", - "#get dist1 from user\n", - "dist1.getdist()\n", - "\n", - "#dist3 = dist1 + dist2\n", - "dist3.add_dist(dist1,dist2)\n", - "\n", - "#display all lengths\n", - "print 'dist1 = ',\n", - "dist1.showdist()\n", - "print 'dist2 = ',\n", - "dist2.showdist()\n", - "print 'dist3 = ',\n", - "dist3.showdist()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter feet:17\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter inches:5.75\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "dist1 = 17 ' - 5.75 \"\n", - "dist2 = 11 ' - 6.25 \"\n", - "dist3 = 29 ' - 0.0 \"\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.8, Page Number: 238" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance: #Distance class\n", - " \n", - " def __init__(self,ft=0,inc=0): #overloaded constructor that takes no arguments or two args or one object(copy constructor)\n", - " if isinstance(ft,int):\n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " else:\n", - " self.__feet = ft.__feet\n", - " self.__inches = ft.__inches\n", - " \n", - " def getdist(self): #get length from user\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self): #display distance\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - "\n", - "#two argument constructor\n", - "dist1 = Distance(11,6.25)\n", - "\n", - "#one argument(object) constructor explicitly pass\n", - "dist2 = Distance(dist1)\n", - "\n", - "#also one argument(object) constructor implicitly pass\n", - "dist3 = dist1\n", - "\n", - "#display all lengths\n", - "print 'dist1 = ',\n", - "dist1.showdist()\n", - "print 'dist2 = ',\n", - "dist2.showdist()\n", - "print 'dist3 = ',\n", - "dist3.showdist()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "dist1 = 11 ' - 6.25 \"\n", - "dist2 = 11 ' - 6.25 \"\n", - "dist3 = 11 ' - 6.25 \"\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.9, Page Number: 240" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance: #Distance class\n", - " \n", - " def __init__(self,ft=0,inc=0): #constructor \n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " \n", - " def getdist(self): #get length from user\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self): #display distance\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - " \n", - " def add_dist(self,d2): #add this length to d2 and return object\n", - " temp = Distance() #temporary object\n", - " temp.__inches = self.__inches + d2.__inches\n", - " if temp.__inches >= 12.0:\n", - " temp.__inches = temp.__inches - 12.0\n", - " temp.__feet = 1\n", - " temp.__feet = temp.__feet + self.__feet + d2.__feet\n", - " return temp #return sum as object\n", - "\n", - "#define two length\n", - "dist1 = Distance()\n", - "dist3 = Distance()\n", - "\n", - "#define and initialize dist2\n", - "dist2 = Distance(11,6.25)\n", - "\n", - "#get dist1 from user\n", - "dist1.getdist()\n", - "\n", - "#dist3 = dist1 + dist2\n", - "dist3 = dist1.add_dist(dist2)\n", - "\n", - "#display all lengths\n", - "print 'dist1 = ',\n", - "dist1.showdist()\n", - "print 'dist2 = ',\n", - "dist2.showdist()\n", - "print 'dist3 = ',\n", - "dist3.showdist()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter feet:17\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter inches:5.75\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "dist1 = 17 ' - 5.75 \"\n", - "dist2 = 11 ' - 6.25 \"\n", - "dist3 = 29 ' - 0.0 \"\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.10, Page Number: 243" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Suit = [\"clubs\",\"diamonds\",\"hearts\",\"spades\"] \n", - "\n", - "(clubs,diamonds,hearts,spades) = (0,1,2,3) #Atteching the names with number \n", - "\n", - "\n", - "#from 2 to 10 are integers without names\n", - "jack = 11 \n", - "queen = 12 \n", - "king = 13\n", - "ace = 14\n", - "\n", - "\n", - "class card: \n", - " \n", - " def __init__(self,n=None,s=None): #constructor\n", - " self.__number = n #2 to 10, jack, queen, king, ace\n", - " self.__suit = s #clubs, diamonds, hearts, spades\n", - " \n", - " def display(self): #display the cards\n", - " \n", - " if self.__number >= 2 and self.__number<=10:\n", - " print self.__number , 'of',\n", - " \n", - " else:\n", - " if self.__number == jack:\n", - " print 'jack of',\n", - " elif self.__number == queen:\n", - " print 'queen of',\n", - " elif self.__number == king:\n", - " print 'king of',\n", - " else:\n", - " print 'ace of',\n", - " \n", - " if self.__suit == clubs:\n", - " print 'clubs'\n", - " elif self.__suit == diamonds:\n", - " print 'diamonds'\n", - " elif self.__suit == hearts:\n", - " print 'hearts'\n", - " else:\n", - " print 'spades'\n", - " \n", - " def isEqual(self,c2): #return 1 if cards equal\n", - " \n", - " if self.__number == c2.__number and self.__suit == c2.__suit:\n", - " return 1\n", - " else:\n", - " return 0\n", - "\n", - "\n", - "#define various cards\n", - "temp = card()\n", - "chosen = card()\n", - "prize = card()\n", - "\n", - "\n", - "#define and initialize card1\n", - "card1 = card(7,clubs)\n", - "print 'card 1 is the',\n", - "card1.display() #display card1\n", - "\n", - "#define and initialize card2\n", - "card2 = card(jack,hearts)\n", - "print 'card 2 is the',\n", - "card2.display() #display card2\n", - "\n", - "#define and initialize card3\n", - "card3 = card(ace,spades)\n", - "print 'card 3 is the',\n", - "card3.display() #display card3\n", - "\n", - "\n", - "#prize is the card to guess\n", - "prize = card3\n", - "\n", - "\n", - "#swapping cards\n", - "print 'I\\'m swapping card 1 and card 3'\n", - "temp = card3\n", - "card3 = card1\n", - "card1 = temp\n", - "\n", - "print 'I\\'m swapping card 2 and card 3'\n", - "temp = card2\n", - "card3 = card2\n", - "card2 = temp\n", - "\n", - "print 'I\\'m swapping card 1 and card 2'\n", - "temp = card2\n", - "card2 = card1\n", - "card1 = temp\n", - "\n", - "print 'Now, where (1,2, or 3) is the',\n", - "prize.display() #display prize\n", - "print '?'\n", - "\n", - "position = input() #get user's guess of position\n", - "\n", - "\n", - "#set chosen to user's choice \n", - "if position == 1:\n", - " chosen = card1\n", - "elif position == 2:\n", - " chosen = card2\n", - "else:\n", - " chosen = card3\n", - "\n", - "#is chosen card the prize?\n", - "\n", - "x=chosen.isEqual(prize)\n", - "\n", - "if x==1:\n", - " print 'That\\'s right! You win!'\n", - "else:\n", - " print 'Sorry. You lose.'\n", - "\n", - "print 'You choose the',\n", - "\n", - "#display chosen card\n", - "chosen.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "card 1 is the 7 of clubs\n", - "card 2 is the jack of hearts\n", - "card 3 is the ace of spades\n", - "I'm swapping card 1 and card 3\n", - "I'm swapping card 2 and card 3\n", - "I'm swapping card 1 and card 2\n", - "Now, where (1,2, or 3) is the ace of spades\n", - "?\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "That's right! You win!\n", - "You choose the ace of spades\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.11, Page Number: 249" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class foo: \n", - " \n", - " __count = 0 #only one data item for all objects\n", - " \n", - " def __init__(self):\n", - " foo.__count = foo.__count + 1 #increment count when object created\n", - " \n", - " def getcount(self): #returns count\n", - " return foo.__count\n", - "\n", - "#create three objecs\n", - "f1 = foo()\n", - "f2 = foo()\n", - "f3 = foo()\n", - "\n", - "#Each object displays the same count value\n", - "print 'count is', f1.getcount()\n", - "print 'count is', f2.getcount()\n", - "print 'count is', f3.getcount()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "count is 3\n", - "count is 3\n", - "count is 3\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.12, Page Number: 253" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance: #Distance class\n", - " \n", - " def __init__(self,ft=0,inc=0.0): #constructor \n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " \n", - " def getdist(self): #get length from user\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self): #display distance\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - "\n", - "#There's no const keyword \n", - " \n", - " def add_dist(self,d2): #add this length to d2 and return object\n", - " \n", - " temp = Distance()\n", - " temp.__inches = self.__inches + d2.__inches\n", - " \n", - " if temp.__inches >= 12.0:\n", - " temp.__inches = temp.__inches - 12.0\n", - " temp.__feet = 1\n", - " \n", - " temp.__feet = temp.__feet + self.__feet + d2.__feet\n", - " \n", - " return temp #return sum as object\n", - " \n", - "dist1 = Distance()\n", - "dist3 = Distance()\n", - "dist2 = Distance(11,6.25)\n", - "\n", - "dist1.getdist()\n", - "\n", - "dist3 = dist1.add_dist(dist2)\n", - "\n", - "print 'dist1 = ',\n", - "dist1.showdist()\n", - "print 'dist2 = ',\n", - "dist2.showdist()\n", - "print 'dist3 = ',\n", - "dist3.showdist()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter feet:17\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter inches:5.75\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "dist1 = 17 ' - 5.75 \"\n", - "dist2 = 11 ' - 6.25 \"\n", - "dist3 = 29 ' - 0.0 \"\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.13, Page Number: 255" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Distance:\n", - " \n", - " def __init__(self,ft,inc):\n", - " self.__feet = ft\n", - " self.__inches = inc\n", - " \n", - " def getdist(self):\n", - " self.__feet = input('Enter feet:')\n", - " self.__inches = input('Enter inches:')\n", - " \n", - " def showdist(self):\n", - " print self.__feet , '\\' -' , self.__inches , '\\\"'\n", - "\n", - "football = Distance(300,0)\n", - "\n", - "print 'football = ',\n", - "football.showdist()\n", - "\n", - "#There's no const keyword in python" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "football = 300 ' - 0 \"\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AnaySonawane/Solid_State_electronics.ipynb b/sample_notebooks/AnaySonawane/Solid_State_electronics.ipynb new file mode 100755 index 00000000..1839cfe8 --- /dev/null +++ b/sample_notebooks/AnaySonawane/Solid_State_electronics.ipynb @@ -0,0 +1,971 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Introduction to Solid State Electronics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1, Page No. 17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# ne in the doped silicon\n", + "\n", + "import math\n", + "#Variable declaration\n", + "ni=1.5*10**16 # in m^-3\n", + "nh=4.5*10**22 # in m^-3\n", + "\n", + "#Calculations\n", + "ne=ni**2/nh\n", + "\n", + "#Result\n", + "print(\" ne in the doped silicon is,(m^-3) = %.f * 10^9\"%(ne/10**9))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " ne in the doped silicon is,(m^-3) = 5 * 10^9\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2, Page No. 17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "\n", + "ne=8.0*10**19 # in m^-3\n", + "nh=5.0*10**18 # in m^-3\n", + "mu_e=2.3 # in m^2/V-s\n", + "mu_h=.01 # in m^2/V-s\n", + "e=1.6*10**-19 # in V\n", + "\n", + "#Calculations\n", + "p=1/(e*((ne*mu_e)+(nh*mu_h)));\n", + "\n", + "#Result\n", + "print(\"(b) the resistivity,p(ohm-m)= %.1f * 10^-2\"%(p*10**2))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(b) the resistivity,p(ohm-m)= 3.4 * 10^-2\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3, Page No. 17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Density\n", + "\n", + "import math\n", + "#Variable declaration\n", + "\n", + "sigma=500.0 # in ohm^-1 m^-1\n", + "mu_e=0.39 # m^2/V-s\n", + "e=1.6*10**-19 # in V\n", + "\n", + "#Calculations\n", + "ne=sigma/(e*mu_e);\n", + "\n", + "#Result\n", + "print(\"number density of donor,ne(m^-3) = %.2f * 10^21\"%(ne*10**-21))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "number density of donor,ne(m^-3) = 8.01 * 10^21\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4, Page No. 18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Density\n", + "\n", + "import math\n", + "#Variable declaration\n", + "\n", + "e=1.6*10**-19 # in V\n", + "Pp=10**-2 # p-type silicon in ohm-m\n", + "Pn=10**-2 # n-type silicon in ohm-m\n", + "mu_p=0.048 # holes mobilities in m^2/V-s\n", + "mu_n=0.135 # electrons mobilities in m^2/V-s\n", + "\n", + "#Calculations\n", + "Na=1/(e*mu_p*Pp);\n", + "Nd=1/(e*mu_n*Pn);\n", + "\n", + "#Result\n", + "print(\"(i). the density of impurity,Na (m^-3) = %.1f * 10^22\"%(Na*10**-22))\n", + "print(\"(ii). the density of impurity,Nd (m^-3) = %.2f * 10^21\"%(Nd*10**-21))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i). the density of impurity,Na (m^-3) = 1.3 * 10^22\n", + "(ii). the density of impurity,Nd (m^-3) = 4.63 * 10^21\n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5, Page No. 18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Resistivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # in V\n", + "n=2.5*10**19 # m^3\n", + "p=n\n", + "ni=n\n", + "mu_p=0.17 # holes mobilities in m^2/V-s\n", + "mu_n=0.36 # electrons mobilities in m^2/V-s\n", + "\n", + "#Calculations\n", + "sgint=e*(ni*(mu_p+mu_n)) #electrical conductivity in mho/metre\n", + "pint=1/sgint #resistivity in ohm-meter\n", + "print(\"electrical conductivity is ,(mho/metre)= %.2f\"%sgint)\n", + "print(\"resistivity is ,(ohm-metre)= %.2f\"%pint)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "electrical conductivity is ,(mho/metre)= 2.12\n", + "resistivity is ,(ohm-metre)= 0.47\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6, Page No. 18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Conductivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "\n", + "e=1.6*10**-19 # in V\n", + "ni=1.5*10**16 # in m^3\n", + "mu_p=0.13 # holes mobilities in m^2/V-s\n", + "mu_n=0.05 # electrons mobilities in m^2/V-s\n", + "siat=10.0**8 # number of silicon atoms\n", + "ta=5.0*10**28 # silicon atoms in atoms/m^3\n", + "mu_n2=0.13 # electrons mobilities in m^2/V-s\n", + "siat2=10.0**8 # number of silicon atoms\n", + "ta2=5.0*10**28 # silicon atoms in atoms/m^3\n", + "mu_p2=0.05 # holes mobilities in m^2/V-s\n", + "\n", + "#Calculations\n", + "sgint=e*(ni*(mu_p+mu_n)) # electrical conductivity in mho/m\n", + "Nd=ta/siat # in atoms/m^3\n", + "p= ni**2/Nd # holes concentration in holes/m^3\n", + "n=Nd\n", + "sntype=e*n*mu_n2 # in mho/m\n", + "Na=ta2/siat2 # in atoms/m^3\n", + "n= ni**2/Na # holes concentration in holes/m^3\n", + "sptype=e*Na*mu_p2 # in mho/m\n", + "\n", + "#Calculations\n", + "print(\"(i) electrical conductivity is ,(mhos/m) = %.2f * 10^-4\"%(sgint*10**4))\n", + "print(\"(ii) holes concentration is, (holes/m^3) = %.1f *10^11\"%(p*10**-11))\n", + "print(\"(ii) conductivity is ,(mho/m) = %.1f\"%sntype)\n", + "print(\"(iii) electron concentration is, (holes/m^3)= %.1f * 10^11\"%(n/10**11))\n", + "print(\"(iii) conductivity is ,(mho/m) = %.1f\"%sptype)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) electrical conductivity is ,(mhos/m) = 4.32 * 10^-4\n", + "(ii) holes concentration is, (holes/m^3) = 4.5 *10^11\n", + "(ii) conductivity is ,(mho/m) = 10.4\n", + "(iii) electron concentration is, (holes/m^3)= 4.5 * 10^11\n", + "(iii) conductivity is ,(mho/m) = 4.0\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, Page No. 19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Fermi Level\n", + "\n", + "import math\n", + "#Variable declaration\n", + "#Nd1=Nc*exp^-(Ec-Ef1)/kT ...Formula Used\n", + "Nc=1.0 #assume\n", + "kT=0.03 #eV\n", + "EcEf1=0.5 #position of Fermi level in V\n", + "Nd=1.0 #assume\n", + "Nd1=3*Nd #After tripling the donor concentration\n", + "\n", + "#Calculation\n", + "EcEf2=(EcEf1-(kT*(math.log(Nd1/Nd))))\n", + "print(\"new position of Fermi-level is %.3f eV below conduction band\"%(math.ceil(EcEf2*1000)/1000))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "new position of Fermi-level is 0.468 eV below conduction band\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8, Page No. 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# density\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # in V\n", + "Pp=10**-1 # p-type silicon in ohm-m\n", + "Pn=10**-1 # n-type silicon in ohm-m\n", + "mu_h=0.05 # holes mobilities in m^2/V-s\n", + "mu_e=0.13 # electrons mobilities in m^2/V-s\n", + "\n", + "#Calculations\n", + "Na=1/(e*mu_h*Pp);\n", + "Nd=1/(e*mu_e*Pn);\n", + "\n", + "#Result\n", + "print(\"(i). the density of impurity,Na (m^-3) = %.2f * 10^21\"%(Na/10**21))\n", + "print(\"(ii). the density of impurity,Nd (m^-3) = %.1f * 10^20\"%(Nd/10**20))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i). the density of impurity,Na (m^-3) = 1.25 * 10^21\n", + "(ii). the density of impurity,Nd (m^-3) = 4.8 * 10^20\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9, Page No. 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# current\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # in V\n", + "Pp=10**-1 # p-type silicon in ohm-m\n", + "Pn=10**-1 # n-type silicon in ohm-m\n", + "mu_hsi=0.048 # holes mobilities in m^2/V-s\n", + "mu_esi=0.135 # electrons mobilities in m^2/V-s\n", + "nisi=1.5*10**16 # in m^-3\n", + "nesi=nisi\n", + "nhsi=nisi\n", + "mu_hge=0.19 # holes mobilities in m^2/V-s\n", + "mu_ege=0.39 # electrons mobilities in m^2/V-s\n", + "A=1*10**-4 # area in m^2\n", + "nige=2.4*10**19 # in m^-3\n", + "V=2.0 # in V\n", + "l=0.1 # in m\n", + "\n", + "#Calculations\n", + "Isi= e*A*(V/l)*((nesi*mu_esi)+(nhsi*mu_hsi))\n", + "#Current for silicon is calculated wrong in the textbook\n", + "nege=nige\n", + "nhge=nige\n", + "Ige= e*A*(V/l)*((nege*mu_ege)+(nhge*mu_hge))\n", + "\n", + "#Result\n", + "print(\"Total current for silicon is,(A) = %f\"%Isi)\n", + "print(\"Total current for germanium is,(A)= %.2f * 10^-3\"%(math.ceil(Ige*10**5)/100))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total current for silicon is,(A) = 0.000001\n", + "Total current for germanium is,(A)= 4.46 * 10^-3\n" + ] + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.10, Page No. 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# hole concentration and conductivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "nh=2*10**21 # acceptor atoms in atoms/m^3\n", + "mu_h=0.17 # mobility of holes in m^2/V-s\n", + "e=1.6*10**-19 # in C\n", + "\n", + "#Calculations\n", + "Na=nh\n", + "sigma=nh*mu_h*e;\n", + "\n", + "#Result\n", + "print(\"hole concentration,Na(atoms/m^3) = %.1f * 10^21\"%(Na/10**21))\n", + "print(\"conductivity,(ohm^-1-m^-1) = %.1f\"%sigma)\n", + "#conductivity is calculated wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "hole concentration,Na(atoms/m^3) = 2.0 * 10^21\n", + "conductivity,(ohm^-1-m^-1) = 54.4\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.11, Page No. 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# donor concentration\n", + "\n", + "import math\n", + "#Variable declaration\n", + "p=0.15 # in ohm-m\n", + "mu_e=0.39 # mobility of electron in m^2/V-s\n", + "e=1.6*10**-19 # in C\n", + "\n", + "#Calculations\n", + "Na=1/(e*mu_e*p);\n", + "\n", + "#Result\n", + "print(\"The value of donor concentration,Na(m^-3) = %.2f * 10^20\"%(Na/10**20))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of donor concentration,Na(m^-3) = 1.07 * 10^20\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.12, Page No. 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "mu_n=0.13 # in m^2/V-s\n", + "mu_p=0.05 # in m^2/V-s\n", + "ni=1.5*10**16 # in m^-3\n", + "e=1.6*10**-19 # in C\n", + "\n", + "#Calculations\n", + "p=1/((e*ni)*(mu_n+mu_p));\n", + "\n", + "#Result\n", + "print(\"The resistivity,p(ohm-m) = %.1f\"%p)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resistivity,p(ohm-m) = 2314.8\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.13, Page No. 37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# current\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # electron charge in coulombs\n", + "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", + "T=300.0 # in Kelvin\n", + "I=240.0 # in mA\n", + "eta=2.0\n", + "Ve=0.8 # in V\n", + "V=0.7 # in V\n", + "\n", + "\n", + "#Calculations\n", + "Vt=(k*T)/e # in V\n", + "Id=I*math.e**((V-Ve)/(eta*Vt)) #in mA\n", + "Ir=(I/((math.e**(Ve/(eta*Vt)))-1))*10**6\n", + "\n", + "\n", + "#Result\n", + "print(\"(i) Current is ,(mA) = %.f\"%(round(Id)))\n", + "print(\"(ii) reverse saturation current is ,(nA) = %.f\"%(round(Ir)))\n", + "#reverse saturation current is calculated wrong in the textbook" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Current is ,(mA) = 35\n", + "(ii) reverse saturation current is ,(nA) = 46\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.14, Page No. 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# diode current and voltage\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # electron charge in coulombs\n", + "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", + "T=300.0 # in Kelvin\n", + "Ir1=10**-10 # in A\n", + "Ir2=10**-12 # in A \n", + "V211=0.5 # in V\n", + "\n", + "#Calculations\n", + "Vt=(k*T)/e\n", + "Vt = math.ceil(Vt*1000)/1000\n", + "V21=((Vt)*math.log10(Ir1/Ir2))*2.3026\n", + "V21 = math.floor(V21*10000)/10000\n", + "V2=(1.0/2)*(V21+V211)\n", + "V1=(1.0/2)*(V211-V21)\n", + "I1=Ir2*math.e**(V2/Vt)*10**6\n", + "I2=I1\n", + "\n", + "#Result\n", + "print(\"diode voltage V2 is ,(V) = %.5f\"%V2)\n", + "print(\"diode voltage V1 is ,(V) = %.5f\"%V1)\n", + "print(\"diode current is,(micro-A) = %.4f\"%I1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "diode voltage V2 is ,(V) = 0.30985\n", + "diode voltage V1 is ,(V) = 0.19015\n", + "diode current is,(micro-A) = 0.1498\n" + ] + } + ], + "prompt_number": 50 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.15, Page No. 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# voltage\n", + "\n", + "import math\n", + "#Variable declaration\n", + "e=1.6*10**-19 # electron charge in coulombs\n", + "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", + "T=300.0 # in Kelvin\n", + "Ir1=10**-12 # in A\n", + "Ir2=10**-10 # in A\n", + "It=2.0 # mA\n", + "\n", + "#Calculations\n", + "I21=Ir2/Ir1\n", + "Vt=(k*T)/e # in V\n", + "Vt = math.ceil(Vt*1000)/1000\n", + "I1=It/(1+I21)*10**3 # in micro-A\n", + "I2=It*10**3-I1 # in micro-A\n", + "I1=I2/I21 # in micro-A\n", + "x=((I1*10**-6)/Ir1)\n", + "V=Vt*math.log10(x)*2.3026\n", + "\n", + "#Result\n", + "print(\"diode voltage is ,(V) = %.3f\"%V)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "diode voltage is ,(V) = 0.437\n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.16, Page No. 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# voltage\n", + "\n", + "import math\n", + "#Variable declaration\n", + "T=27.0 # degree Celsius\n", + "Tk=273+T # in Kelvin\n", + "e=1.6*10**-19 # electron charge in coulombs\n", + "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", + "J=10**4 # in Amp/m^2\n", + "Jo=200.0 #in mA/m^2\n", + "\n", + "#Calculations\n", + "x=(J/(Jo*10**-3))\n", + "Ve=((math.log(x))*k*Tk)/e\n", + "\n", + "#Result\n", + "print(\"voltage to be applied is ,(V) = %.2f\"%Ve)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "voltage to be applied is ,(V) = 0.28\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.17, Page No. 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "V=3.0 # in V\n", + "I=55.0 # in mA\n", + "V2=26.0 # in mV\n", + "\n", + "\n", + "#Calculations\n", + "Rdc=V/(I*10**-3) # in ohm\n", + "Rac=V2/I # in ohm\n", + "\n", + "#Result\n", + "print(\"static resistance is ,(ohm) = %.1f\"%Rdc)\n", + "print(\"dynamic resistance is ,(ohm) = %.2f\"%Rac)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "static resistance is ,(ohm) = 54.5\n", + "dynamic resistance is ,(ohm) = 0.47\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.18, Page No. 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "k=1.38*10**-23 # constant\n", + "T=27+273.0 # in K\n", + "eta=2.0\n", + "e=1.6*10**-19 # in C\n", + "Vt=(k*T/e) # in V\n", + "V=0.5 # in V\n", + "Ir=10**-6 # in A\n", + "\n", + "#Calculations\n", + "I=(Ir*10**3*(math.e**(V/(eta*Vt))-1))\n", + "R_dc=V*10**3/I;\n", + "R_ac=(eta*k*T)/(e*I*10**-3);\n", + "\n", + "#Result\n", + "print(\"static resistance,R_dc(ohm) = %.1f\"%R_dc)\n", + "print(\"Dynamic resistance,R_ac(ohm) = %.1f\"%R_ac)\n", + "#answer is wrong in textbook" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "static resistance,R_dc(ohm) = 31.8\n", + "Dynamic resistance,R_ac(ohm) = 3.3\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.19, Page No. 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "V=1.2 # in V\n", + "Vk=0.7 # in V\n", + "I_F=100.0 # in mA\n", + "V_R=10.0 # in V\n", + "I_R=1.0 # in micro-A\n", + "I=5.0 # in mA\n", + "eta=2\n", + "\n", + "#Calculations\n", + "R_B=(V-Vk)/(I_F*10**-3)\n", + "R_R=V_R/I_R\n", + "R_ac=eta*26/I\n", + "\n", + "#Result\n", + "print(\"the bulk resistance,R_B(ohm) = %.f\"%R_B)\n", + "print(\"the reverse resistance,R_R(M-ohm) = %.f\"%R_R)\n", + "print(\"ac resistance,R_ac(ohm) = %.1f\"%R_ac)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the bulk resistance,R_B(ohm) = 5\n", + "the reverse resistance,R_R(M-ohm) = 10\n", + "ac resistance,R_ac(ohm) = 10.4\n" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.20, Page No. 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# capacitance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "epsilon_0=8.85*10**-12 # in farada/m\n", + "K=12.0 # constant for silicon\n", + "A=1*10**-8 # in m^2\n", + "W=5*10**-7 # in m\n", + "\n", + "#Calculations\n", + "epsilon=epsilon_0*K\n", + "Ct=epsilon*A*10**14/W;\n", + "\n", + "#Result\n", + "print(\"the transition capacitance,Ct(PF) = %.1f\"%Ct)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the transition capacitance,Ct(PF) = 212.4\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.21, Page No. 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "V=0.2 # in V\n", + "I=1.0 # in micro-A\n", + "\n", + "#Calculations\n", + "R_dc=V*10**3/I\n", + "R_ac=26/(I*10**3);\n", + "\n", + "#Result\n", + "print(\"The static resistance,R_ac(k-ohm) = %.f\"%R_dc)\n", + "print(\"the dynamic resistance,R_ac(ohm) = %.3f\"%R_ac)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The static resistance,R_ac(k-ohm) = 200\n", + "the dynamic resistance,R_ac(ohm) = 0.026\n" + ] + } + ], + "prompt_number": 55 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AnaySonawane/Solid_State_electronics_Ch1.ipynb b/sample_notebooks/AnaySonawane/Solid_State_electronics_Ch1.ipynb deleted file mode 100755 index 1839cfe8..00000000 --- a/sample_notebooks/AnaySonawane/Solid_State_electronics_Ch1.ipynb +++ /dev/null @@ -1,971 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 : Introduction to Solid State Electronics" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1, Page No. 17" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# ne in the doped silicon\n", - "\n", - "import math\n", - "#Variable declaration\n", - "ni=1.5*10**16 # in m^-3\n", - "nh=4.5*10**22 # in m^-3\n", - "\n", - "#Calculations\n", - "ne=ni**2/nh\n", - "\n", - "#Result\n", - "print(\" ne in the doped silicon is,(m^-3) = %.f * 10^9\"%(ne/10**9))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " ne in the doped silicon is,(m^-3) = 5 * 10^9\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2, Page No. 17" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "\n", - "ne=8.0*10**19 # in m^-3\n", - "nh=5.0*10**18 # in m^-3\n", - "mu_e=2.3 # in m^2/V-s\n", - "mu_h=.01 # in m^2/V-s\n", - "e=1.6*10**-19 # in V\n", - "\n", - "#Calculations\n", - "p=1/(e*((ne*mu_e)+(nh*mu_h)));\n", - "\n", - "#Result\n", - "print(\"(b) the resistivity,p(ohm-m)= %.1f * 10^-2\"%(p*10**2))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(b) the resistivity,p(ohm-m)= 3.4 * 10^-2\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3, Page No. 17" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Density\n", - "\n", - "import math\n", - "#Variable declaration\n", - "\n", - "sigma=500.0 # in ohm^-1 m^-1\n", - "mu_e=0.39 # m^2/V-s\n", - "e=1.6*10**-19 # in V\n", - "\n", - "#Calculations\n", - "ne=sigma/(e*mu_e);\n", - "\n", - "#Result\n", - "print(\"number density of donor,ne(m^-3) = %.2f * 10^21\"%(ne*10**-21))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "number density of donor,ne(m^-3) = 8.01 * 10^21\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4, Page No. 18" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Density\n", - "\n", - "import math\n", - "#Variable declaration\n", - "\n", - "e=1.6*10**-19 # in V\n", - "Pp=10**-2 # p-type silicon in ohm-m\n", - "Pn=10**-2 # n-type silicon in ohm-m\n", - "mu_p=0.048 # holes mobilities in m^2/V-s\n", - "mu_n=0.135 # electrons mobilities in m^2/V-s\n", - "\n", - "#Calculations\n", - "Na=1/(e*mu_p*Pp);\n", - "Nd=1/(e*mu_n*Pn);\n", - "\n", - "#Result\n", - "print(\"(i). the density of impurity,Na (m^-3) = %.1f * 10^22\"%(Na*10**-22))\n", - "print(\"(ii). the density of impurity,Nd (m^-3) = %.2f * 10^21\"%(Nd*10**-21))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i). the density of impurity,Na (m^-3) = 1.3 * 10^22\n", - "(ii). the density of impurity,Nd (m^-3) = 4.63 * 10^21\n" - ] - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5, Page No. 18" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Resistivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # in V\n", - "n=2.5*10**19 # m^3\n", - "p=n\n", - "ni=n\n", - "mu_p=0.17 # holes mobilities in m^2/V-s\n", - "mu_n=0.36 # electrons mobilities in m^2/V-s\n", - "\n", - "#Calculations\n", - "sgint=e*(ni*(mu_p+mu_n)) #electrical conductivity in mho/metre\n", - "pint=1/sgint #resistivity in ohm-meter\n", - "print(\"electrical conductivity is ,(mho/metre)= %.2f\"%sgint)\n", - "print(\"resistivity is ,(ohm-metre)= %.2f\"%pint)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "electrical conductivity is ,(mho/metre)= 2.12\n", - "resistivity is ,(ohm-metre)= 0.47\n" - ] - } - ], - "prompt_number": 30 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6, Page No. 18" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Conductivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "\n", - "e=1.6*10**-19 # in V\n", - "ni=1.5*10**16 # in m^3\n", - "mu_p=0.13 # holes mobilities in m^2/V-s\n", - "mu_n=0.05 # electrons mobilities in m^2/V-s\n", - "siat=10.0**8 # number of silicon atoms\n", - "ta=5.0*10**28 # silicon atoms in atoms/m^3\n", - "mu_n2=0.13 # electrons mobilities in m^2/V-s\n", - "siat2=10.0**8 # number of silicon atoms\n", - "ta2=5.0*10**28 # silicon atoms in atoms/m^3\n", - "mu_p2=0.05 # holes mobilities in m^2/V-s\n", - "\n", - "#Calculations\n", - "sgint=e*(ni*(mu_p+mu_n)) # electrical conductivity in mho/m\n", - "Nd=ta/siat # in atoms/m^3\n", - "p= ni**2/Nd # holes concentration in holes/m^3\n", - "n=Nd\n", - "sntype=e*n*mu_n2 # in mho/m\n", - "Na=ta2/siat2 # in atoms/m^3\n", - "n= ni**2/Na # holes concentration in holes/m^3\n", - "sptype=e*Na*mu_p2 # in mho/m\n", - "\n", - "#Calculations\n", - "print(\"(i) electrical conductivity is ,(mhos/m) = %.2f * 10^-4\"%(sgint*10**4))\n", - "print(\"(ii) holes concentration is, (holes/m^3) = %.1f *10^11\"%(p*10**-11))\n", - "print(\"(ii) conductivity is ,(mho/m) = %.1f\"%sntype)\n", - "print(\"(iii) electron concentration is, (holes/m^3)= %.1f * 10^11\"%(n/10**11))\n", - "print(\"(iii) conductivity is ,(mho/m) = %.1f\"%sptype)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) electrical conductivity is ,(mhos/m) = 4.32 * 10^-4\n", - "(ii) holes concentration is, (holes/m^3) = 4.5 *10^11\n", - "(ii) conductivity is ,(mho/m) = 10.4\n", - "(iii) electron concentration is, (holes/m^3)= 4.5 * 10^11\n", - "(iii) conductivity is ,(mho/m) = 4.0\n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, Page No. 19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Fermi Level\n", - "\n", - "import math\n", - "#Variable declaration\n", - "#Nd1=Nc*exp^-(Ec-Ef1)/kT ...Formula Used\n", - "Nc=1.0 #assume\n", - "kT=0.03 #eV\n", - "EcEf1=0.5 #position of Fermi level in V\n", - "Nd=1.0 #assume\n", - "Nd1=3*Nd #After tripling the donor concentration\n", - "\n", - "#Calculation\n", - "EcEf2=(EcEf1-(kT*(math.log(Nd1/Nd))))\n", - "print(\"new position of Fermi-level is %.3f eV below conduction band\"%(math.ceil(EcEf2*1000)/1000))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "new position of Fermi-level is 0.468 eV below conduction band\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8, Page No. 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# density\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # in V\n", - "Pp=10**-1 # p-type silicon in ohm-m\n", - "Pn=10**-1 # n-type silicon in ohm-m\n", - "mu_h=0.05 # holes mobilities in m^2/V-s\n", - "mu_e=0.13 # electrons mobilities in m^2/V-s\n", - "\n", - "#Calculations\n", - "Na=1/(e*mu_h*Pp);\n", - "Nd=1/(e*mu_e*Pn);\n", - "\n", - "#Result\n", - "print(\"(i). the density of impurity,Na (m^-3) = %.2f * 10^21\"%(Na/10**21))\n", - "print(\"(ii). the density of impurity,Nd (m^-3) = %.1f * 10^20\"%(Nd/10**20))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i). the density of impurity,Na (m^-3) = 1.25 * 10^21\n", - "(ii). the density of impurity,Nd (m^-3) = 4.8 * 10^20\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9, Page No. 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# current\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # in V\n", - "Pp=10**-1 # p-type silicon in ohm-m\n", - "Pn=10**-1 # n-type silicon in ohm-m\n", - "mu_hsi=0.048 # holes mobilities in m^2/V-s\n", - "mu_esi=0.135 # electrons mobilities in m^2/V-s\n", - "nisi=1.5*10**16 # in m^-3\n", - "nesi=nisi\n", - "nhsi=nisi\n", - "mu_hge=0.19 # holes mobilities in m^2/V-s\n", - "mu_ege=0.39 # electrons mobilities in m^2/V-s\n", - "A=1*10**-4 # area in m^2\n", - "nige=2.4*10**19 # in m^-3\n", - "V=2.0 # in V\n", - "l=0.1 # in m\n", - "\n", - "#Calculations\n", - "Isi= e*A*(V/l)*((nesi*mu_esi)+(nhsi*mu_hsi))\n", - "#Current for silicon is calculated wrong in the textbook\n", - "nege=nige\n", - "nhge=nige\n", - "Ige= e*A*(V/l)*((nege*mu_ege)+(nhge*mu_hge))\n", - "\n", - "#Result\n", - "print(\"Total current for silicon is,(A) = %f\"%Isi)\n", - "print(\"Total current for germanium is,(A)= %.2f * 10^-3\"%(math.ceil(Ige*10**5)/100))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total current for silicon is,(A) = 0.000001\n", - "Total current for germanium is,(A)= 4.46 * 10^-3\n" - ] - } - ], - "prompt_number": 41 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.10, Page No. 21" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# hole concentration and conductivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "nh=2*10**21 # acceptor atoms in atoms/m^3\n", - "mu_h=0.17 # mobility of holes in m^2/V-s\n", - "e=1.6*10**-19 # in C\n", - "\n", - "#Calculations\n", - "Na=nh\n", - "sigma=nh*mu_h*e;\n", - "\n", - "#Result\n", - "print(\"hole concentration,Na(atoms/m^3) = %.1f * 10^21\"%(Na/10**21))\n", - "print(\"conductivity,(ohm^-1-m^-1) = %.1f\"%sigma)\n", - "#conductivity is calculated wrong in the book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "hole concentration,Na(atoms/m^3) = 2.0 * 10^21\n", - "conductivity,(ohm^-1-m^-1) = 54.4\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.11, Page No. 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# donor concentration\n", - "\n", - "import math\n", - "#Variable declaration\n", - "p=0.15 # in ohm-m\n", - "mu_e=0.39 # mobility of electron in m^2/V-s\n", - "e=1.6*10**-19 # in C\n", - "\n", - "#Calculations\n", - "Na=1/(e*mu_e*p);\n", - "\n", - "#Result\n", - "print(\"The value of donor concentration,Na(m^-3) = %.2f * 10^20\"%(Na/10**20))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of donor concentration,Na(m^-3) = 1.07 * 10^20\n" - ] - } - ], - "prompt_number": 28 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.12, Page No. 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "mu_n=0.13 # in m^2/V-s\n", - "mu_p=0.05 # in m^2/V-s\n", - "ni=1.5*10**16 # in m^-3\n", - "e=1.6*10**-19 # in C\n", - "\n", - "#Calculations\n", - "p=1/((e*ni)*(mu_n+mu_p));\n", - "\n", - "#Result\n", - "print(\"The resistivity,p(ohm-m) = %.1f\"%p)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The resistivity,p(ohm-m) = 2314.8\n" - ] - } - ], - "prompt_number": 30 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.13, Page No. 37" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# current\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # electron charge in coulombs\n", - "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", - "T=300.0 # in Kelvin\n", - "I=240.0 # in mA\n", - "eta=2.0\n", - "Ve=0.8 # in V\n", - "V=0.7 # in V\n", - "\n", - "\n", - "#Calculations\n", - "Vt=(k*T)/e # in V\n", - "Id=I*math.e**((V-Ve)/(eta*Vt)) #in mA\n", - "Ir=(I/((math.e**(Ve/(eta*Vt)))-1))*10**6\n", - "\n", - "\n", - "#Result\n", - "print(\"(i) Current is ,(mA) = %.f\"%(round(Id)))\n", - "print(\"(ii) reverse saturation current is ,(nA) = %.f\"%(round(Ir)))\n", - "#reverse saturation current is calculated wrong in the textbook" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Current is ,(mA) = 35\n", - "(ii) reverse saturation current is ,(nA) = 46\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.14, Page No. 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# diode current and voltage\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # electron charge in coulombs\n", - "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", - "T=300.0 # in Kelvin\n", - "Ir1=10**-10 # in A\n", - "Ir2=10**-12 # in A \n", - "V211=0.5 # in V\n", - "\n", - "#Calculations\n", - "Vt=(k*T)/e\n", - "Vt = math.ceil(Vt*1000)/1000\n", - "V21=((Vt)*math.log10(Ir1/Ir2))*2.3026\n", - "V21 = math.floor(V21*10000)/10000\n", - "V2=(1.0/2)*(V21+V211)\n", - "V1=(1.0/2)*(V211-V21)\n", - "I1=Ir2*math.e**(V2/Vt)*10**6\n", - "I2=I1\n", - "\n", - "#Result\n", - "print(\"diode voltage V2 is ,(V) = %.5f\"%V2)\n", - "print(\"diode voltage V1 is ,(V) = %.5f\"%V1)\n", - "print(\"diode current is,(micro-A) = %.4f\"%I1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "diode voltage V2 is ,(V) = 0.30985\n", - "diode voltage V1 is ,(V) = 0.19015\n", - "diode current is,(micro-A) = 0.1498\n" - ] - } - ], - "prompt_number": 50 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.15, Page No. 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# voltage\n", - "\n", - "import math\n", - "#Variable declaration\n", - "e=1.6*10**-19 # electron charge in coulombs\n", - "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", - "T=300.0 # in Kelvin\n", - "Ir1=10**-12 # in A\n", - "Ir2=10**-10 # in A\n", - "It=2.0 # mA\n", - "\n", - "#Calculations\n", - "I21=Ir2/Ir1\n", - "Vt=(k*T)/e # in V\n", - "Vt = math.ceil(Vt*1000)/1000\n", - "I1=It/(1+I21)*10**3 # in micro-A\n", - "I2=It*10**3-I1 # in micro-A\n", - "I1=I2/I21 # in micro-A\n", - "x=((I1*10**-6)/Ir1)\n", - "V=Vt*math.log10(x)*2.3026\n", - "\n", - "#Result\n", - "print(\"diode voltage is ,(V) = %.3f\"%V)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "diode voltage is ,(V) = 0.437\n" - ] - } - ], - "prompt_number": 53 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.16, Page No. 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# voltage\n", - "\n", - "import math\n", - "#Variable declaration\n", - "T=27.0 # degree Celsius\n", - "Tk=273+T # in Kelvin\n", - "e=1.6*10**-19 # electron charge in coulombs\n", - "k=1.38*10**-23 # Boltzmann constant in m^2-kg/s^2-K^-1\n", - "J=10**4 # in Amp/m^2\n", - "Jo=200.0 #in mA/m^2\n", - "\n", - "#Calculations\n", - "x=(J/(Jo*10**-3))\n", - "Ve=((math.log(x))*k*Tk)/e\n", - "\n", - "#Result\n", - "print(\"voltage to be applied is ,(V) = %.2f\"%Ve)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "voltage to be applied is ,(V) = 0.28\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.17, Page No. 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "V=3.0 # in V\n", - "I=55.0 # in mA\n", - "V2=26.0 # in mV\n", - "\n", - "\n", - "#Calculations\n", - "Rdc=V/(I*10**-3) # in ohm\n", - "Rac=V2/I # in ohm\n", - "\n", - "#Result\n", - "print(\"static resistance is ,(ohm) = %.1f\"%Rdc)\n", - "print(\"dynamic resistance is ,(ohm) = %.2f\"%Rac)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "static resistance is ,(ohm) = 54.5\n", - "dynamic resistance is ,(ohm) = 0.47\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.18, Page No. 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "k=1.38*10**-23 # constant\n", - "T=27+273.0 # in K\n", - "eta=2.0\n", - "e=1.6*10**-19 # in C\n", - "Vt=(k*T/e) # in V\n", - "V=0.5 # in V\n", - "Ir=10**-6 # in A\n", - "\n", - "#Calculations\n", - "I=(Ir*10**3*(math.e**(V/(eta*Vt))-1))\n", - "R_dc=V*10**3/I;\n", - "R_ac=(eta*k*T)/(e*I*10**-3);\n", - "\n", - "#Result\n", - "print(\"static resistance,R_dc(ohm) = %.1f\"%R_dc)\n", - "print(\"Dynamic resistance,R_ac(ohm) = %.1f\"%R_ac)\n", - "#answer is wrong in textbook" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "static resistance,R_dc(ohm) = 31.8\n", - "Dynamic resistance,R_ac(ohm) = 3.3\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.19, Page No. 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "V=1.2 # in V\n", - "Vk=0.7 # in V\n", - "I_F=100.0 # in mA\n", - "V_R=10.0 # in V\n", - "I_R=1.0 # in micro-A\n", - "I=5.0 # in mA\n", - "eta=2\n", - "\n", - "#Calculations\n", - "R_B=(V-Vk)/(I_F*10**-3)\n", - "R_R=V_R/I_R\n", - "R_ac=eta*26/I\n", - "\n", - "#Result\n", - "print(\"the bulk resistance,R_B(ohm) = %.f\"%R_B)\n", - "print(\"the reverse resistance,R_R(M-ohm) = %.f\"%R_R)\n", - "print(\"ac resistance,R_ac(ohm) = %.1f\"%R_ac)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the bulk resistance,R_B(ohm) = 5\n", - "the reverse resistance,R_R(M-ohm) = 10\n", - "ac resistance,R_ac(ohm) = 10.4\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.20, Page No. 41" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# capacitance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "epsilon_0=8.85*10**-12 # in farada/m\n", - "K=12.0 # constant for silicon\n", - "A=1*10**-8 # in m^2\n", - "W=5*10**-7 # in m\n", - "\n", - "#Calculations\n", - "epsilon=epsilon_0*K\n", - "Ct=epsilon*A*10**14/W;\n", - "\n", - "#Result\n", - "print(\"the transition capacitance,Ct(PF) = %.1f\"%Ct)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the transition capacitance,Ct(PF) = 212.4\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.21, Page No. 41" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "V=0.2 # in V\n", - "I=1.0 # in micro-A\n", - "\n", - "#Calculations\n", - "R_dc=V*10**3/I\n", - "R_ac=26/(I*10**3);\n", - "\n", - "#Result\n", - "print(\"The static resistance,R_ac(k-ohm) = %.f\"%R_dc)\n", - "print(\"the dynamic resistance,R_ac(ohm) = %.3f\"%R_ac)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The static resistance,R_ac(k-ohm) = 200\n", - "the dynamic resistance,R_ac(ohm) = 0.026\n" - ] - } - ], - "prompt_number": 55 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AnkitKumar/AnkitKumar_version_backup/Ch16.ipynb b/sample_notebooks/AnkitKumar/AnkitKumar_version_backup/Ch16.ipynb new file mode 100755 index 00000000..86539c04 --- /dev/null +++ b/sample_notebooks/AnkitKumar/AnkitKumar_version_backup/Ch16.ipynb @@ -0,0 +1,364 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 16 : Electrical Energy & Capacitance" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.1 Page No : 533" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of E = 4000.00 v/m\n" + ] + } + ], + "source": [ + "v_bminusv_a=-12\n", + "d=0.3*10**-2#in m\n", + "E=-(v_bminusv_a)/d\n", + "print \"The value of E = %0.2f v/m\"%E" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.2 Page No : 533" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "solution a\n", + "Electric potential from A to B = -40000.00 V\n", + "solution b\n", + "Change in electric potential = -0.00 joules\n", + "velocity = 2768514.16 m/s\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "print \"solution a\"\n", + "E=8*10**4#in V/m\n", + "d=0.5#in m\n", + "delta_V=-E*d\n", + "print \"Electric potential from A to B = %0.2f V\"%delta_V\n", + "print \"solution b\"\n", + "q=1.6*10**-19#in C\n", + "delta_PE=q*delta_V\n", + "print \"Change in electric potential = %0.2f joules\"%delta_PE\n", + "m_p=1.67*10**-27#in kg\n", + "vf=sqrt((2*-delta_PE)/m_p)\n", + "print \"velocity = %0.2f m/s\"%vf" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.3 Page No: 534" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Solution a\n", + "Magnitude of V1 = 112375.00 v\n", + "Magnitude of V2 = -35960.00 v\n", + "solution b\n", + "Magnitude of Vp = 76415.00 v\n", + "work done = 0.31 Joule\n" + ] + } + ], + "source": [ + "k_e=8.99*10**9 #N.m**2/c**2\n", + "q1=5*10**-6# in C\n", + "q2=-2*10**-6#in C\n", + "r1=0.4\n", + "r2=0.5\n", + "V1=(k_e*q1)/(r1)\n", + "V2=(k_e*q2)/(r2)\n", + "print \"Solution a\"\n", + "print \"Magnitude of V1 = %0.2f v\"%V1\n", + "print \"Magnitude of V2 = %0.2f v\"%V2\n", + "print \"solution b\"\n", + "vp=V1+V2\n", + "print \"Magnitude of Vp = %0.2f v\"%vp\n", + "q3=4*10**-6#in C\n", + "w=vp*q3\n", + "print \"work done = %0.2f Joule\"%w" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.4 Page No: 535" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Capacitance = 1.77e-12 farad\n" + ] + } + ], + "source": [ + "e0=8.85*10**-12#in c2/N.m2\n", + "A=2*10**-4#in m2\n", + "d=1*10**-3#in m\n", + "c=(e0*A)/d\n", + "print \"Capacitance = %0.2e farad\"%c" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.5 Page No : 535" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "capacitance = 4.50e-05 farad\n", + "voltage between battery = 2.16e-04 c\n" + ] + } + ], + "source": [ + "c1=3*10**-6\n", + "c2=6*10**-6\n", + "c3=12*10**-6\n", + "c4=24*10**-6\n", + "delta_v=18\n", + "c_eq=c1+c2+c3+c4\n", + "print \"capacitance = %0.2e farad\"%c_eq\n", + "q=delta_v*c3\n", + "print \"voltage between battery = %0.2e c\"%q" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.6 Page No : 536" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "solution a\n", + "capacitance = 1.60e-06 farad\n", + "solution b\n", + "voltage between battery = 2.88e-05 c\n" + ] + } + ], + "source": [ + "c1=3*10**-6\n", + "c2=6*10**-6\n", + "c3=12*10**-6\n", + "c4=24*10**-6\n", + "delta_v=18\n", + "print \"solution a\"\n", + "c_eq=1/((1/c1)+(1/c2)+(1/c3)+(1/c4))\n", + "print \"capacitance = %0.2e farad\"%c_eq\n", + "q=delta_v*c_eq\n", + "print \"solution b\"\n", + "print \"voltage between battery = %0.2e c\"%q" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.7 Page No: 536" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "solution a\n", + "capacitance = 2.00e-06 farad\n" + ] + } + ], + "source": [ + "c1=4*10**-6\n", + "c2=4*10**-6\n", + "print \"solution a\"\n", + "c_eq=1/((1/c1)+(1/c2))\n", + "print \"capacitance = %0.2e farad\"%c_eq" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.8 Page No: 537" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "solution a\n", + "Energy stored = 4671 volt\n", + "solution b\n", + "power = 240000 watt\n" + ] + } + ], + "source": [ + "Energy=1.2*10**3#in J\n", + "c=1.1*10**-4#in f\n", + "delta_v=sqrt((2*Energy)/c)\n", + "print \"solution a\"\n", + "print \"Energy stored = %0.f volt\"%delta_v\n", + "print \"solution b\"\n", + "Energy_deliverd=600#in j\n", + "delta_t=2.5*10**-3#in s\n", + "p=(Energy_deliverd)/delta_t\n", + "print \"power = %0.f watt\"%p" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 16.9 Page No: 538" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "solution a\n", + "Capacitance = 1.96e-11 farad\n", + "solution b\n", + "Voltage = 16000.0 volt\n", + "Maximum charge = 3.14e-07 columb\n" + ] + } + ], + "source": [ + "k=3.7\n", + "e0=8.85*10**-12#in c2/N.m2\n", + "A=6*10**-4#in m2\n", + "d=1*10**-3#in m\n", + "c=(k*e0*A)/d\n", + "print \"solution a\"\n", + "print \"Capacitance = %0.2e farad\"%c\n", + "print \"solution b\"\n", + "E_max=16*10**6#in v/m\n", + "delta_v_max=E_max*d\n", + "print \"Voltage = %0.1f volt\"%delta_v_max\n", + "Q_max=delta_v_max*c\n", + "print \"Maximum charge = %0.2e columb\"%Q_max" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AnkitKumar/Ch16.ipynb b/sample_notebooks/AnkitKumar/Ch16.ipynb deleted file mode 100755 index 86539c04..00000000 --- a/sample_notebooks/AnkitKumar/Ch16.ipynb +++ /dev/null @@ -1,364 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 16 : Electrical Energy & Capacitance" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.1 Page No : 533" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of E = 4000.00 v/m\n" - ] - } - ], - "source": [ - "v_bminusv_a=-12\n", - "d=0.3*10**-2#in m\n", - "E=-(v_bminusv_a)/d\n", - "print \"The value of E = %0.2f v/m\"%E" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.2 Page No : 533" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "solution a\n", - "Electric potential from A to B = -40000.00 V\n", - "solution b\n", - "Change in electric potential = -0.00 joules\n", - "velocity = 2768514.16 m/s\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "print \"solution a\"\n", - "E=8*10**4#in V/m\n", - "d=0.5#in m\n", - "delta_V=-E*d\n", - "print \"Electric potential from A to B = %0.2f V\"%delta_V\n", - "print \"solution b\"\n", - "q=1.6*10**-19#in C\n", - "delta_PE=q*delta_V\n", - "print \"Change in electric potential = %0.2f joules\"%delta_PE\n", - "m_p=1.67*10**-27#in kg\n", - "vf=sqrt((2*-delta_PE)/m_p)\n", - "print \"velocity = %0.2f m/s\"%vf" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.3 Page No: 534" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Solution a\n", - "Magnitude of V1 = 112375.00 v\n", - "Magnitude of V2 = -35960.00 v\n", - "solution b\n", - "Magnitude of Vp = 76415.00 v\n", - "work done = 0.31 Joule\n" - ] - } - ], - "source": [ - "k_e=8.99*10**9 #N.m**2/c**2\n", - "q1=5*10**-6# in C\n", - "q2=-2*10**-6#in C\n", - "r1=0.4\n", - "r2=0.5\n", - "V1=(k_e*q1)/(r1)\n", - "V2=(k_e*q2)/(r2)\n", - "print \"Solution a\"\n", - "print \"Magnitude of V1 = %0.2f v\"%V1\n", - "print \"Magnitude of V2 = %0.2f v\"%V2\n", - "print \"solution b\"\n", - "vp=V1+V2\n", - "print \"Magnitude of Vp = %0.2f v\"%vp\n", - "q3=4*10**-6#in C\n", - "w=vp*q3\n", - "print \"work done = %0.2f Joule\"%w" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.4 Page No: 535" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Capacitance = 1.77e-12 farad\n" - ] - } - ], - "source": [ - "e0=8.85*10**-12#in c2/N.m2\n", - "A=2*10**-4#in m2\n", - "d=1*10**-3#in m\n", - "c=(e0*A)/d\n", - "print \"Capacitance = %0.2e farad\"%c" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.5 Page No : 535" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "capacitance = 4.50e-05 farad\n", - "voltage between battery = 2.16e-04 c\n" - ] - } - ], - "source": [ - "c1=3*10**-6\n", - "c2=6*10**-6\n", - "c3=12*10**-6\n", - "c4=24*10**-6\n", - "delta_v=18\n", - "c_eq=c1+c2+c3+c4\n", - "print \"capacitance = %0.2e farad\"%c_eq\n", - "q=delta_v*c3\n", - "print \"voltage between battery = %0.2e c\"%q" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.6 Page No : 536" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "solution a\n", - "capacitance = 1.60e-06 farad\n", - "solution b\n", - "voltage between battery = 2.88e-05 c\n" - ] - } - ], - "source": [ - "c1=3*10**-6\n", - "c2=6*10**-6\n", - "c3=12*10**-6\n", - "c4=24*10**-6\n", - "delta_v=18\n", - "print \"solution a\"\n", - "c_eq=1/((1/c1)+(1/c2)+(1/c3)+(1/c4))\n", - "print \"capacitance = %0.2e farad\"%c_eq\n", - "q=delta_v*c_eq\n", - "print \"solution b\"\n", - "print \"voltage between battery = %0.2e c\"%q" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.7 Page No: 536" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "solution a\n", - "capacitance = 2.00e-06 farad\n" - ] - } - ], - "source": [ - "c1=4*10**-6\n", - "c2=4*10**-6\n", - "print \"solution a\"\n", - "c_eq=1/((1/c1)+(1/c2))\n", - "print \"capacitance = %0.2e farad\"%c_eq" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.8 Page No: 537" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "solution a\n", - "Energy stored = 4671 volt\n", - "solution b\n", - "power = 240000 watt\n" - ] - } - ], - "source": [ - "Energy=1.2*10**3#in J\n", - "c=1.1*10**-4#in f\n", - "delta_v=sqrt((2*Energy)/c)\n", - "print \"solution a\"\n", - "print \"Energy stored = %0.f volt\"%delta_v\n", - "print \"solution b\"\n", - "Energy_deliverd=600#in j\n", - "delta_t=2.5*10**-3#in s\n", - "p=(Energy_deliverd)/delta_t\n", - "print \"power = %0.f watt\"%p" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 16.9 Page No: 538" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "solution a\n", - "Capacitance = 1.96e-11 farad\n", - "solution b\n", - "Voltage = 16000.0 volt\n", - "Maximum charge = 3.14e-07 columb\n" - ] - } - ], - "source": [ - "k=3.7\n", - "e0=8.85*10**-12#in c2/N.m2\n", - "A=6*10**-4#in m2\n", - "d=1*10**-3#in m\n", - "c=(k*e0*A)/d\n", - "print \"solution a\"\n", - "print \"Capacitance = %0.2e farad\"%c\n", - "print \"solution b\"\n", - "E_max=16*10**6#in v/m\n", - "delta_v_max=E_max*d\n", - "print \"Voltage = %0.1f volt\"%delta_v_max\n", - "Q_max=delta_v_max*c\n", - "print \"Maximum charge = %0.2e columb\"%Q_max" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Anshulkhare/Anshulkhare_version_backup/Chapter9.ipynb b/sample_notebooks/Anshulkhare/Anshulkhare_version_backup/Chapter9.ipynb new file mode 100755 index 00000000..7a0b46d8 --- /dev/null +++ b/sample_notebooks/Anshulkhare/Anshulkhare_version_backup/Chapter9.ipynb @@ -0,0 +1,388 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:2221c3190a93e10b0d60c9c13471ed510a28f24c08c158331f416508f81a0bfb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter09:Numerical Solution of Partial Differential Equations" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.1:pg-350" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#standard five point formula\n", + "#example 9.1\n", + "#page 350\n", + "\n", + "u2=5.0;u3=1.0;\n", + "for i in range(0,3):\n", + " u1=(u2+u3+6.0)/4.0;\n", + " u2=(u1/2.0)+(5.0/2.0);\n", + " u3=(u1/2.0)+(1.0/2.0);\n", + " print\" the values are u1=%d\\t u2=%d\\t u3=%d\\t\\n\\n\" %(u1,u2,u3)\n", + " \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " the values are u1=3\t u2=4\t u3=2\t\n", + "\n", + "\n", + " the values are u1=3\t u2=4\t u3=2\t\n", + "\n", + "\n", + " the values are u1=3\t u2=4\t u3=2\t\n", + "\n", + "\n" + ] + } + ], + "prompt_number": 120 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.2:pg-351" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#solution of laplace equation by jacobi method,gauss-seidel method and SOR method\n", + "#example 9.2\n", + "#page 351\n", + "u1=0.25;u2=0.25;u3=0.5;u4=0.5;#initial values\n", + "print \"jacobis iteration process\\n\\n\"\n", + "print\"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n", + "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n", + "for i in range(0,7):\n", + " u11=(0+u2+0+u4)/4\n", + " u22=(u1+0+0+u3)/4\n", + " u33=(1+u2+0+u4)/4\n", + " u44=(1+0+u3+u1)/4\n", + " u1=u11;u2=u22;u3=u33;u4=u44;\n", + " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u11,u22,u33,u44) \n", + "print \" gauss seidel process\\n\\n\"\n", + "u1=0.25;u2=0.3125;u3=0.5625;u4=0.46875;#initial values\n", + "print \"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n", + "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n", + "for i in range(0,4):\n", + "\n", + " u1=(0.0+u2+0.0+u4)/4.0\n", + " u2=(u1+0.0+0.0+u3)/4.0\n", + " u3=(1.0+u2+0.0+u4)/4.0\n", + " u4=(1.0+0.0+u3+u1)/4.0\n", + " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4) \n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "jacobis iteration process\n", + "\n", + "\n", + "u1\t u2\t u3\t u4\t \n", + "\n", + "\n", + "0.250000\t 0.250000\t 0.500000\t 0.500000\t \n", + "\n", + "0.187500\t 0.187500\t 0.437500\t 0.437500\t \n", + "\n", + "0.156250\t 0.156250\t 0.406250\t 0.406250\t \n", + "\n", + "0.140625\t 0.140625\t 0.390625\t 0.390625\t \n", + "\n", + "0.132812\t 0.132812\t 0.382812\t 0.382812\t \n", + "\n", + "0.128906\t 0.128906\t 0.378906\t 0.378906\t \n", + "\n", + "0.126953\t 0.126953\t 0.376953\t 0.376953\t \n", + "\n", + "0.125977\t 0.125977\t 0.375977\t 0.375977\t \n", + "\n", + " gauss seidel process\n", + "\n", + "\n", + "u1\t u2\t u3\t u4\t \n", + "\n", + "\n", + "0.250000\t 0.312500\t 0.562500\t 0.468750\t \n", + "\n", + "0.195312\t 0.189453\t 0.414551\t 0.402466\t \n", + "\n", + "0.147980\t 0.140633\t 0.385775\t 0.383439\t \n", + "\n", + "0.131018\t 0.129198\t 0.378159\t 0.377294\t \n", + "\n", + "0.126623\t 0.126196\t 0.375872\t 0.375624\t \n", + "\n" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.4:pg-354" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#poisson equation\n", + "#exaample 9.4\n", + "#page 354\n", + "u2=0.0;u4=0.0;\n", + "print \" u1\\t u2\\t u3\\t u4\\t\\n\\n\"\n", + "for i in range(0,6):\n", + " u1=(u2/2.0)+30.0\n", + " u2=(u1+u4+150.0)/4.0\n", + " u4=(u2/2.0)+45.0\n", + " print \"%0.2f\\t %0.2f\\t %0.2f\\t %0.2f\\n\" %(u1,u2,u2,u4)\n", + "print \" from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\\n\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " u1\t u2\t u3\t u4\t\n", + "\n", + "\n", + "30.00\t 45.00\t 45.00\t 67.50\n", + "\n", + "52.50\t 67.50\t 67.50\t 78.75\n", + "\n", + "63.75\t 73.12\t 73.12\t 81.56\n", + "\n", + "66.56\t 74.53\t 74.53\t 82.27\n", + "\n", + "67.27\t 74.88\t 74.88\t 82.44\n", + "\n", + "67.44\t 74.97\t 74.97\t 82.49\n", + "\n", + " from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\n", + "\n" + ] + } + ], + "prompt_number": 59 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.6:pg-362" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#bender-schmidt formula\n", + "#example 9.6\n", + "#page 362\n", + "def f(x):\n", + " return (4*x)-(x*x)\n", + "#u=[f(0),f(1),f(2),f(3),f(4)]\n", + "u1=f(0);u2=f(1);u3=f(2);u4=f(3);u5=f(4);\n", + "u11=(u1+u3)/2\n", + "u12=(u2+u4)/2\n", + "u13=(u3+u5)/2\n", + "print \"u11=%0.2f\\t u12=%0.2f\\t u13=%0.2f\\t \\n\" %(u11,u12,u13)\n", + "u21=(u1+u12)/2.0\n", + "u22=(u11+u13)/2.0\n", + "u23=(u12+0)/2.0\n", + "print \"u21=%0.2f\\t u22=%0.2f\\t u23=%0.2f\\t \\n\" %(u21,u22,u23)\n", + "u31=(u1+u22)/2.0\n", + "u32=(u21+u23)/2.0\n", + "u33=(u22+u1)/2.0\n", + "print \"u31=%0.2f\\t u32=%0.2f\\t u33=%0.2f\\t \\n\" % (u31,u32,u33)\n", + "u41=(u1+u32)/2.0\n", + "u42=(u31+u33)/2.0\n", + "u43=(u32+u1)/2.0\n", + "print \"u41=%0.2f\\t u42=%0.2f\\t u43=%0.2f\\t \\n\" % (u41,u42,u43)\n", + "u51=(u1+u42)/2.0\n", + "u52=(u41+u43)/2.0\n", + "u53=(u42+u1)/2.0\n", + "print \"u51=%0.2f\\t u52=%0.2f\\t u53=%0.2f\\t \\n\" % (u51,u52,u53)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "u11=2.00\t u12=3.00\t u13=2.00\t \n", + "\n", + "u21=1.50\t u22=2.00\t u23=1.50\t \n", + "\n", + "u31=1.00\t u32=1.50\t u33=1.00\t \n", + "\n", + "u41=0.75\t u42=1.00\t u43=0.75\t \n", + "\n", + "u51=0.50\t u52=0.75\t u53=0.50\t \n", + "\n" + ] + } + ], + "prompt_number": 77 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.7:pg-363" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#bender-schimdt's formula and crank-nicolson formula\n", + "#example 9.7\n", + "#page 363\n", + "#bender -schimdt's formula\n", + "z=math.pi\n", + "def f(x,t):\n", + " return math.exp(z*z*t*-1)*sin(z*x)\n", + "#u=[f(0,0),f(0.2,0),f(0.4,0),f(0.6,0),f(0.8,0),f(1,0)];\n", + "u1=f(0,0)\n", + "u2=f(0.2,0)\n", + "u3=f(0.4,0)\n", + "u4=f(0.6,0)\n", + "u5=f(0.8,0)\n", + "u6=f(1.0,0)\n", + "u11=u3/2;u12=(u2+u4)/2;u13=u12;u14=u11;\n", + "print \"u11=%f\\t u12=%f\\t u13=%f\\t u14=%f\\n\\n\" % (u11,u12,u13,u14)\n", + "u21=u12/2;u22=(u12+u14)/2;u23=u22;u24=u21;\n", + "print \"u21=%f\\t u22=%f\\t u23=%f\\t u24=%f\\n\\n\" % (u21,u22,u23,u24)\n", + "print \"the error in the solution is: %f\\n\\n\" % (math.fabs(u22-f(0.6,0.04)))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "u11=0.475528\t u12=0.769421\t u13=0.769421\t u14=0.475528\n", + "\n", + "\n", + "u21=0.384710\t u22=0.622475\t u23=0.622475\t u24=0.384710\n", + "\n", + "\n", + "the error in the solution is: 0.018372\n", + "\n", + "\n" + ] + } + ], + "prompt_number": 119 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.8:pg-364" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import matrix\n", + "#heat equation using crank-nicolson method\n", + "#example 9.8\n", + "#page 364\n", + "z=0.01878;\n", + "#h=1/2;l=1/8,i=1\n", + "u01=0.0;u21=1.0/8.0;\n", + "u11=(u21+u01)/6.0;\n", + "print \" u11=%f\\n\\n\" % (u11)\n", + "print \"error is %f\\n\\n\" % (math.fabs(u11-z))\n", + "#h=1/4,l=1/8,i=1,2,3\n", + "A=matrix([['-3' ,'-1' ,'0'],['1','-3','1'],['0','1','-3']])\n", + "C=matrix([['0'],['0'],['-1/8']])\n", + "#here we found inverese of A then we multipy it with C\n", + "u12=0.01786\n", + "print \"u12=%f\\n\\n\" % (u12)\n", + "print \"error is %f\\n\\n\" %(math.fabs(u12-z))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " u11=0.020833\n", + "\n", + "\n", + "error is 0.002053\n", + "\n", + "\n", + "u12=0.017860\n", + "\n", + "\n", + "error is 0.000920\n", + "\n", + "\n" + ] + } + ], + "prompt_number": 105 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Anshulkhare/Chapter9.ipynb b/sample_notebooks/Anshulkhare/Chapter9.ipynb deleted file mode 100755 index 7a0b46d8..00000000 --- a/sample_notebooks/Anshulkhare/Chapter9.ipynb +++ /dev/null @@ -1,388 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:2221c3190a93e10b0d60c9c13471ed510a28f24c08c158331f416508f81a0bfb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter09:Numerical Solution of Partial Differential Equations" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.1:pg-350" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#standard five point formula\n", - "#example 9.1\n", - "#page 350\n", - "\n", - "u2=5.0;u3=1.0;\n", - "for i in range(0,3):\n", - " u1=(u2+u3+6.0)/4.0;\n", - " u2=(u1/2.0)+(5.0/2.0);\n", - " u3=(u1/2.0)+(1.0/2.0);\n", - " print\" the values are u1=%d\\t u2=%d\\t u3=%d\\t\\n\\n\" %(u1,u2,u3)\n", - " \n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " the values are u1=3\t u2=4\t u3=2\t\n", - "\n", - "\n", - " the values are u1=3\t u2=4\t u3=2\t\n", - "\n", - "\n", - " the values are u1=3\t u2=4\t u3=2\t\n", - "\n", - "\n" - ] - } - ], - "prompt_number": 120 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.2:pg-351" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#solution of laplace equation by jacobi method,gauss-seidel method and SOR method\n", - "#example 9.2\n", - "#page 351\n", - "u1=0.25;u2=0.25;u3=0.5;u4=0.5;#initial values\n", - "print \"jacobis iteration process\\n\\n\"\n", - "print\"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n", - "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n", - "for i in range(0,7):\n", - " u11=(0+u2+0+u4)/4\n", - " u22=(u1+0+0+u3)/4\n", - " u33=(1+u2+0+u4)/4\n", - " u44=(1+0+u3+u1)/4\n", - " u1=u11;u2=u22;u3=u33;u4=u44;\n", - " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u11,u22,u33,u44) \n", - "print \" gauss seidel process\\n\\n\"\n", - "u1=0.25;u2=0.3125;u3=0.5625;u4=0.46875;#initial values\n", - "print \"u1\\t u2\\t u3\\t u4\\t \\n\\n\"\n", - "print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4)\n", - "for i in range(0,4):\n", - "\n", - " u1=(0.0+u2+0.0+u4)/4.0\n", - " u2=(u1+0.0+0.0+u3)/4.0\n", - " u3=(1.0+u2+0.0+u4)/4.0\n", - " u4=(1.0+0.0+u3+u1)/4.0\n", - " print \"%f\\t %f\\t %f\\t %f\\t \\n\" %(u1,u2,u3,u4) \n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "jacobis iteration process\n", - "\n", - "\n", - "u1\t u2\t u3\t u4\t \n", - "\n", - "\n", - "0.250000\t 0.250000\t 0.500000\t 0.500000\t \n", - "\n", - "0.187500\t 0.187500\t 0.437500\t 0.437500\t \n", - "\n", - "0.156250\t 0.156250\t 0.406250\t 0.406250\t \n", - "\n", - "0.140625\t 0.140625\t 0.390625\t 0.390625\t \n", - "\n", - "0.132812\t 0.132812\t 0.382812\t 0.382812\t \n", - "\n", - "0.128906\t 0.128906\t 0.378906\t 0.378906\t \n", - "\n", - "0.126953\t 0.126953\t 0.376953\t 0.376953\t \n", - "\n", - "0.125977\t 0.125977\t 0.375977\t 0.375977\t \n", - "\n", - " gauss seidel process\n", - "\n", - "\n", - "u1\t u2\t u3\t u4\t \n", - "\n", - "\n", - "0.250000\t 0.312500\t 0.562500\t 0.468750\t \n", - "\n", - "0.195312\t 0.189453\t 0.414551\t 0.402466\t \n", - "\n", - "0.147980\t 0.140633\t 0.385775\t 0.383439\t \n", - "\n", - "0.131018\t 0.129198\t 0.378159\t 0.377294\t \n", - "\n", - "0.126623\t 0.126196\t 0.375872\t 0.375624\t \n", - "\n" - ] - } - ], - "prompt_number": 51 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.4:pg-354" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#poisson equation\n", - "#exaample 9.4\n", - "#page 354\n", - "u2=0.0;u4=0.0;\n", - "print \" u1\\t u2\\t u3\\t u4\\t\\n\\n\"\n", - "for i in range(0,6):\n", - " u1=(u2/2.0)+30.0\n", - " u2=(u1+u4+150.0)/4.0\n", - " u4=(u2/2.0)+45.0\n", - " print \"%0.2f\\t %0.2f\\t %0.2f\\t %0.2f\\n\" %(u1,u2,u2,u4)\n", - "print \" from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\\n\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " u1\t u2\t u3\t u4\t\n", - "\n", - "\n", - "30.00\t 45.00\t 45.00\t 67.50\n", - "\n", - "52.50\t 67.50\t 67.50\t 78.75\n", - "\n", - "63.75\t 73.12\t 73.12\t 81.56\n", - "\n", - "66.56\t 74.53\t 74.53\t 82.27\n", - "\n", - "67.27\t 74.88\t 74.88\t 82.44\n", - "\n", - "67.44\t 74.97\t 74.97\t 82.49\n", - "\n", - " from last two iterates we conclude u1=67 u2=75 u3=75 u4=83\n", - "\n" - ] - } - ], - "prompt_number": 59 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.6:pg-362" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#bender-schmidt formula\n", - "#example 9.6\n", - "#page 362\n", - "def f(x):\n", - " return (4*x)-(x*x)\n", - "#u=[f(0),f(1),f(2),f(3),f(4)]\n", - "u1=f(0);u2=f(1);u3=f(2);u4=f(3);u5=f(4);\n", - "u11=(u1+u3)/2\n", - "u12=(u2+u4)/2\n", - "u13=(u3+u5)/2\n", - "print \"u11=%0.2f\\t u12=%0.2f\\t u13=%0.2f\\t \\n\" %(u11,u12,u13)\n", - "u21=(u1+u12)/2.0\n", - "u22=(u11+u13)/2.0\n", - "u23=(u12+0)/2.0\n", - "print \"u21=%0.2f\\t u22=%0.2f\\t u23=%0.2f\\t \\n\" %(u21,u22,u23)\n", - "u31=(u1+u22)/2.0\n", - "u32=(u21+u23)/2.0\n", - "u33=(u22+u1)/2.0\n", - "print \"u31=%0.2f\\t u32=%0.2f\\t u33=%0.2f\\t \\n\" % (u31,u32,u33)\n", - "u41=(u1+u32)/2.0\n", - "u42=(u31+u33)/2.0\n", - "u43=(u32+u1)/2.0\n", - "print \"u41=%0.2f\\t u42=%0.2f\\t u43=%0.2f\\t \\n\" % (u41,u42,u43)\n", - "u51=(u1+u42)/2.0\n", - "u52=(u41+u43)/2.0\n", - "u53=(u42+u1)/2.0\n", - "print \"u51=%0.2f\\t u52=%0.2f\\t u53=%0.2f\\t \\n\" % (u51,u52,u53)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "u11=2.00\t u12=3.00\t u13=2.00\t \n", - "\n", - "u21=1.50\t u22=2.00\t u23=1.50\t \n", - "\n", - "u31=1.00\t u32=1.50\t u33=1.00\t \n", - "\n", - "u41=0.75\t u42=1.00\t u43=0.75\t \n", - "\n", - "u51=0.50\t u52=0.75\t u53=0.50\t \n", - "\n" - ] - } - ], - "prompt_number": 77 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.7:pg-363" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#bender-schimdt's formula and crank-nicolson formula\n", - "#example 9.7\n", - "#page 363\n", - "#bender -schimdt's formula\n", - "z=math.pi\n", - "def f(x,t):\n", - " return math.exp(z*z*t*-1)*sin(z*x)\n", - "#u=[f(0,0),f(0.2,0),f(0.4,0),f(0.6,0),f(0.8,0),f(1,0)];\n", - "u1=f(0,0)\n", - "u2=f(0.2,0)\n", - "u3=f(0.4,0)\n", - "u4=f(0.6,0)\n", - "u5=f(0.8,0)\n", - "u6=f(1.0,0)\n", - "u11=u3/2;u12=(u2+u4)/2;u13=u12;u14=u11;\n", - "print \"u11=%f\\t u12=%f\\t u13=%f\\t u14=%f\\n\\n\" % (u11,u12,u13,u14)\n", - "u21=u12/2;u22=(u12+u14)/2;u23=u22;u24=u21;\n", - "print \"u21=%f\\t u22=%f\\t u23=%f\\t u24=%f\\n\\n\" % (u21,u22,u23,u24)\n", - "print \"the error in the solution is: %f\\n\\n\" % (math.fabs(u22-f(0.6,0.04)))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "u11=0.475528\t u12=0.769421\t u13=0.769421\t u14=0.475528\n", - "\n", - "\n", - "u21=0.384710\t u22=0.622475\t u23=0.622475\t u24=0.384710\n", - "\n", - "\n", - "the error in the solution is: 0.018372\n", - "\n", - "\n" - ] - } - ], - "prompt_number": 119 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.8:pg-364" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import matrix\n", - "#heat equation using crank-nicolson method\n", - "#example 9.8\n", - "#page 364\n", - "z=0.01878;\n", - "#h=1/2;l=1/8,i=1\n", - "u01=0.0;u21=1.0/8.0;\n", - "u11=(u21+u01)/6.0;\n", - "print \" u11=%f\\n\\n\" % (u11)\n", - "print \"error is %f\\n\\n\" % (math.fabs(u11-z))\n", - "#h=1/4,l=1/8,i=1,2,3\n", - "A=matrix([['-3' ,'-1' ,'0'],['1','-3','1'],['0','1','-3']])\n", - "C=matrix([['0'],['0'],['-1/8']])\n", - "#here we found inverese of A then we multipy it with C\n", - "u12=0.01786\n", - "print \"u12=%f\\n\\n\" % (u12)\n", - "print \"error is %f\\n\\n\" %(math.fabs(u12-z))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " u11=0.020833\n", - "\n", - "\n", - "error is 0.002053\n", - "\n", - "\n", - "u12=0.017860\n", - "\n", - "\n", - "error is 0.000920\n", - "\n", - "\n" - ] - } - ], - "prompt_number": 105 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3.ipynb b/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3.ipynb new file mode 100755 index 00000000..777522bb --- /dev/null +++ b/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3.ipynb @@ -0,0 +1,195 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: Elements of the Theory of Plasticity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 3.1, True Stress and True Strain, Page No. 76" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Engineering Stress at maximum load = 99852.1 psi\n", + "True Fracture Stress = 112785 psi\n", + "True Strain at fracture = 0.344939\n", + "Engineering strain at fracture = 0.411903\n" + ] + } + ], + "source": [ + "from math import pi\n", + "from math import log\n", + "from math import exp\n", + "\n", + "#variable declaration\n", + "D_i=0.505;\n", + "L=2;\n", + "P_max=20000;\n", + "P_f=16000;\n", + "D_f=0.425;\n", + "\n", + "#calculation\n", + "E_St= P_max*4/(pi*D_i**2);\n", + "T_fr_St= P_f*4/(pi*D_f**2);\n", + "e_f=log(D_i**2/D_f**2);\n", + "e=exp(e_f)-1;\n", + "\n", + "#result\n", + "print('\\nEngineering Stress at maximum load = %g psi\\nTrue Fracture Stress = %g psi\\nTrue Strain at fracture = %g\\nEngineering strain at fracture = %g')%(E_St,T_fr_St,e_f,e);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 3.2, Yielding Criteria for Ductile Metals, Page No. 78" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "\n", + "\n", + "from math import sqrt\n", + "\n", + "#variable declaration\n", + "sigma00=500;\n", + "sigma_z=-50;\n", + "sigma_y=100;\n", + "sigma_x=200;\n", + "T_xy=30;\n", + "T_yz=0;\n", + "T_xz=0;\n", + "\n", + "#calculation\n", + "sigma0=sqrt((sigma_x-sigma_y)**2+(sigma_y-sigma_z)**2+(sigma_z-sigma_x)**2+6*(T_xy**2+T_yz**2+T_xz**2))/sqrt(2);\n", + "s=sigma00/sigma0;\n", + "\n", + "#result\n", + "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 3.3, Tresca Criterion, Page No. 81" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "\n", + "\n", + "#variable declaration\n", + "sigma00=500;\n", + "sigma_z=-50;\n", + "sigma_y=100;\n", + "sigma_x=200;\n", + "T_xy=30;\n", + "T_yz=0;\n", + "T_xz=0;\n", + "\n", + "#calculation\n", + "sigma0=sigma_x-sigma_z;\n", + "s=sigma00/sigma0;\n", + "\n", + "#result\n", + "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "Example 3.4, Levy-Mises Equation, Page No. 91" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Plastic Strain = 0.199532\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "\n", + "#variable declaration\n", + "r_t=20;\n", + "p=1000;\n", + "\n", + "#calculation\n", + "sigma1=p*r_t;\n", + "sigma1=sigma1/1000; #conversion to ksi\n", + "sigma=sqrt(3)*sigma1/2;\n", + "e=(sigma/25)**(1/0.25);\n", + "e1=sqrt(3)*e/2;\n", + "\n", + "#result\n", + "print('\\nPlastic Strain = %g')%(e1);\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3_1.ipynb b/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3_1.ipynb new file mode 100755 index 00000000..3168a0f9 --- /dev/null +++ b/sample_notebooks/ApurvaBhushan/ApurvaBhushan_version_backup/Chapter_3_1.ipynb @@ -0,0 +1,212 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3: Elements of the Theory of Plasticity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Example 3.1, True Stress and True Strain, Page No. 76" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Engineering Stress at maximum load = 99852.1 psi\n", + "True Fracture Stress = 112785 psi\n", + "True Strain at fracture = 0.344939\n", + "Engineering strain at fracture = 0.411903\n" + ] + } + ], + "source": [ + "from math import pi\n", + "from math import log\n", + "from math import exp\n", + "\n", + "#variable declaration\n", + "D_i=0.505;\n", + "L=2;\n", + "P_max=20000;\n", + "P_f=16000;\n", + "D_f=0.425;\n", + "\n", + "#calculation\n", + "E_St= P_max*4/(pi*D_i**2);\n", + "T_fr_St= P_f*4/(pi*D_f**2);\n", + "e_f=log(D_i**2/D_f**2);\n", + "e=exp(e_f)-1;\n", + "\n", + "#result\n", + "print('\\nEngineering Stress at maximum load = %g psi\\nTrue Fracture Stress = %g psi\\nTrue Strain at fracture = %g\\nEngineering strain at fracture = %g')%(E_St,T_fr_St,e_f,e);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Example 3.2, Yielding Criteria for Ductile Metals, Page No. 78" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Since the calculated value of sigma0 = 224.054 MPa, which is less than the yield strength of the aluminium alloy\n", + "Thus safety factor is = 2.23161\n" + ] + } + ], + "source": [ + "\n", + "from math import sqrt\n", + "\n", + "#variable declaration\n", + "sigma00=500;\n", + "sigma_z=-50;\n", + "sigma_y=100;\n", + "sigma_x=200;\n", + "T_xy=30;\n", + "T_yz=0;\n", + "T_xz=0;\n", + "\n", + "#calculation\n", + "sigma0=sqrt((sigma_x-sigma_y)**2+(sigma_y-sigma_z)**2+(sigma_z-sigma_x)**2+6*(T_xy**2+T_yz**2+T_xz**2))/sqrt(2);\n", + "s=sigma00/sigma0;\n", + "\n", + "#result\n", + "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Example 3.3, Tresca Criterion, Page No. 81" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Since the calculated value of sigma0 = 250 MPa, which is less than the yield strength of the aluminium alloy\n", + "Thus safety factor is = 2\n" + ] + } + ], + "source": [ + "\n", + "\n", + "#variable declaration\n", + "sigma00=500;\n", + "sigma_z=-50;\n", + "sigma_y=100;\n", + "sigma_x=200;\n", + "T_xy=30;\n", + "T_yz=0;\n", + "T_xz=0;\n", + "\n", + "#calculation\n", + "sigma0=sigma_x-sigma_z;\n", + "s=sigma00/sigma0;\n", + "\n", + "#result\n", + "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "### Example 3.4, Levy-Mises Equation, Page No. 91" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Plastic Strain = 0.199532\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "\n", + "#variable declaration\n", + "r_t=20;\n", + "p=1000;\n", + "\n", + "#calculation\n", + "sigma1=p*r_t;\n", + "sigma1=sigma1/1000; #conversion to ksi\n", + "sigma=sqrt(3)*sigma1/2;\n", + "e=(sigma/25)**(1/0.25);\n", + "e1=sqrt(3)*e/2;\n", + "\n", + "#result\n", + "print('\\nPlastic Strain = %g')%(e1);\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ApurvaBhushan/Chapter_3.ipynb b/sample_notebooks/ApurvaBhushan/Chapter_3.ipynb deleted file mode 100755 index 777522bb..00000000 --- a/sample_notebooks/ApurvaBhushan/Chapter_3.ipynb +++ /dev/null @@ -1,195 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 3: Elements of the Theory of Plasticity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 3.1, True Stress and True Strain, Page No. 76" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Engineering Stress at maximum load = 99852.1 psi\n", - "True Fracture Stress = 112785 psi\n", - "True Strain at fracture = 0.344939\n", - "Engineering strain at fracture = 0.411903\n" - ] - } - ], - "source": [ - "from math import pi\n", - "from math import log\n", - "from math import exp\n", - "\n", - "#variable declaration\n", - "D_i=0.505;\n", - "L=2;\n", - "P_max=20000;\n", - "P_f=16000;\n", - "D_f=0.425;\n", - "\n", - "#calculation\n", - "E_St= P_max*4/(pi*D_i**2);\n", - "T_fr_St= P_f*4/(pi*D_f**2);\n", - "e_f=log(D_i**2/D_f**2);\n", - "e=exp(e_f)-1;\n", - "\n", - "#result\n", - "print('\\nEngineering Stress at maximum load = %g psi\\nTrue Fracture Stress = %g psi\\nTrue Strain at fracture = %g\\nEngineering strain at fracture = %g')%(E_St,T_fr_St,e_f,e);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 3.2, Yielding Criteria for Ductile Metals, Page No. 78" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "\n", - "\n", - "from math import sqrt\n", - "\n", - "#variable declaration\n", - "sigma00=500;\n", - "sigma_z=-50;\n", - "sigma_y=100;\n", - "sigma_x=200;\n", - "T_xy=30;\n", - "T_yz=0;\n", - "T_xz=0;\n", - "\n", - "#calculation\n", - "sigma0=sqrt((sigma_x-sigma_y)**2+(sigma_y-sigma_z)**2+(sigma_z-sigma_x)**2+6*(T_xy**2+T_yz**2+T_xz**2))/sqrt(2);\n", - "s=sigma00/sigma0;\n", - "\n", - "#result\n", - "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 3.3, Tresca Criterion, Page No. 81" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "\n", - "\n", - "#variable declaration\n", - "sigma00=500;\n", - "sigma_z=-50;\n", - "sigma_y=100;\n", - "sigma_x=200;\n", - "T_xy=30;\n", - "T_yz=0;\n", - "T_xz=0;\n", - "\n", - "#calculation\n", - "sigma0=sigma_x-sigma_z;\n", - "s=sigma00/sigma0;\n", - "\n", - "#result\n", - "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "Example 3.4, Levy-Mises Equation, Page No. 91" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Plastic Strain = 0.199532\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "\n", - "#variable declaration\n", - "r_t=20;\n", - "p=1000;\n", - "\n", - "#calculation\n", - "sigma1=p*r_t;\n", - "sigma1=sigma1/1000; #conversion to ksi\n", - "sigma=sqrt(3)*sigma1/2;\n", - "e=(sigma/25)**(1/0.25);\n", - "e1=sqrt(3)*e/2;\n", - "\n", - "#result\n", - "print('\\nPlastic Strain = %g')%(e1);\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ApurvaBhushan/Chapter_3_1.ipynb b/sample_notebooks/ApurvaBhushan/Chapter_3_1.ipynb deleted file mode 100755 index 3168a0f9..00000000 --- a/sample_notebooks/ApurvaBhushan/Chapter_3_1.ipynb +++ /dev/null @@ -1,212 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 3: Elements of the Theory of Plasticity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 3.1, True Stress and True Strain, Page No. 76" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Engineering Stress at maximum load = 99852.1 psi\n", - "True Fracture Stress = 112785 psi\n", - "True Strain at fracture = 0.344939\n", - "Engineering strain at fracture = 0.411903\n" - ] - } - ], - "source": [ - "from math import pi\n", - "from math import log\n", - "from math import exp\n", - "\n", - "#variable declaration\n", - "D_i=0.505;\n", - "L=2;\n", - "P_max=20000;\n", - "P_f=16000;\n", - "D_f=0.425;\n", - "\n", - "#calculation\n", - "E_St= P_max*4/(pi*D_i**2);\n", - "T_fr_St= P_f*4/(pi*D_f**2);\n", - "e_f=log(D_i**2/D_f**2);\n", - "e=exp(e_f)-1;\n", - "\n", - "#result\n", - "print('\\nEngineering Stress at maximum load = %g psi\\nTrue Fracture Stress = %g psi\\nTrue Strain at fracture = %g\\nEngineering strain at fracture = %g')%(E_St,T_fr_St,e_f,e);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 3.2, Yielding Criteria for Ductile Metals, Page No. 78" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Since the calculated value of sigma0 = 224.054 MPa, which is less than the yield strength of the aluminium alloy\n", - "Thus safety factor is = 2.23161\n" - ] - } - ], - "source": [ - "\n", - "from math import sqrt\n", - "\n", - "#variable declaration\n", - "sigma00=500;\n", - "sigma_z=-50;\n", - "sigma_y=100;\n", - "sigma_x=200;\n", - "T_xy=30;\n", - "T_yz=0;\n", - "T_xz=0;\n", - "\n", - "#calculation\n", - "sigma0=sqrt((sigma_x-sigma_y)**2+(sigma_y-sigma_z)**2+(sigma_z-sigma_x)**2+6*(T_xy**2+T_yz**2+T_xz**2))/sqrt(2);\n", - "s=sigma00/sigma0;\n", - "\n", - "#result\n", - "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "### Example 3.3, Tresca Criterion, Page No. 81" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Since the calculated value of sigma0 = 250 MPa, which is less than the yield strength of the aluminium alloy\n", - "Thus safety factor is = 2\n" - ] - } - ], - "source": [ - "\n", - "\n", - "#variable declaration\n", - "sigma00=500;\n", - "sigma_z=-50;\n", - "sigma_y=100;\n", - "sigma_x=200;\n", - "T_xy=30;\n", - "T_yz=0;\n", - "T_xz=0;\n", - "\n", - "#calculation\n", - "sigma0=sigma_x-sigma_z;\n", - "s=sigma00/sigma0;\n", - "\n", - "#result\n", - "print('\\nSince the calculated value of sigma0 = %g MPa, which is less than the yield strength of the aluminium alloy\\nThus safety factor is = %g')%(sigma0,s);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "### Example 3.4, Levy-Mises Equation, Page No. 91" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Plastic Strain = 0.199532\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "\n", - "#variable declaration\n", - "r_t=20;\n", - "p=1000;\n", - "\n", - "#calculation\n", - "sigma1=p*r_t;\n", - "sigma1=sigma1/1000; #conversion to ksi\n", - "sigma=sqrt(3)*sigma1/2;\n", - "e=(sigma/25)**(1/0.25);\n", - "e1=sqrt(3)*e/2;\n", - "\n", - "#result\n", - "print('\\nPlastic Strain = %g')%(e1);\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Ashish KumarSingh/Chapter.ipynb b/sample_notebooks/Ashish KumarSingh/Chapter.ipynb new file mode 100755 index 00000000..26e2a823 --- /dev/null +++ b/sample_notebooks/Ashish KumarSingh/Chapter.ipynb @@ -0,0 +1,243 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Light" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1, Page Number 10" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Brewsters Angle of the Material is 56.31 Degrees\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "n2=1.5 #Given Refractive Index of Glass in Air\n", + "n1=1 #Given Refractive Index of Air\n", + "\n", + "theta=0 #Brewster's Angle\n", + "#From Equation 1.13 (Brewsters angle= Tan Inverse (n2/n1))\n", + "theta=math.degrees(math.atan(1.5))\n", + "print \"The Brewsters Angle of the Material is \"+str(round(theta,2))+\" Degrees\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2, Page Number 13" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "In Coherant Sources The Maximum Irradiance is 16I\n", + "In Incoherant Sources The Maximum Irradiance is 4I\n" + ] + } + ], + "source": [ + "n=4 #Total Number of Sources\n", + "\n", + "#For Coherant Sources\n", + "print \"In Coherant Sources The Maximum Irradiance is \"+str(n*n)+\"I\" #Where I is the Irradiance at any point\n", + "#For Incoherant Sources\n", + "print \"In Incoherant Sources The Maximum Irradiance is \"+str(n)+\"I\" " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3, Page Number 23" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(A)The Minimum Seperation Between the Sources is 0.0025 m\n", + "(B)The Minimum Wavelength Difference which may be resolved is 2.08333333333e-11 m\n" + ] + } + ], + "source": [ + "D=0.1 #Diameter of the Objective Lens\n", + "d1=500 #Distance from the source\n", + "l =0.000000500 #Wavelength Provided\n", + "p=1 #First Order\n", + "N=40*600 #The diffraction grating is 40 mm wide and has 600 lines/mm\n", + "\n", + "#From Equation 1.29 we Have\n", + "Smin=(d1*l)/D #Where Smin is the minimum Seperation of the Sources\n", + "print \"(A)The Minimum Seperation Between the Sources is \"+str(Smin)+\" m\"\n", + "\n", + "#We know that Chromatic resolving power is given by l/dl where dl is the Minimum Wavelength Difference\n", + "#From Equation l/dl=p*N\n", + "dl=l/(N*p)\n", + "\n", + "print \"(B)The Minimum Wavelength Difference which may be resolved is \"+str(dl)+\" m\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 1.4, Page Number 29" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Total Power Radiated from the Source is 6.3504 W\n" + ] + } + ], + "source": [ + "em=0.7 #Emissivity Of the Surface\n", + "T=2000 #Temperature in Kelvin\n", + "A=0.00001 #Area in Meter Square\n", + "S=5.67*(10**-8) #Stefan-Boltzmann Constant\n", + "\n", + "W=S*A*em*(T**4) #Where W is the total power radiated\n", + "\n", + "print \"The Total Power Radiated from the Source is \"+str(W)+\" W\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 1.5, Page Number 31" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Ionization Energy required to excite the electron from ground to Infinity 13.66 eV\n" + ] + } + ], + "source": [ + "Z=1 #Atomic Number of Hydrogen\n", + "m=9.1*(10**-31) #Mass of a Electron\n", + "e=1.6*(10**-19) #Charge Of a Electron\n", + "p=6.6*(10**-34) #Plancks Constant\n", + "e1=8.85*(10**-12)#Permittivity of Free Space\n", + "#From Equation 1.43\n", + "E=(m*(Z**2)*(e**4))/(8*(p**2)*(e1**2)) #Where E is the Ionization Energy\n", + "E2=E/e #Converting in Electron Volts\n", + "E2=round(E2,2)\n", + "\n", + "print \"The Ionization Energy required to excite the electron from ground to Infinity \"+str(E2)+\" eV\"\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 1.6, Page Number 32" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Required Work function is 4.5375 eV\n" + ] + } + ], + "source": [ + "e=1.6*(10**-19) #Charge Of a Electron\n", + "h=6.6*(10**-34) #Plancks Constant\n", + "vo=1.1*(10**15) #Threshold Frequency in Hertz\n", + "\n", + "# We Know h*vo=phi*e where phi is the required Work Function\n", + "# We assume that the ejected electron has zero kinetic energy\n", + "\n", + "phi=h*vo/e\n", + "print \"The Required Work function is \"+str(phi)+\" eV\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Ashish KumarSingh/Chapter_First.ipynb b/sample_notebooks/Ashish KumarSingh/Chapter_First.ipynb deleted file mode 100755 index 26e2a823..00000000 --- a/sample_notebooks/Ashish KumarSingh/Chapter_First.ipynb +++ /dev/null @@ -1,243 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Light" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1, Page Number 10" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Brewsters Angle of the Material is 56.31 Degrees\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "n2=1.5 #Given Refractive Index of Glass in Air\n", - "n1=1 #Given Refractive Index of Air\n", - "\n", - "theta=0 #Brewster's Angle\n", - "#From Equation 1.13 (Brewsters angle= Tan Inverse (n2/n1))\n", - "theta=math.degrees(math.atan(1.5))\n", - "print \"The Brewsters Angle of the Material is \"+str(round(theta,2))+\" Degrees\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2, Page Number 13" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "In Coherant Sources The Maximum Irradiance is 16I\n", - "In Incoherant Sources The Maximum Irradiance is 4I\n" - ] - } - ], - "source": [ - "n=4 #Total Number of Sources\n", - "\n", - "#For Coherant Sources\n", - "print \"In Coherant Sources The Maximum Irradiance is \"+str(n*n)+\"I\" #Where I is the Irradiance at any point\n", - "#For Incoherant Sources\n", - "print \"In Incoherant Sources The Maximum Irradiance is \"+str(n)+\"I\" " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.3, Page Number 23" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(A)The Minimum Seperation Between the Sources is 0.0025 m\n", - "(B)The Minimum Wavelength Difference which may be resolved is 2.08333333333e-11 m\n" - ] - } - ], - "source": [ - "D=0.1 #Diameter of the Objective Lens\n", - "d1=500 #Distance from the source\n", - "l =0.000000500 #Wavelength Provided\n", - "p=1 #First Order\n", - "N=40*600 #The diffraction grating is 40 mm wide and has 600 lines/mm\n", - "\n", - "#From Equation 1.29 we Have\n", - "Smin=(d1*l)/D #Where Smin is the minimum Seperation of the Sources\n", - "print \"(A)The Minimum Seperation Between the Sources is \"+str(Smin)+\" m\"\n", - "\n", - "#We know that Chromatic resolving power is given by l/dl where dl is the Minimum Wavelength Difference\n", - "#From Equation l/dl=p*N\n", - "dl=l/(N*p)\n", - "\n", - "print \"(B)The Minimum Wavelength Difference which may be resolved is \"+str(dl)+\" m\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 1.4, Page Number 29" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Total Power Radiated from the Source is 6.3504 W\n" - ] - } - ], - "source": [ - "em=0.7 #Emissivity Of the Surface\n", - "T=2000 #Temperature in Kelvin\n", - "A=0.00001 #Area in Meter Square\n", - "S=5.67*(10**-8) #Stefan-Boltzmann Constant\n", - "\n", - "W=S*A*em*(T**4) #Where W is the total power radiated\n", - "\n", - "print \"The Total Power Radiated from the Source is \"+str(W)+\" W\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 1.5, Page Number 31" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Ionization Energy required to excite the electron from ground to Infinity 13.66 eV\n" - ] - } - ], - "source": [ - "Z=1 #Atomic Number of Hydrogen\n", - "m=9.1*(10**-31) #Mass of a Electron\n", - "e=1.6*(10**-19) #Charge Of a Electron\n", - "p=6.6*(10**-34) #Plancks Constant\n", - "e1=8.85*(10**-12)#Permittivity of Free Space\n", - "#From Equation 1.43\n", - "E=(m*(Z**2)*(e**4))/(8*(p**2)*(e1**2)) #Where E is the Ionization Energy\n", - "E2=E/e #Converting in Electron Volts\n", - "E2=round(E2,2)\n", - "\n", - "print \"The Ionization Energy required to excite the electron from ground to Infinity \"+str(E2)+\" eV\"\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 1.6, Page Number 32" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Required Work function is 4.5375 eV\n" - ] - } - ], - "source": [ - "e=1.6*(10**-19) #Charge Of a Electron\n", - "h=6.6*(10**-34) #Plancks Constant\n", - "vo=1.1*(10**15) #Threshold Frequency in Hertz\n", - "\n", - "# We Know h*vo=phi*e where phi is the required Work Function\n", - "# We assume that the ejected electron has zero kinetic energy\n", - "\n", - "phi=h*vo/e\n", - "print \"The Required Work function is \"+str(phi)+\" eV\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AumkarRane/AumkarRane_version_backup/Chapter9.ipynb b/sample_notebooks/AumkarRane/AumkarRane_version_backup/Chapter9.ipynb new file mode 100755 index 00000000..49a8b300 --- /dev/null +++ b/sample_notebooks/AumkarRane/AumkarRane_version_backup/Chapter9.ipynb @@ -0,0 +1,194 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 9 : Special Theory of Relativity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 1 , Page number 284" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Change in length in diameter= 6.37 *10**-2 m\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "l=2*6371 #Diameter of earth\n", + "v=30 #velocity\n", + "c=3*10**5 #velocity of light\n", + "\n", + "#Calculations\n", + "dell=(l*v**2)/(2*c**2)/10**-5\n", + "\n", + "#Result\n", + "print\"Change in length in diameter=\",round(dell,2),\"*10**-2 m\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 2 , Page number 284" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The minimum speed v= 0.99999996247 c\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "delt=10 #time duration at earth\n", + "delt1=1/365 \n", + "\n", + "#Calculations\n", + "v=math.sqrt(1-(delt1/delt)**2)\n", + "\n", + "#Result\n", + "print\"The minimum speed v= \",v,\"c\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 3 , Page number 285" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1) The time taken on earth (t) = 21.05 year\n", + "(2) The time taken on spaceship (t1) = 6.53 year\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "L0=20 #The distance of the star\n", + "v=0.95 #velocity\n", + "\n", + "#Calculations\n", + "t=L0/v\n", + "L=L0*math.sqrt(1-v**2)\n", + "L=round(L,1)\n", + "t1=(L*3*10**8)/(v*3*10**8)\n", + "\n", + "#Result\n", + "print\"(1) The time taken on earth (t) = \",round(t,2),\"year\"\n", + "print\"(2) The time taken on spaceship (t1) = \",round(t1,2),\"year\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 4 , Page number 285" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1) The height will be same and the length(L0) = 6.25 m\n", + "(2) The time elapsed on his friend's watch(t1) = 8.0 sec\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "L=5 #Lenth\n", + "v=0.6 #velocity\n", + "t=10 #time\n", + "\n", + "#Calculations\n", + "L0=L/math.sqrt(1-v**2)\n", + "t1=t*math.sqrt(1-v**2)\n", + "\n", + "#Result\n", + "print\"(1) The height will be same and the length(L0) = \",L0,\"m\"\n", + "print\"(2) The time elapsed on his friend's watch(t1) = \",t1,\"sec\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AumkarRane/Chapter9.ipynb b/sample_notebooks/AumkarRane/Chapter9.ipynb deleted file mode 100755 index 49a8b300..00000000 --- a/sample_notebooks/AumkarRane/Chapter9.ipynb +++ /dev/null @@ -1,194 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 9 : Special Theory of Relativity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 1 , Page number 284" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Change in length in diameter= 6.37 *10**-2 m\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "l=2*6371 #Diameter of earth\n", - "v=30 #velocity\n", - "c=3*10**5 #velocity of light\n", - "\n", - "#Calculations\n", - "dell=(l*v**2)/(2*c**2)/10**-5\n", - "\n", - "#Result\n", - "print\"Change in length in diameter=\",round(dell,2),\"*10**-2 m\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 2 , Page number 284" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The minimum speed v= 0.99999996247 c\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "delt=10 #time duration at earth\n", - "delt1=1/365 \n", - "\n", - "#Calculations\n", - "v=math.sqrt(1-(delt1/delt)**2)\n", - "\n", - "#Result\n", - "print\"The minimum speed v= \",v,\"c\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 3 , Page number 285" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1) The time taken on earth (t) = 21.05 year\n", - "(2) The time taken on spaceship (t1) = 6.53 year\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "L0=20 #The distance of the star\n", - "v=0.95 #velocity\n", - "\n", - "#Calculations\n", - "t=L0/v\n", - "L=L0*math.sqrt(1-v**2)\n", - "L=round(L,1)\n", - "t1=(L*3*10**8)/(v*3*10**8)\n", - "\n", - "#Result\n", - "print\"(1) The time taken on earth (t) = \",round(t,2),\"year\"\n", - "print\"(2) The time taken on spaceship (t1) = \",round(t1,2),\"year\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 4 , Page number 285" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1) The height will be same and the length(L0) = 6.25 m\n", - "(2) The time elapsed on his friend's watch(t1) = 8.0 sec\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "L=5 #Lenth\n", - "v=0.6 #velocity\n", - "t=10 #time\n", - "\n", - "#Calculations\n", - "L0=L/math.sqrt(1-v**2)\n", - "t1=t*math.sqrt(1-v**2)\n", - "\n", - "#Result\n", - "print\"(1) The height will be same and the length(L0) = \",L0,\"m\"\n", - "print\"(2) The time elapsed on his friend's watch(t1) = \",t1,\"sec\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/AviralYadav/AviralYadav_version_backup/Chapter9.ipynb b/sample_notebooks/AviralYadav/AviralYadav_version_backup/Chapter9.ipynb new file mode 100755 index 00000000..0655eef8 --- /dev/null +++ b/sample_notebooks/AviralYadav/AviralYadav_version_backup/Chapter9.ipynb @@ -0,0 +1,144 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:349ae7afdee1d1b3c3dc4037b8dc3bb200738707d16369e5edfee0d065859f9b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 9: Signal Analysis" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.1:pg-277" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# To find dynamic range of spectrum analyser\n", + "\n", + "# Given data\n", + "I_p = +25.0; #Third order intercept point in dBm\n", + "MDS = -85.0; #noise level in dBm\n", + "\n", + "#Calculations\n", + "\n", + "dynamic_range = 2/3.0*(I_p -MDS);\n", + "print \"The dynamic range of the spectrum analyser =\",int(dynamic_range),\" dB\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The dynamic range of the spectrum analyser = 73 dB\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.2:pg-277" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# To find minimum detectable signal\n", + "\n", + "import math\n", + "\n", + "# Given data\n", + "NF = 20.0; #Noise figure in dB\n", + "BW = 1*10.0**3; #Bandwidth in Hz\n", + "\n", + "#Calculations\n", + "MDS=-114+10*math.log10((BW/(1*10.0**6)))+NF\n", + "print \"The minimum detectable signal of the spectrum analyser = \",int(MDS),\" dBm\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum detectable signal of the spectrum analyser = -124 dBm\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex9.3:pg-285" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# To find dynamic range and total frequency display\n", + "\n", + "import math\n", + "# Given data\n", + "T = 4.0; #Sample window in s\n", + "f_s = 20*10.0**3; # sample frequency in Hz\n", + "N = 10.0; #no of bits\n", + "\n", + "#Calculations\n", + "f_r = 1/T;\n", + "f_h = f_s/2.0; \n", + "R_d = 20*math.log10(2.0**N);\n", + "\n", + "print \"The ratio of the spectral calculation = \",round(f_r,2),\" Hz\\n\"\n", + "print \"The maximum calculated spectral frequency = \",int(f_h),\" Hz\\n\"\n", + "print \"The dynamic range = \",int(R_d),\" dB\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of the spectral calculation = 0.25 Hz\n", + "\n", + "The maximum calculated spectral frequency = 10000 Hz\n", + "\n", + "The dynamic range = 60 dB\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/AviralYadav/Chapter9.ipynb b/sample_notebooks/AviralYadav/Chapter9.ipynb deleted file mode 100755 index 0655eef8..00000000 --- a/sample_notebooks/AviralYadav/Chapter9.ipynb +++ /dev/null @@ -1,144 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:349ae7afdee1d1b3c3dc4037b8dc3bb200738707d16369e5edfee0d065859f9b" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 9: Signal Analysis" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.1:pg-277" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# To find dynamic range of spectrum analyser\n", - "\n", - "# Given data\n", - "I_p = +25.0; #Third order intercept point in dBm\n", - "MDS = -85.0; #noise level in dBm\n", - "\n", - "#Calculations\n", - "\n", - "dynamic_range = 2/3.0*(I_p -MDS);\n", - "print \"The dynamic range of the spectrum analyser =\",int(dynamic_range),\" dB\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The dynamic range of the spectrum analyser = 73 dB\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.2:pg-277" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# To find minimum detectable signal\n", - "\n", - "import math\n", - "\n", - "# Given data\n", - "NF = 20.0; #Noise figure in dB\n", - "BW = 1*10.0**3; #Bandwidth in Hz\n", - "\n", - "#Calculations\n", - "MDS=-114+10*math.log10((BW/(1*10.0**6)))+NF\n", - "print \"The minimum detectable signal of the spectrum analyser = \",int(MDS),\" dBm\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The minimum detectable signal of the spectrum analyser = -124 dBm\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex9.3:pg-285" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# To find dynamic range and total frequency display\n", - "\n", - "import math\n", - "# Given data\n", - "T = 4.0; #Sample window in s\n", - "f_s = 20*10.0**3; # sample frequency in Hz\n", - "N = 10.0; #no of bits\n", - "\n", - "#Calculations\n", - "f_r = 1/T;\n", - "f_h = f_s/2.0; \n", - "R_d = 20*math.log10(2.0**N);\n", - "\n", - "print \"The ratio of the spectral calculation = \",round(f_r,2),\" Hz\\n\"\n", - "print \"The maximum calculated spectral frequency = \",int(f_h),\" Hz\\n\"\n", - "print \"The dynamic range = \",int(R_d),\" dB\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ratio of the spectral calculation = 0.25 Hz\n", - "\n", - "The maximum calculated spectral frequency = 10000 Hz\n", - "\n", - "The dynamic range = 60 dB\n" - ] - } - ], - "prompt_number": 15 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/AzagumozhiMadhaiyan/Chapter8.ipynb b/sample_notebooks/AzagumozhiMadhaiyan/Chapter8.ipynb new file mode 100755 index 00000000..3fff6821 --- /dev/null +++ b/sample_notebooks/AzagumozhiMadhaiyan/Chapter8.ipynb @@ -0,0 +1,71 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# CHAPTER_8-Load Characteristics Of DC Motors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 8.3 Page Dc-111" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "speed of motion at half the torque= 1444.17 rpm\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "U=230 #voltage(V)\n", + "Ia1=155 #current(A)\n", + "Rm_Rse=0.1#armature resistance(ohm)\n", + "N1=1000 #speed(rpm)\n", + "\n", + "#calculation\n", + "Ia2=round(Ia1/math.sqrt(2),1) #current(A)\n", + "Eb1=U-(Ia1*Rm_Rse) #voltage(V)\n", + "Eb2=U-(Ia2*Rm_Rse) #voltage(V)\n", + "N2=(Eb2/Eb1)*(Ia1/Ia2)*N1\n", + "print 'speed of motion at half the torque=',round(N2,2),'rpm'" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/AzagumozhiMadhaiyan/Chapter_8_.ipynb b/sample_notebooks/AzagumozhiMadhaiyan/Chapter_8_.ipynb deleted file mode 100755 index 3fff6821..00000000 --- a/sample_notebooks/AzagumozhiMadhaiyan/Chapter_8_.ipynb +++ /dev/null @@ -1,71 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# CHAPTER_8-Load Characteristics Of DC Motors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 8.3 Page Dc-111" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "speed of motion at half the torque= 1444.17 rpm\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "U=230 #voltage(V)\n", - "Ia1=155 #current(A)\n", - "Rm_Rse=0.1#armature resistance(ohm)\n", - "N1=1000 #speed(rpm)\n", - "\n", - "#calculation\n", - "Ia2=round(Ia1/math.sqrt(2),1) #current(A)\n", - "Eb1=U-(Ia1*Rm_Rse) #voltage(V)\n", - "Eb2=U-(Ia2*Rm_Rse) #voltage(V)\n", - "N2=(Eb2/Eb1)*(Ia1/Ia2)*N1\n", - "print 'speed of motion at half the torque=',round(N2,2),'rpm'" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL.ipynb b/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL.ipynb new file mode 100755 index 00000000..cd376de8 --- /dev/null +++ b/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL.ipynb @@ -0,0 +1,677 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 CRYSTAL STRUCTURES" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_4 pgno:10" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1.0\n", + "r=a/2 = 0.5\n", + "Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= 0.523598775598\n", + "Total Volume of the cube ,V=aˆ3 = 1.0\n", + "Fp(S.C)=(v∗100/V)= 52.3598775598\n" + ] + } + ], + "source": [ + "#exa 1.4\n", + "from math import pi\n", + "a=1.\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=a/2.\n", + "print \"r=a/2 = \",r # initializing value of radius of atom for simple cubic .\n", + "v=((4*pi*(r**3))/3)\n", + "print \"Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= \",v # calcuation . \n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(S.C)=(v∗100/V)= \",Fp,# calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_5 pgno:11" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1.0\n", + "Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = 0.433012701892\n", + "Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = 0.680174761588\n", + "Total Volume of the cube ,V=aˆ3 = 1.0\n", + "Fp(B.C.C)=(v∗100/V)= 68.0174761588 %\n" + ] + } + ], + "source": [ + "#exa 1.5\n", + "from math import sqrt\n", + "a=1.\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=(sqrt(3)*(a**2/4))\n", + "print \"Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = \",r # initializing value of radius of atom for BCC.\n", + "v=((4*pi*(r**3))/3)*2\n", + "print \"Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = \",v # calcuation \n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(B.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_6 pgno:12" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1\n", + "Radius of the atom,r=(a/(2∗sqrt(2)))= 0.353553390593\n", + "Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= 0.740480489693\n", + "Total volume of the cube ,V=aˆ3= 2\n", + "Fp(F.C.C)=(v∗100/V)= 37.0240244847 %\n" + ] + } + ], + "source": [ + "#exa 1.6\n", + "a=1\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=(a/(2*sqrt(2)))\n", + "print \"Radius of the atom,r=(a/(2∗sqrt(2)))= \",r # initializing value of radius of atom for FCC .\n", + "v=(((4*pi*(r**3))/3)*4)\n", + "print \"Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= \",v # calcuation \n", + "V=a^3\n", + "print \"Total volume of the cube ,V=aˆ3= \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(F.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_8 pgno:14" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1\n", + "Radius of the atom , r=(sqrt (3)∗a/8))= 0.216506350946\n", + "v=(((4∗pi∗(rˆ3))/3)∗8) = 0.340087380794\n", + "V=aˆ3= 2\n", + "Fp(Diamond)=(v∗100/V) = 17.0043690397 %\n" + ] + } + ], + "source": [ + "#Exa 1.8 \n", + "a=1\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=((sqrt(3)*a/8))\n", + "print \"Radius of the atom , r=(sqrt (3)∗a/8))= \",r # initializing value of radius of atom for diamond .\n", + "v=(((4*pi*(r**3))/3)*8)\n", + "print \"v=(((4∗pi∗(rˆ3))/3)∗8) = \",v # calcuation .\n", + "V=a^3\n", + "print \"V=aˆ3= \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(Diamond)=(v∗100/V) = \",Fp,\"%\" # calculation\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_9 pgno:14" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 5e-08 cm\n", + "Radius of the atom,r=(sqrt(3)∗(a/4))= 2.16506350946e-08\n", + "Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= 8.50218451985e-23\n", + "Total Volume of the cube ,V=aˆ3 = 1.25e-22\n", + "Fp(B.C.C)=(v∗100/V) = 68.0174761588 %\n" + ] + } + ], + "source": [ + "#exa 1.9\n", + "a=5*10**-8\n", + "print \"a = \",a,\" cm\" # initializing value of lattice constant .\n", + "r=(sqrt(3)*(a/4))\n", + "print \"Radius of the atom,r=(sqrt(3)∗(a/4))= \",r # initializing value of radius of atom for BCC.\n", + "v=((4*pi*(r**3))/3)*2\n", + "print \"Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= \",v # calcuation .\n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(B.C.C)=(v∗100/V) = \",Fp,\"%\" # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_10 pgno:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = 1\n", + "y intercept = inf\n", + "z intercept = inf\n", + "miller indices ,h=(1/x )= [1]\n", + "k=(1/y)= [0.0]\n", + "l=(1/z) = [0.0]\n" + ] + } + ], + "source": [ + "#exa 1.10\n", + "x=1\n", + "print \"x intercept = \",x # initializing value of x intercept .\n", + "y=float('inf')\n", + "print \"y intercept = \",y # initializing value of y intercept .\n", + "z=float('inf')\n", + "print \"z intercept = \",z # initializing value of z intercept .\n", + "h=[1/x]\n", + "print \"miller indices ,h=(1/x )= \",h # calculation\n", + "k=[1/y]\n", + "print \"k=(1/y)= \",k # calculation\n", + "l=[1/z]\n", + "print \"l=(1/z) = \",l # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_11 pgno:15" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = inf\n", + "y intercept = inf\n", + "z intercept = 1\n", + "miller indices ,h=[1/x] = [0.0]\n", + "k=[1/y] = [0.0]\n", + "l=[1/z] = [1]\n" + ] + } + ], + "source": [ + "#exa 1.11\n", + "x=float('inf')\n", + "print \"x intercept = \",x # initializing of x intercept .\n", + "y=float('inf') \n", + "print\"y intercept = \",y # initializing of Y intercept .\n", + "z=1\n", + "print \"z intercept = \",z # initializing of Z intercept .\n", + "h=[1/x]\n", + "print \"miller indices ,h=[1/x] = \",h # calculation\n", + "k=[1/y]\n", + "print \"k=[1/y] = \",k # calculation \n", + "l=[1/z]\n", + "print \"l=[1/z] = \",l # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_12 pgno: 16" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = inf\n", + "y intercept = 1\n", + "z intercept = inf\n", + "miller indices ,h=[1/x] = [0.0]\n", + "k=[1/y] = [1]\n", + "l=[1/z] = [0.0]\n" + ] + } + ], + "source": [ + "#exa 1.12\n", + "x=float('inf') \n", + "print \"x intercept = \",x # initializing of X intercept .\n", + "y=1\n", + "print \"y intercept = \",y # initializing of X intercept .\n", + "z=float('inf') \n", + "print \"z intercept = \",z # initializing of X intercept .\n", + "h=[1/x]\n", + "print \"miller indices ,h=[1/x] = \",h # calculation\n", + "k=[1/y]\n", + "print \"k=[1/y] = \",k # calculation \n", + "l=[1/z]\n", + "print \"l=[1/z] = \",l #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_13 pgno:16" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = 1\n", + "y intercept = 1\n", + "z intercept = inf\n", + "miller indices ,h=[1/x] = [1]\n", + "k=[1/y] = [1]\n", + "l=[1/z] = [0.0]\n" + ] + } + ], + "source": [ + "#exa 1.13\n", + "x=1\n", + "print \"x intercept = \",x # initializing of X intercept .\n", + "y=1\n", + "print \"y intercept = \",y # initializing of X intercept .\n", + "z=float('inf') \n", + "print \"z intercept = \",z # initializing of X intercept .\n", + "h=[1/x]\n", + "print \"miller indices ,h=[1/x] = \",h # calculation\n", + "k=[1/y]\n", + "print \"k=[1/y] = \",k # calculation \n", + "l=[1/z]\n", + "print \"l=[1/z] = \",l #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_14 pgno:17" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = inf\n", + "y intercept = 1\n", + "z intercept = 1\n", + "miller indices ,h=[1/x] = [0.0]\n", + "k=[1/y] = [1]\n", + "l=[1/z] = [1]\n" + ] + } + ], + "source": [ + "#exa 1.14\n", + "x=float('inf') \n", + "print \"x intercept = \",x # initializing of X intercept .\n", + "y=1\n", + "print \"y intercept = \",y # initializing of X intercept .\n", + "z=1\n", + "print \"z intercept = \",z # initializing of X intercept .\n", + "h=[1/x]\n", + "print \"miller indices ,h=[1/x] = \",h # calculation\n", + "k=[1/y]\n", + "print \"k=[1/y] = \",k # calculation \n", + "l=[1/z]\n", + "print \"l=[1/z] = \",l #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_15 pgno:18" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x intercept = 2\n", + "y intercept = 2\n", + "z intercept = 2\n", + "common factor of all the intercept= 2\n", + "miller indices ,h=[c/x] = [1]\n", + "k=[c/y] = [1]\n", + "l=[c/z] = [1]\n" + ] + } + ], + "source": [ + "x=2\n", + "print \"x intercept = \",x # initializing of X intercept .\n", + "y=2\n", + "print \"y intercept = \",y # initializing of X intercept .\n", + "z=2\n", + "print \"z intercept = \",z # initializing of X intercept .\n", + "c=2\n", + "print \"common factor of all the intercept= \",c # initializing value of common factor of all the intercepts .\n", + "h=[c/x]\n", + "print \"miller indices ,h=[c/x] = \",h # calculation\n", + "k=[c/y]\n", + "print \"k=[c/y] = \",k # calculation \n", + "l=[c/z]\n", + "print \"l=[c/z] = \",l #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_16 pgno: 18" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wa = 28.1\n", + "D = 2.33 ram/cmˆ3\n", + "Na = 6.02e+23 atoms/mole\n", + "na =(Na∗D)/(Wa)= 4.99167259786e+22 atoms/cmˆ3\n" + ] + } + ], + "source": [ + "#exa 1.16\n", + "Wa =28.1\n", + "print \"Wa = \",Wa # initializing value of atomic weight .\n", + "D=2.33\n", + "print \"D = \",D,\"ram/cmˆ3\" # initializing value of density .\n", + "Na=6.02*10**23\n", + "print \"Na = \",Na,\"atoms/mole\" # initializing value of avagadro number .\n", + "na =(Na*D)/(Wa)\n", + "print \"na =(Na∗D)/(Wa)= \",na,\" atoms/cmˆ3\" # calculation\n", + "# the value of na (number of atoms in 1 cmˆ3 of silicon ) , provided after calculation in the book is wrong." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_17 pgno: 18" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 5e-08 cm\n", + "N= 2\n", + "V=aˆ3 = 1.25e-22 cmˆ3\n", + "na=(no.of atoms in unit cell/Volume of theunit cell) =(N/(V))= 1.6e+22\n" + ] + } + ], + "source": [ + "#exa 1.17\n", + "a=5*10**-8\n", + "print \"a= \",a,\"cm\" # initializing value of lattice constant .\n", + "N=2\n", + "print \"N= \",N # initializing value of no. of atoms in unit cell .\n", + "V=a**3\n", + "print \"V=aˆ3 = \",V,\"cmˆ3\" # initializing value of total Volume of the unit cell.\n", + "na =(N/(V))\n", + "print \"na=(no.of atoms in unit cell/Volume of theunit cell) =(N/(V))= \",na # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_18 pgno: 18" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 5.43e-08 cm\n", + "N = 8\n", + "Number of atom in the cmˆ3,ns =(N/(aˆ3))= 4.99678310227e+22\n" + ] + } + ], + "source": [ + "#exa 1.18\n", + "a=5.43*10**-8\n", + "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", + "N=8\n", + "print \"N = \",N # initializing value of no. of atoms in a unit cell .\n", + "ns =(N/(a**3))\n", + "print \"Number of atom in the cmˆ3,ns =(N/(aˆ3))= \",ns # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_19 pgno: 18" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 5.43e-08 cm\n", + "Wa = 28.1\n", + "Na = 6.02e+23\n", + "ns = 50000000000000000000000 atoms/cmˆ3\n", + "Density of silicon ,D =(ns∗Wa)/(Na)= 2.33388704319 gm/cmˆ2\n" + ] + } + ], + "source": [ + "#exa 1.19\n", + "a=5.43*10**-8\n", + "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", + "Wa =28.1\n", + "print \"Wa = \",Wa # initializing value of atomic weight .\n", + "Na=6.02*10**23\n", + "print \"Na = \",Na # initializing value of avagdro number .\n", + "ns =5*10**22\n", + "print \"ns = \",ns,\"atoms/cmˆ3\" # initializing value of atoms/cmˆ3.\n", + "D =(ns*Wa)/(Na)\n", + "print \"Density of silicon ,D =(ns∗Wa)/(Na)= \",D,\" gm/cmˆ2\" # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_20 pgno: 19" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 4.75e-08 cm\n", + "N = 4\n", + "na =(N/(aˆ3))= 3.73232249599e+22\n" + ] + } + ], + "source": [ + "#exa 1.20\n", + "a=4.75*10**-8\n", + "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", + "N=4\n", + "print \"N = \",N # initializing value of number of atoms in the unit cell .\n", + "na =(N/(a**3))\n", + "print \"na =(N/(aˆ3))=\",na # calculation" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL_STRUCTURES.ipynb b/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL_STRUCTURES.ipynb deleted file mode 100755 index cd376de8..00000000 --- a/sample_notebooks/BhavithaInnamuri/Chapter_1_CRYSTAL_STRUCTURES.ipynb +++ /dev/null @@ -1,677 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 CRYSTAL STRUCTURES" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_4 pgno:10" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1.0\n", - "r=a/2 = 0.5\n", - "Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= 0.523598775598\n", - "Total Volume of the cube ,V=aˆ3 = 1.0\n", - "Fp(S.C)=(v∗100/V)= 52.3598775598\n" - ] - } - ], - "source": [ - "#exa 1.4\n", - "from math import pi\n", - "a=1.\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=a/2.\n", - "print \"r=a/2 = \",r # initializing value of radius of atom for simple cubic .\n", - "v=((4*pi*(r**3))/3)\n", - "print \"Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= \",v # calcuation . \n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(S.C)=(v∗100/V)= \",Fp,# calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_5 pgno:11" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1.0\n", - "Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = 0.433012701892\n", - "Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = 0.680174761588\n", - "Total Volume of the cube ,V=aˆ3 = 1.0\n", - "Fp(B.C.C)=(v∗100/V)= 68.0174761588 %\n" - ] - } - ], - "source": [ - "#exa 1.5\n", - "from math import sqrt\n", - "a=1.\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=(sqrt(3)*(a**2/4))\n", - "print \"Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = \",r # initializing value of radius of atom for BCC.\n", - "v=((4*pi*(r**3))/3)*2\n", - "print \"Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = \",v # calcuation \n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(B.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_6 pgno:12" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1\n", - "Radius of the atom,r=(a/(2∗sqrt(2)))= 0.353553390593\n", - "Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= 0.740480489693\n", - "Total volume of the cube ,V=aˆ3= 2\n", - "Fp(F.C.C)=(v∗100/V)= 37.0240244847 %\n" - ] - } - ], - "source": [ - "#exa 1.6\n", - "a=1\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=(a/(2*sqrt(2)))\n", - "print \"Radius of the atom,r=(a/(2∗sqrt(2)))= \",r # initializing value of radius of atom for FCC .\n", - "v=(((4*pi*(r**3))/3)*4)\n", - "print \"Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= \",v # calcuation \n", - "V=a^3\n", - "print \"Total volume of the cube ,V=aˆ3= \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(F.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_8 pgno:14" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1\n", - "Radius of the atom , r=(sqrt (3)∗a/8))= 0.216506350946\n", - "v=(((4∗pi∗(rˆ3))/3)∗8) = 0.340087380794\n", - "V=aˆ3= 2\n", - "Fp(Diamond)=(v∗100/V) = 17.0043690397 %\n" - ] - } - ], - "source": [ - "#Exa 1.8 \n", - "a=1\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=((sqrt(3)*a/8))\n", - "print \"Radius of the atom , r=(sqrt (3)∗a/8))= \",r # initializing value of radius of atom for diamond .\n", - "v=(((4*pi*(r**3))/3)*8)\n", - "print \"v=(((4∗pi∗(rˆ3))/3)∗8) = \",v # calcuation .\n", - "V=a^3\n", - "print \"V=aˆ3= \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(Diamond)=(v∗100/V) = \",Fp,\"%\" # calculation\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_9 pgno:14" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a = 5e-08 cm\n", - "Radius of the atom,r=(sqrt(3)∗(a/4))= 2.16506350946e-08\n", - "Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= 8.50218451985e-23\n", - "Total Volume of the cube ,V=aˆ3 = 1.25e-22\n", - "Fp(B.C.C)=(v∗100/V) = 68.0174761588 %\n" - ] - } - ], - "source": [ - "#exa 1.9\n", - "a=5*10**-8\n", - "print \"a = \",a,\" cm\" # initializing value of lattice constant .\n", - "r=(sqrt(3)*(a/4))\n", - "print \"Radius of the atom,r=(sqrt(3)∗(a/4))= \",r # initializing value of radius of atom for BCC.\n", - "v=((4*pi*(r**3))/3)*2\n", - "print \"Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= \",v # calcuation .\n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(B.C.C)=(v∗100/V) = \",Fp,\"%\" # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_10 pgno:" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = 1\n", - "y intercept = inf\n", - "z intercept = inf\n", - "miller indices ,h=(1/x )= [1]\n", - "k=(1/y)= [0.0]\n", - "l=(1/z) = [0.0]\n" - ] - } - ], - "source": [ - "#exa 1.10\n", - "x=1\n", - "print \"x intercept = \",x # initializing value of x intercept .\n", - "y=float('inf')\n", - "print \"y intercept = \",y # initializing value of y intercept .\n", - "z=float('inf')\n", - "print \"z intercept = \",z # initializing value of z intercept .\n", - "h=[1/x]\n", - "print \"miller indices ,h=(1/x )= \",h # calculation\n", - "k=[1/y]\n", - "print \"k=(1/y)= \",k # calculation\n", - "l=[1/z]\n", - "print \"l=(1/z) = \",l # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_11 pgno:15" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = inf\n", - "y intercept = inf\n", - "z intercept = 1\n", - "miller indices ,h=[1/x] = [0.0]\n", - "k=[1/y] = [0.0]\n", - "l=[1/z] = [1]\n" - ] - } - ], - "source": [ - "#exa 1.11\n", - "x=float('inf')\n", - "print \"x intercept = \",x # initializing of x intercept .\n", - "y=float('inf') \n", - "print\"y intercept = \",y # initializing of Y intercept .\n", - "z=1\n", - "print \"z intercept = \",z # initializing of Z intercept .\n", - "h=[1/x]\n", - "print \"miller indices ,h=[1/x] = \",h # calculation\n", - "k=[1/y]\n", - "print \"k=[1/y] = \",k # calculation \n", - "l=[1/z]\n", - "print \"l=[1/z] = \",l # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_12 pgno: 16" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = inf\n", - "y intercept = 1\n", - "z intercept = inf\n", - "miller indices ,h=[1/x] = [0.0]\n", - "k=[1/y] = [1]\n", - "l=[1/z] = [0.0]\n" - ] - } - ], - "source": [ - "#exa 1.12\n", - "x=float('inf') \n", - "print \"x intercept = \",x # initializing of X intercept .\n", - "y=1\n", - "print \"y intercept = \",y # initializing of X intercept .\n", - "z=float('inf') \n", - "print \"z intercept = \",z # initializing of X intercept .\n", - "h=[1/x]\n", - "print \"miller indices ,h=[1/x] = \",h # calculation\n", - "k=[1/y]\n", - "print \"k=[1/y] = \",k # calculation \n", - "l=[1/z]\n", - "print \"l=[1/z] = \",l #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_13 pgno:16" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = 1\n", - "y intercept = 1\n", - "z intercept = inf\n", - "miller indices ,h=[1/x] = [1]\n", - "k=[1/y] = [1]\n", - "l=[1/z] = [0.0]\n" - ] - } - ], - "source": [ - "#exa 1.13\n", - "x=1\n", - "print \"x intercept = \",x # initializing of X intercept .\n", - "y=1\n", - "print \"y intercept = \",y # initializing of X intercept .\n", - "z=float('inf') \n", - "print \"z intercept = \",z # initializing of X intercept .\n", - "h=[1/x]\n", - "print \"miller indices ,h=[1/x] = \",h # calculation\n", - "k=[1/y]\n", - "print \"k=[1/y] = \",k # calculation \n", - "l=[1/z]\n", - "print \"l=[1/z] = \",l #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_14 pgno:17" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = inf\n", - "y intercept = 1\n", - "z intercept = 1\n", - "miller indices ,h=[1/x] = [0.0]\n", - "k=[1/y] = [1]\n", - "l=[1/z] = [1]\n" - ] - } - ], - "source": [ - "#exa 1.14\n", - "x=float('inf') \n", - "print \"x intercept = \",x # initializing of X intercept .\n", - "y=1\n", - "print \"y intercept = \",y # initializing of X intercept .\n", - "z=1\n", - "print \"z intercept = \",z # initializing of X intercept .\n", - "h=[1/x]\n", - "print \"miller indices ,h=[1/x] = \",h # calculation\n", - "k=[1/y]\n", - "print \"k=[1/y] = \",k # calculation \n", - "l=[1/z]\n", - "print \"l=[1/z] = \",l #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_15 pgno:18" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x intercept = 2\n", - "y intercept = 2\n", - "z intercept = 2\n", - "common factor of all the intercept= 2\n", - "miller indices ,h=[c/x] = [1]\n", - "k=[c/y] = [1]\n", - "l=[c/z] = [1]\n" - ] - } - ], - "source": [ - "x=2\n", - "print \"x intercept = \",x # initializing of X intercept .\n", - "y=2\n", - "print \"y intercept = \",y # initializing of X intercept .\n", - "z=2\n", - "print \"z intercept = \",z # initializing of X intercept .\n", - "c=2\n", - "print \"common factor of all the intercept= \",c # initializing value of common factor of all the intercepts .\n", - "h=[c/x]\n", - "print \"miller indices ,h=[c/x] = \",h # calculation\n", - "k=[c/y]\n", - "print \"k=[c/y] = \",k # calculation \n", - "l=[c/z]\n", - "print \"l=[c/z] = \",l #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_16 pgno: 18" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wa = 28.1\n", - "D = 2.33 ram/cmˆ3\n", - "Na = 6.02e+23 atoms/mole\n", - "na =(Na∗D)/(Wa)= 4.99167259786e+22 atoms/cmˆ3\n" - ] - } - ], - "source": [ - "#exa 1.16\n", - "Wa =28.1\n", - "print \"Wa = \",Wa # initializing value of atomic weight .\n", - "D=2.33\n", - "print \"D = \",D,\"ram/cmˆ3\" # initializing value of density .\n", - "Na=6.02*10**23\n", - "print \"Na = \",Na,\"atoms/mole\" # initializing value of avagadro number .\n", - "na =(Na*D)/(Wa)\n", - "print \"na =(Na∗D)/(Wa)= \",na,\" atoms/cmˆ3\" # calculation\n", - "# the value of na (number of atoms in 1 cmˆ3 of silicon ) , provided after calculation in the book is wrong." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_17 pgno: 18" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 5e-08 cm\n", - "N= 2\n", - "V=aˆ3 = 1.25e-22 cmˆ3\n", - "na=(no.of atoms in unit cell/Volume of theunit cell) =(N/(V))= 1.6e+22\n" - ] - } - ], - "source": [ - "#exa 1.17\n", - "a=5*10**-8\n", - "print \"a= \",a,\"cm\" # initializing value of lattice constant .\n", - "N=2\n", - "print \"N= \",N # initializing value of no. of atoms in unit cell .\n", - "V=a**3\n", - "print \"V=aˆ3 = \",V,\"cmˆ3\" # initializing value of total Volume of the unit cell.\n", - "na =(N/(V))\n", - "print \"na=(no.of atoms in unit cell/Volume of theunit cell) =(N/(V))= \",na # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_18 pgno: 18" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a = 5.43e-08 cm\n", - "N = 8\n", - "Number of atom in the cmˆ3,ns =(N/(aˆ3))= 4.99678310227e+22\n" - ] - } - ], - "source": [ - "#exa 1.18\n", - "a=5.43*10**-8\n", - "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", - "N=8\n", - "print \"N = \",N # initializing value of no. of atoms in a unit cell .\n", - "ns =(N/(a**3))\n", - "print \"Number of atom in the cmˆ3,ns =(N/(aˆ3))= \",ns # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_19 pgno: 18" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a = 5.43e-08 cm\n", - "Wa = 28.1\n", - "Na = 6.02e+23\n", - "ns = 50000000000000000000000 atoms/cmˆ3\n", - "Density of silicon ,D =(ns∗Wa)/(Na)= 2.33388704319 gm/cmˆ2\n" - ] - } - ], - "source": [ - "#exa 1.19\n", - "a=5.43*10**-8\n", - "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", - "Wa =28.1\n", - "print \"Wa = \",Wa # initializing value of atomic weight .\n", - "Na=6.02*10**23\n", - "print \"Na = \",Na # initializing value of avagdro number .\n", - "ns =5*10**22\n", - "print \"ns = \",ns,\"atoms/cmˆ3\" # initializing value of atoms/cmˆ3.\n", - "D =(ns*Wa)/(Na)\n", - "print \"Density of silicon ,D =(ns∗Wa)/(Na)= \",D,\" gm/cmˆ2\" # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_20 pgno: 19" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a = 4.75e-08 cm\n", - "N = 4\n", - "na =(N/(aˆ3))= 3.73232249599e+22\n" - ] - } - ], - "source": [ - "#exa 1.20\n", - "a=4.75*10**-8\n", - "print \"a = \",a,\"cm\" # initializing value of lattice constant .\n", - "N=4\n", - "print \"N = \",N # initializing value of number of atoms in the unit cell .\n", - "na =(N/(a**3))\n", - "print \"na =(N/(aˆ3))=\",na # calculation" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/DanishAnsari/DanishAnsari_version_backup/chapter_1.ipynb b/sample_notebooks/DanishAnsari/DanishAnsari_version_backup/chapter_1.ipynb new file mode 100755 index 00000000..13a30876 --- /dev/null +++ b/sample_notebooks/DanishAnsari/DanishAnsari_version_backup/chapter_1.ipynb @@ -0,0 +1,111 @@ +{ + "metadata": { + "name": "chapter 1.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Vectors" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1-1,Page no 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initialisation of Variables\n", + "f1=120 #lb\n", + "f2=100 #lb\n", + "theta=((60*pi)/180) #radians\n", + "#Calculations\n", + "R=sqrt(120**2+100**2-(2*120*100*cos(theta))) #Applying Thr rule of Cosines\n", + "alpha1=(((arcsin(120*sin(theta)/111))*180)/pi) #Applying the Law of Sines\n", + "alpha=alpha1+270 #As the vector lies in the fourth Quadrant by obsrevaton\n", + "#Results\n", + "print'The Resultant of The force system is equal to',round(R,3),\"lb\" #lb\n", + "print'The Resultant is at',round(alpha,3),\"degrees\" #degrees\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Resultant of The force system is equal to 111.355 lb\n", + "The Resultant is at 339.43 degrees\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2-2,Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Initilization of variables\n", + "P=100 #lb\n", + "Q=120 #lb\n", + "theta=((30*pi)/180) #radians\n", + "#Calculations\n", + "R_x=Q*cos(theta) #lb\n", + "R_y=Q*sin(theta)-P #lb\n", + "R=sqrt(R_x**2+R_y**2) #lb Triangle law\n", + "Theta_1=((arctan(R_y/R_x))*180)/pi #degrees\n", + "Theta_R=360+Theta_1 #degrees\n", + "#Result\n", + "print'The resultant of the force system is',round(R,3),\"lb\"\n", + "print'The resultant is at',round(Theta_R,3),\"degrees\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The resultant of the force system is 111.355 lb\n", + "The resultant is at 338.948 degrees\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/DanishAnsari/chapter_1.ipynb b/sample_notebooks/DanishAnsari/chapter_1.ipynb deleted file mode 100755 index 13a30876..00000000 --- a/sample_notebooks/DanishAnsari/chapter_1.ipynb +++ /dev/null @@ -1,111 +0,0 @@ -{ - "metadata": { - "name": "chapter 1.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Vectors" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1-1,Page no 8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initialisation of Variables\n", - "f1=120 #lb\n", - "f2=100 #lb\n", - "theta=((60*pi)/180) #radians\n", - "#Calculations\n", - "R=sqrt(120**2+100**2-(2*120*100*cos(theta))) #Applying Thr rule of Cosines\n", - "alpha1=(((arcsin(120*sin(theta)/111))*180)/pi) #Applying the Law of Sines\n", - "alpha=alpha1+270 #As the vector lies in the fourth Quadrant by obsrevaton\n", - "#Results\n", - "print'The Resultant of The force system is equal to',round(R,3),\"lb\" #lb\n", - "print'The Resultant is at',round(alpha,3),\"degrees\" #degrees\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Resultant of The force system is equal to 111.355 lb\n", - "The Resultant is at 339.43 degrees\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2-2,Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Initilization of variables\n", - "P=100 #lb\n", - "Q=120 #lb\n", - "theta=((30*pi)/180) #radians\n", - "#Calculations\n", - "R_x=Q*cos(theta) #lb\n", - "R_y=Q*sin(theta)-P #lb\n", - "R=sqrt(R_x**2+R_y**2) #lb Triangle law\n", - "Theta_1=((arctan(R_y/R_x))*180)/pi #degrees\n", - "Theta_R=360+Theta_1 #degrees\n", - "#Result\n", - "print'The resultant of the force system is',round(R,3),\"lb\"\n", - "print'The resultant is at',round(Theta_R,3),\"degrees\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The resultant of the force system is 111.355 lb\n", - "The resultant is at 338.948 degrees\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb b/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb deleted file mode 100755 index d7167f86..00000000 --- a/sample_notebooks/DaudIbrahir Saifi/Chapter_07.ipynb +++ /dev/null @@ -1,341 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:012ab8557afdcfdae2cdc3da17271647415fc17ab95dd187f4df0903472edf45" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter - 7 : Cathode Ray Oscilloscopes" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.1 - Page No : 244" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "l=2.5 # in cm\n", - "l=l*10**-2 # in meter\n", - "d=.5 # in cm\n", - "d=d*10**-2 # in meter\n", - "S= 20 # in cm\n", - "S= S*10**-2 # in meter\n", - "Va= 2500 # in volts\n", - "# Formula y = OC*AB/OB = (S*d/2)/(l/2)\n", - "y = (S*d/2)/(l/2) # in meter\n", - "print \"The value of deflection = %0.f cm\" %(y*10**2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of deflection = 4 cm\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.2 - Page No : 244" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " #Given data\n", - "R_E1= 5.6 # in kohm\n", - "C1= 0.2 # in micro F\n", - "V_B1= 6.3 # in volt\n", - "V_BE= 0.7 # in volt\n", - "TL= 2.5 # trigger level for the Schmitt trigger (UTP,LTP) in volt\n", - "del_V1= 2*TL # in volt\n", - "I_C1= (V_B1-V_BE)/R_E1 # in mA\n", - "print \"Charging current = %0.f mA\" %I_C1 \n", - "toh= del_V1*C1/I_C1 # in ms\n", - "print \"Time period = %0.f ms\" %toh" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Charging current = 1 mA\n", - "Time period = 1 ms\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.3 - Page No : 255" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import sqrt \n", - "#Given data\n", - "L=10 # trace length in cm\n", - "DS= 5 # deflection sensitivity in V/cm\n", - "V_peakTOpeak= L*DS # in volt\n", - "V_peak= V_peakTOpeak/2 # in volt\n", - "RMS= V_peak/sqrt(2) # RMS value of unknown as voltage in volt\n", - "print \"The value of AC voltage = %0.3f volts\" %RMS " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of AC voltage = 17.678 volts\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.4 - Page No : 255" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division \n", - "#Given data\n", - "Y= 2+1/2 # Positive Y-peaks in pattern\n", - "X= 1/2+1/2 # Positive X-peaks in pattern\n", - "f_h= 3# frequency of horizontal voltage signal in kHz\n", - "f_yBYf_x= Y/X \n", - "# frequency of vertical voltage signal= f_yBYf_x * f_h\n", - "f_v= f_yBYf_x * f_h # frequency of vertical voltage signal in kHz\n", - "print \"frequency of vertical voltage signal = %0.1f kHz\" %f_v " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "frequency of vertical voltage signal = 7.5 kHz\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.5 - Page No : 256" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " #Given data\n", - "f_x= 1000 # in Hz\n", - "Y= 2 # points of tangency to vertical line\n", - "X= 5 # points of tangency to horizontal line\n", - "f_y= f_x*X/Y # in Hz\n", - "print \"Frequency of vertical input = %0.f Hz\" %f_y" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Frequency of vertical input = 2500 Hz\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.6 - Page No : 257" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " #Given data\n", - "f=2000 # in Hz\n", - "T=1/f # in sec\n", - "D=0.2 \n", - "PulseDuration= D*T # in sec\n", - "print \"The value of pulse duration = %0.1f ms\" %(PulseDuration*10**3) " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of pulse duration = 0.1 ms\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.7 - Page No : 258" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " #Given data\n", - "vertical_attenuation= 0.5 # in V/Div\n", - "TPD= 2 # time/Div control in micro sec\n", - "P= 4*vertical_attenuation # peak-to-peak amplitude of the signal in V \n", - "print \"Peak-to-Peak amplitude of the signal = %0.f V\" %P\n", - "T= 4*TPD # in micro sec\n", - "T=T*10**-6 # in sec\n", - "f=1/T # in Hz\n", - "print \"The value of frequency = %0.f kHz\" %(f*10**-3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Peak-to-Peak amplitude of the signal = 2 V\n", - "The value of frequency = 125 kHz\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.8 - Page No : 261" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import pi \n", - "#Given data\n", - "C_1N= 36 # in pF\n", - "C_2= 150 # in pF\n", - "R_1N= 1 # in M ohm\n", - "R_1= 10 # in M ohm\n", - "R_source= 500 # in ohm\n", - "# R_1/(omega*(C_2+C_1N)) = R_1N/(omega*C_1)\n", - "C_1= R_1N*(C_2+C_1N)/R_1 # in pF\n", - "C_T= 1/(1/C_1+1/(C_2+C_1N)) # in pF\n", - "C_T= C_T*10**-12 # in F\n", - "f= 1/(2*pi*C_T*R_source) \n", - "print \"Signal Frequency = %0.2f MHz\" %(f*10**-6)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Signal Frequency = 18.82 MHz\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example : 7.9 - Page No : 263" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - " #Given data\n", - "f= 20 # in MHz\n", - "f=f*10**6 # in Hz\n", - "toh= 1/f # in sec\n", - "toh=toh*10**9 # in ns\n", - "# For one cycle occupying 4 horizontal divisions,\n", - "MTD= toh/4 # Minimum time/division in ns/division\n", - "# Using the 10 times magnifier to provide MTD\n", - "MTD_setting= 10*MTD # minimum time/division setting in ns/division\n", - "print \"Minimum time/division setting = %0.f ns/division\" %MTD_setting" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Minimum time/division setting = 125 ns/division\n" - ] - } - ], - "prompt_number": 12 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/DaudIbrahir Saifi/DaudIbrahir Saifi_version_backup/Chapter_07.ipynb b/sample_notebooks/DaudIbrahir Saifi/DaudIbrahir Saifi_version_backup/Chapter_07.ipynb new file mode 100755 index 00000000..d7167f86 --- /dev/null +++ b/sample_notebooks/DaudIbrahir Saifi/DaudIbrahir Saifi_version_backup/Chapter_07.ipynb @@ -0,0 +1,341 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:012ab8557afdcfdae2cdc3da17271647415fc17ab95dd187f4df0903472edf45" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter - 7 : Cathode Ray Oscilloscopes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.1 - Page No : 244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "l=2.5 # in cm\n", + "l=l*10**-2 # in meter\n", + "d=.5 # in cm\n", + "d=d*10**-2 # in meter\n", + "S= 20 # in cm\n", + "S= S*10**-2 # in meter\n", + "Va= 2500 # in volts\n", + "# Formula y = OC*AB/OB = (S*d/2)/(l/2)\n", + "y = (S*d/2)/(l/2) # in meter\n", + "print \"The value of deflection = %0.f cm\" %(y*10**2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of deflection = 4 cm\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.2 - Page No : 244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "R_E1= 5.6 # in kohm\n", + "C1= 0.2 # in micro F\n", + "V_B1= 6.3 # in volt\n", + "V_BE= 0.7 # in volt\n", + "TL= 2.5 # trigger level for the Schmitt trigger (UTP,LTP) in volt\n", + "del_V1= 2*TL # in volt\n", + "I_C1= (V_B1-V_BE)/R_E1 # in mA\n", + "print \"Charging current = %0.f mA\" %I_C1 \n", + "toh= del_V1*C1/I_C1 # in ms\n", + "print \"Time period = %0.f ms\" %toh" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Charging current = 1 mA\n", + "Time period = 1 ms\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.3 - Page No : 255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt \n", + "#Given data\n", + "L=10 # trace length in cm\n", + "DS= 5 # deflection sensitivity in V/cm\n", + "V_peakTOpeak= L*DS # in volt\n", + "V_peak= V_peakTOpeak/2 # in volt\n", + "RMS= V_peak/sqrt(2) # RMS value of unknown as voltage in volt\n", + "print \"The value of AC voltage = %0.3f volts\" %RMS " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of AC voltage = 17.678 volts\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.4 - Page No : 255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division \n", + "#Given data\n", + "Y= 2+1/2 # Positive Y-peaks in pattern\n", + "X= 1/2+1/2 # Positive X-peaks in pattern\n", + "f_h= 3# frequency of horizontal voltage signal in kHz\n", + "f_yBYf_x= Y/X \n", + "# frequency of vertical voltage signal= f_yBYf_x * f_h\n", + "f_v= f_yBYf_x * f_h # frequency of vertical voltage signal in kHz\n", + "print \"frequency of vertical voltage signal = %0.1f kHz\" %f_v " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "frequency of vertical voltage signal = 7.5 kHz\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.5 - Page No : 256" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f_x= 1000 # in Hz\n", + "Y= 2 # points of tangency to vertical line\n", + "X= 5 # points of tangency to horizontal line\n", + "f_y= f_x*X/Y # in Hz\n", + "print \"Frequency of vertical input = %0.f Hz\" %f_y" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Frequency of vertical input = 2500 Hz\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.6 - Page No : 257" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f=2000 # in Hz\n", + "T=1/f # in sec\n", + "D=0.2 \n", + "PulseDuration= D*T # in sec\n", + "print \"The value of pulse duration = %0.1f ms\" %(PulseDuration*10**3) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of pulse duration = 0.1 ms\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.7 - Page No : 258" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "vertical_attenuation= 0.5 # in V/Div\n", + "TPD= 2 # time/Div control in micro sec\n", + "P= 4*vertical_attenuation # peak-to-peak amplitude of the signal in V \n", + "print \"Peak-to-Peak amplitude of the signal = %0.f V\" %P\n", + "T= 4*TPD # in micro sec\n", + "T=T*10**-6 # in sec\n", + "f=1/T # in Hz\n", + "print \"The value of frequency = %0.f kHz\" %(f*10**-3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Peak-to-Peak amplitude of the signal = 2 V\n", + "The value of frequency = 125 kHz\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.8 - Page No : 261" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi \n", + "#Given data\n", + "C_1N= 36 # in pF\n", + "C_2= 150 # in pF\n", + "R_1N= 1 # in M ohm\n", + "R_1= 10 # in M ohm\n", + "R_source= 500 # in ohm\n", + "# R_1/(omega*(C_2+C_1N)) = R_1N/(omega*C_1)\n", + "C_1= R_1N*(C_2+C_1N)/R_1 # in pF\n", + "C_T= 1/(1/C_1+1/(C_2+C_1N)) # in pF\n", + "C_T= C_T*10**-12 # in F\n", + "f= 1/(2*pi*C_T*R_source) \n", + "print \"Signal Frequency = %0.2f MHz\" %(f*10**-6)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Signal Frequency = 18.82 MHz\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example : 7.9 - Page No : 263" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + " #Given data\n", + "f= 20 # in MHz\n", + "f=f*10**6 # in Hz\n", + "toh= 1/f # in sec\n", + "toh=toh*10**9 # in ns\n", + "# For one cycle occupying 4 horizontal divisions,\n", + "MTD= toh/4 # Minimum time/division in ns/division\n", + "# Using the 10 times magnifier to provide MTD\n", + "MTD_setting= 10*MTD # minimum time/division setting in ns/division\n", + "print \"Minimum time/division setting = %0.f ns/division\" %MTD_setting" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum time/division setting = 125 ns/division\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/DeepTrambadia/DeepTrambadia_version_backup/sc201.ipynb b/sample_notebooks/DeepTrambadia/DeepTrambadia_version_backup/sc201.ipynb new file mode 100755 index 00000000..b76b0ff0 --- /dev/null +++ b/sample_notebooks/DeepTrambadia/DeepTrambadia_version_backup/sc201.ipynb @@ -0,0 +1,53 @@ +import math + +#(a) +#initialisation of variables + +E=10 #E in V +R=1 #R in Kohm + + +#Calculations + +Id=E/R #Eq.(2.2) +Vd=E +print "The current Ic is= %fmA "%(Id),";Vd=0V" +print "The diode voltage is= %fV"%(Vd),";Id=0A" +print "The resulting load line appears in Fig. 2.4. The intersection between the load line and the characteristic curve defines the Q-point as" +print "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy" + + +#(B) +print "(B)" +Ir=9.25 #Ir in mA +Vdq=0.78 #Vdq in v +Vr=Ir*R +print "Vr = Ir*R = Idq*R %d="%(Vr),"or" +Vr = E-Vdq +print "Vr = E-Vdq = %f" %(Vr) +print "The difference in results is due to the accuracy with which the graph can be read. Ideally,the results obtained either way should be the same." + +#Graph solution to example 2.1 + +import numpy as np +import matplotlib.pyplot as plt + +Vd = np.linspace(0.0,10.0) +Id = np.linspace(0.0,10.0) +Id= -Vd + 10 +plt.plot(Vd, Id) +Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7] +Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0] + +plt.plot(Vd, Id,'yo-') + +plt.xlabel('Voltage (v)') +plt.ylabel('current (mA)') +plt.title('About as simple as it gets, folks') +plt.grid(True) +plt.savefig("test.png") + +plt.show() + +print "example 2.2:" +print "repeat the example 2.1 for R =2" \ No newline at end of file diff --git a/sample_notebooks/DeepTrambadia/Diode.ipynb b/sample_notebooks/DeepTrambadia/Diode.ipynb new file mode 100755 index 00000000..7297aefc --- /dev/null +++ b/sample_notebooks/DeepTrambadia/Diode.ipynb @@ -0,0 +1,679 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:90aab70b55d4896f0f22aa66f516161405cb3435a2adc68d32d5e3787e2d9de5" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2:Diode Applications\n" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 page : 53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#(a)\n", + "#initialisation of variables\n", + "\n", + "E=10 #E in V\n", + "R=1 #R in Kohm\n", + "\n", + "\n", + "#Calculations\n", + " \n", + "Id=E/R #Eq.(2.2)\n", + "Vd=E\n", + "print \"(a) \\nThe current Ic is = %fmA \"%(Id),\";Vd=0V\"\n", + "print \"The diode voltage is = %fV\"%(Vd),\";Id=0A\"\n", + "print \"\\nThe resulting load line appears in Fig. 2.4. The intersection between the load line \\nand the characteristic curve defines the Q-point as\"\n", + "print \"\\nThe level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. \\nA higher degree of accuracy would require a plot that would be much large and perhaps unwieldy\"\n", + "\n", + "\n", + "#(B)\n", + "print \"\\n(B)\\n\"\n", + "Ir=9.25 #Ir in mA\n", + "Vdq=0.78 #Vdq in v\n", + "Vr=Ir*R\n", + "print \"Vr = Ir*R = Idq*R = %dV\"%(Vr),\"or\"\n", + "Vr = E-Vdq\n", + "print \"Vr = E-Vdq = %fV\" %(Vr)\n", + "print \"\\nThe difference in results is due to the accuracy with which the graph can be read. \\nIdeally,the results obtained either way should be the same.\"\n", + "\n", + "#Graph solution to example 2.1\n", + "\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "\n", + "Vd = np.linspace(0.0,10.0)\n", + "Id = np.linspace(0.0,10.0)\n", + "Id= -Vd + 10\n", + "plt.plot(Vd, Id)\n", + "Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7]\n", + "Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0]\n", + "\n", + "plt.plot(Vd, Id,'yo-')\n", + "\n", + "plt.xlabel('Voltage (v)')\n", + "plt.ylabel('current (mA)')\n", + "plt.title('Characteristics of diode')\n", + "plt.grid(True)\n", + "plt.savefig(\"test.png\")\n", + "\n", + "plt.show()\n", + "\n", + "print \"example 2.2:\"\n", + "print \"repeat the example 2.1 for R =2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) \n", + "The current Ic is = 10.000000mA ;Vd=0V\n", + "The diode voltage is = 10.000000V ;Id=0A\n", + "\n", + "The resulting load line appears in Fig. 2.4. The intersection between the load line \n", + "and the characteristic curve defines the Q-point as\n", + "\n", + "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. \n", + "A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy\n", + "\n", + "(B)\n", + "\n", + "Vr = Ir*R = Idq*R = 9V or\n", + "Vr = E-Vdq = 9.220000V\n", + "\n", + "The difference in results is due to the accuracy with which the graph can be read. \n", + "Ideally,the results obtained either way should be the same.\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEZCAYAAACervI0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlcVPX6B/DPCLgBbgi4AGLubIJiuYuYmRaopRUuKJbd\nFi1bNZer9+pVqJtbaaWZWnmVtGvu3TSkLMMWVNRckhxwIXMBjVWW7++P+c0cQNbhzJw5cz7v14vX\ndWDmzMPT3Hl4vs/5ntEJIQSIiEhz6ikdABERKYMFgIhIo1gAiIg0igWAiEijWACIiDSKBYCISKNY\nAMgsCxYswMSJE5UOQxaHDh1C165dzXrsiBEj8Mknn8gcUeXmzp0Ld3d3tGnTpkb3r1evHn7//XcA\nwLPPPotFixaZ9bxhYWFYt26dWY8l28UCQJX6z3/+g9DQULi6uqJNmzYYMWIEvv/+ewCATqdTODqD\nDRs2YMCAAXU6xoABA3DmzJlq71dR0du7d6/VCmF6ejqWLl2KM2fO4MqVK7V+/HvvvYe5c+ea9dw6\nnc5m/puTfFgAqEJLly7FSy+9hLlz5+LPP//ExYsX8fzzz2PXrl0AADn3DxYXF8t2rNoqKipS7Llr\nKz09HW5ubnBzc1M6FLIXgqicrKws4eLiIrZt21bpfRYsWCAee+wxER0dLVxdXYW/v7/4+eefTT9f\nsmSJ6NChg3B1dRV+fn5i+/btpp+tX79e9O3bV7z00kvCzc1NzJs3T6SmporBgwcLNzc30bJlSzF+\n/HiRlZVlekx6eroYPXq0cHd3F25ubmLatGni9OnTokGDBsLBwUG4uLiI5s2bCyGEyM/PF6+88orw\n8fERnp6e4plnnhF5eXlCCCEOHjwo2rZtK+Li4kSrVq1EdHS0OHjwoPDy8jI9V2xsrGjbtq1wdXUV\nXbp0EV9//bXYt2+fqF+/vnBychIuLi4iODhYCCHEoEGDxIcffmh67Jo1a0S3bt1Mv3dycnKlx6ws\n9xMnThTu7u6iXbt2YtGiRaKkpETs379fNGrUSNSrV0+4uLiImJiYCh//5ptvitatW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JISqHl4Mm\nqoWcnBw4OzsjNzcXgwYNwtq1axEcHFzjx4eHh2PTpk1lZgHlnTt3Dq+++mqFRYRITuwAiGrh6aef\nRkhICHr27IkxY8bU6s0fAF599VW8//77Vd7n/fffx+uvv16XMIlqhB0AEZFGsQMgItIoFgAiIo1i\nASAi0igWACIijWIBICLSKBYAIiKN+j91tdZGQm+jrgAAAABJRU5ErkJggg==\n", + "text": [ + "" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "example 2.2:\n", + "repeat the example 2.1 for R =2\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page : 60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 2.6\n", + "#For the series diode configuration of Fig. 2.16, determine VD, VR, and ID.\n", + "\n", + "import math\n", + "\n", + "#initialisation of variables\n", + "\n", + "\n", + "E=8 #E in V\n", + "R=2.2 #R in Kohm\n", + "Vd=0.7 #Vd in V \n", + "\n", + "#Calculations\n", + "\n", + "Vr=E-Vd \n", + "Id=Vr/R \n", + "print \"Since the applied voltage establishes a current in the clockwise direction to match thearrow of the symbol \\nand the diode is in the 'on' state,\\n\"\n", + "print \"The diode voltage is = %.1fV\"%(Vd),\";Id=0A\"\n", + "print \"The voltage Vr is = %.1fV\"%(Vr)\n", + "print \"The current Id is = %.2fmA \"%(Id)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Since the applied voltage establishes a current in the clockwise direction to match thearrow of the symbol \n", + "and the diode is in the 'on' state,\n", + "\n", + "The diode voltage is = 0.7V ;Id=0A\n", + "The voltage Vr is = 7.3V\n", + "The current Id is = 3.32mA \n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page : 60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 2.7\n", + "#Repeat Example 2.6 with the diode reversed\n", + "\n", + "import math\n", + "\n", + "#initialisation of variables\n", + "\n", + "\n", + "E=8 #E in V\n", + "R=2.2 #R in Kohm\n", + "I=0 #For open circuit\n", + "\n", + "#Calculations\n", + "\n", + "Vr=I*R \n", + "Vd=E-Vr \n", + "print \"Removing the diode, we find that the direction of I is opposite to the arrow in the diode symbol \\nand the diode equivalent is the open circuit no matter which model isemployed.\"\n", + "print \"The result is the network of Fig. 2.17, where ID = 0A due to the open circuit.\\n\"\n", + "print \"The voltage Vr is = %.1fV\"%(Vr)\n", + "print \"The diode voltage is = %.1fV\"%(Vd)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Removing the diode, we find that the direction of I is opposite to the arrow in the diode symbol \n", + "and the diode equivalent is the open circuit no matter which model isemployed.\n", + "The result is the network of Fig. 2.17, where ID = 0A due to the open circuit.\n", + "\n", + "The voltage Vr is = 0.0V\n", + "The diode voltage is = 8.0V\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 Page : 61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 2.8\n", + "#For the series diode configuration of Fig. 2.19, determine VD, VR, and ID.\n", + "\n", + "import math\n", + "\n", + "#initialisation of variables\n", + "\n", + "\n", + "E=0.5 #E in volt\n", + "R=1.2 #R in Kohm\n", + "Id=0 #For open circuit\n", + "\n", + "\n", + "#calculation\n", + "\n", + "Vr=Id*R\n", + "Vd=E\n", + "\n", + "print \"The voltage Vr is = %.1fV\"%(Vr)\n", + "print \"The diode voltage Vd is = %.1fV\"%(Vd)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The voltage Vr is = 0.0V\n", + "The diode voltage Vd is = 0.5V\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 Page : 62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 2.9 Page no 62\n", + "\n", + "#initialisation of variables\n", + "\n", + "R=5.6 # resistance in kilo ohm\n", + "E=12\t\t\t # supply voltage in volt\n", + "Vt1=0.7 # threshold voltage of siicon in volt\n", + "Vt2=0.3 # threshold voltage of germanium in volt\n", + "\n", + "print \"Applying KVL rule in fig 2.2,\"\n", + "\n", + "Vo=E-(Vt1+Vt2) # resulting voltage in volt\n", + "\n", + "Id=(Vo/R)\n", + "\n", + "print \"The resulting voltage is = %dV\"%(Vo)\n", + "\n", + "print \"The current through diode is = %.2fmA\"%(Id)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Applying KVL rule in fig 2.2,\n", + "The resulting voltage is = 11V\n", + "The current through diode is = 1.96mA\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.12 Page : 64" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialisation of variables\n", + "\n", + "E=10 #supply voltage in vol't\n", + "R=0.33 #resistance in kilo ohms\n", + "Vd=0.7 # voltage across silicon diode\n", + "\n", + "print\"From figure 2.31 it can be said that both diodes are opened so\"\n", + "\n", + "Vo=0.7 # resulting voltage in volt\n", + "\n", + "I1=(E-Vd)/R\n", + "print\"the value of Id1 is = %.2fmA\"%(I1)\n", + "print\"\\nDiodes are of similar characteristics so\"\n", + "\n", + "Id2=(I1/2)\n", + "print\"the value of Id2 is = %.2fmA\"%(Id2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "From figure 2.31 it can be said that both diodes are opened so\n", + "the value of Id1 is = 28.18mA\n", + "\n", + "Diodes are of similar characteristics so\n", + "the value of Id2 is = 14.09mA\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13 Page : 65" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialization of variables\n", + "\n", + "E1=20 #supply voltage in V\n", + "E2=4 #second port voltage in V\n", + "Vd=0.7 #thresold voltage\n", + "R=2.2 #R in Kohm\n", + "\n", + "\n", + "#calculation\n", + "\n", + "I = (E1-E2-Vd)/R\n", + "\n", + "print \"Diode D1 turn on and Diode D2 turn off\"\n", + "print \"the resultant current I is = %.2fmA\" %(I)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diode D1 turn on and Diode D2 turn off\n", + "the resultant current I is = 6.95mA\n" + ] + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.14 Page :66" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialization of variables\n", + "E=12 #supply Voltage in V\n", + "Vd=0.3 #thresold voltage in V\n", + "\n", + "\n", + "#calculation\n", + "\n", + "V0 = E-Vd\n", + "\n", + "print \"If initially both were 'on,'' the 0.7-V drop across the silicon diode would not match the 0.3 V \"\n", + "print \"Across the germanium diode as required by the fact that the voltage across parallel elements must be the same.\"\n", + "print \"\\nThe silicon diode will never have the opportunity to capture its required 0.7 V \\nand therefore remains in its open-circuit state.\"\n", + "print \"the resultant Voltage V0 is = %.1fV\" % (V0)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "If initially both were 'on,'' the 0.7-V drop across the silicon diode would not match the 0.3 V \n", + "Across the germanium diode as required by the fact that the voltage across parallel elements must be the same.\n", + "\n", + "The silicon diode will never have the opportunity to capture its required 0.7 V \n", + "and therefore remains in its open-circuit state.\n", + "the resultant Voltage V0 is = 11.7V\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.15 Page :66" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialization of variables\n", + "\n", + "E=20 #supply voltage in V\n", + "VT1=0.7 #thresold voltage\n", + "VT2=0.7 #thresold voltage\n", + "R1=3.3 #R in Kohm\n", + "R2=5.6 #R in Kohm\n", + "\n", + "#calculation\n", + "\n", + "print \"Both Diodes will turn 'on'\"\n", + "print \"So diode voltage will appear over the resistance\"\n", + "\n", + "I1 = (VT2)/R1\n", + "\n", + "print \"the resultant current I2 is = %.3fmA\" %(I1)\n", + "\n", + "print \"\\nApplying Kirchhoff's voltage law around the indicated loop in the clockwise direction yields\"\n", + "\n", + "V2 = E-VT1-VT2\n", + "I2 = V2/R2\n", + "\n", + "print \"the voltage V2 = %.1fV\" %(V2)\n", + "print \"the current I2 = %.2fmA\"%(I2)\n", + "\n", + "#At hte bottom node (a)\n", + "\n", + "ID2=I2-I1\n", + "\n", + "print \"the current I2 = %.3fmA\" %(ID2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Both Diodes will turn 'on'\n", + "So diode voltage will appear over the resistance\n", + "the resultant current I2 is = 0.212mA\n", + "\n", + "Applying Kirchhoff's voltage law around the indicated loop in the clockwise direction yields\n", + "the voltage V2 = 18.6V\n", + "the current I2 = 3.32mA\n", + "the current I2 = 3.109mA\n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.18 Page :71" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialization of variables\n", + "\n", + "Vm=20 #peak voltage in V\n", + "VT=0.7 #thresold voltage in V\n", + "\n", + "\n", + "#calculation\n", + "#(a)\n", + "print \"(a)\\nIdeal Diode:\"\n", + "\n", + "Vdc1= -(0.318*Vm) #Vdc=-0.318(Vm-VT)\n", + "\n", + "print \" In this situation the diode will conduct during the negative part of the input\"\n", + "print \"For the full period DC level is = %.2fV\" %(Vdc1)\n", + "print \"\\nThe negative sign indicates that the polarity of the output is opposite to the defined polarity\"\n", + "\n", + "\n", + "#(b)\n", + "\n", + "print \"\\n(b)\\nsilicon Diode:\"\n", + "\n", + "Vdc2= -0.318*(Vm-0.7)\n", + "\n", + "print \"Vdc2 = %.2fV\" %(Vdc2)\n", + "\n", + "#(c)\n", + "\n", + "print \"\\n(c)\\nIf Vm is increased to 200V:\"\n", + "\n", + "Vm = 200 #new peak voltage\n", + "Vdc1= -(0.318*Vm)\n", + "Vdc2= -0.318*(Vm-0.7)\n", + "\n", + "print \"using (a), Vdc = %.2fV\" %(Vdc1)\n", + "print \"using (b), Vdc = %.2fV\" %(Vdc2)\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)\n", + "Ideal Diode:\n", + " In this situation the diode will conduct during the negative part of the input\n", + "For the full period DC level is = -6.36V\n", + "\n", + "The negative sign indicates that the polarity of the output is opposite to the defined polarity\n", + "\n", + "(b)\n", + "silicon Diode:\n", + "Vdc2 = -6.14V\n", + "\n", + "(c)\n", + "If Vm is increased to 200V:\n", + "using (a), Vdc = -63.60V\n", + "using (b), Vdc = -63.38V\n" + ] + } + ], + "prompt_number": 43 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.19 Page :75" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 2.19 page no.75\n", + "\n", + "import math\n", + "\n", + "#initialization of variables\n", + "Vi=10 #input voltage in V\n", + "\n", + "#calculation\n", + "\n", + "print \"After redrawing the network configuration,\"\n", + "\n", + "V0 = 0.5*Vi\n", + "\n", + "print \"voltage across the resistance V0 = %dV\" %(V0)\n", + "print \"\\nFor the negative part of the input the roles of the diodes will be interchanged\"\n", + "\n", + "#The effect of removing diodes\n", + "\n", + "Vdc = 0.636*(V0)\n", + "print \"The effect of removing diodes:\"\n", + "print \"\\tReduced available DC level = %.2fV\" %(Vdc)\n", + "print \"\\tPIV = the maximum voltage across R is = %dV\" %(V0)\n", + "print \"or half of that required for a half-wave rectifier with the same input\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "After redrawing the network configuration,\n", + "voltage across the resistance V0 = 5V\n", + "\n", + "For the negative part of the input the roles of the diodes will be interchanged\n", + "The effect of removing diodes:\n", + "\tReduced available DC level = 3.18V\n", + "\tPIV = the maximum voltage across R is = 5V\n", + "or half of that required for a half-wave rectifier with the same input\n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/DeepTrambadia/Diode_Applications.ipynb b/sample_notebooks/DeepTrambadia/Diode_Applications.ipynb deleted file mode 100755 index 7297aefc..00000000 --- a/sample_notebooks/DeepTrambadia/Diode_Applications.ipynb +++ /dev/null @@ -1,679 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:90aab70b55d4896f0f22aa66f516161405cb3435a2adc68d32d5e3787e2d9de5" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2:Diode Applications\n" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 page : 53" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#(a)\n", - "#initialisation of variables\n", - "\n", - "E=10 #E in V\n", - "R=1 #R in Kohm\n", - "\n", - "\n", - "#Calculations\n", - " \n", - "Id=E/R #Eq.(2.2)\n", - "Vd=E\n", - "print \"(a) \\nThe current Ic is = %fmA \"%(Id),\";Vd=0V\"\n", - "print \"The diode voltage is = %fV\"%(Vd),\";Id=0A\"\n", - "print \"\\nThe resulting load line appears in Fig. 2.4. The intersection between the load line \\nand the characteristic curve defines the Q-point as\"\n", - "print \"\\nThe level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. \\nA higher degree of accuracy would require a plot that would be much large and perhaps unwieldy\"\n", - "\n", - "\n", - "#(B)\n", - "print \"\\n(B)\\n\"\n", - "Ir=9.25 #Ir in mA\n", - "Vdq=0.78 #Vdq in v\n", - "Vr=Ir*R\n", - "print \"Vr = Ir*R = Idq*R = %dV\"%(Vr),\"or\"\n", - "Vr = E-Vdq\n", - "print \"Vr = E-Vdq = %fV\" %(Vr)\n", - "print \"\\nThe difference in results is due to the accuracy with which the graph can be read. \\nIdeally,the results obtained either way should be the same.\"\n", - "\n", - "#Graph solution to example 2.1\n", - "\n", - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "\n", - "Vd = np.linspace(0.0,10.0)\n", - "Id = np.linspace(0.0,10.0)\n", - "Id= -Vd + 10\n", - "plt.plot(Vd, Id)\n", - "Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7]\n", - "Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0]\n", - "\n", - "plt.plot(Vd, Id,'yo-')\n", - "\n", - "plt.xlabel('Voltage (v)')\n", - "plt.ylabel('current (mA)')\n", - "plt.title('Characteristics of diode')\n", - "plt.grid(True)\n", - "plt.savefig(\"test.png\")\n", - "\n", - "plt.show()\n", - "\n", - "print \"example 2.2:\"\n", - "print \"repeat the example 2.1 for R =2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) \n", - "The current Ic is = 10.000000mA ;Vd=0V\n", - "The diode voltage is = 10.000000V ;Id=0A\n", - "\n", - "The resulting load line appears in Fig. 2.4. The intersection between the load line \n", - "and the characteristic curve defines the Q-point as\n", - "\n", - "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. \n", - "A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy\n", - "\n", - "(B)\n", - "\n", - "Vr = Ir*R = Idq*R = 9V or\n", - "Vr = E-Vdq = 9.220000V\n", - "\n", - "The difference in results is due to the accuracy with which the graph can be read. \n", - "Ideally,the results obtained either way should be the same.\n" - ] - }, - { - "metadata": {}, - "output_type": "display_data", - "png": "iVBORw0KGgoAAAANSUhEUgAAAYAAAAEZCAYAAACervI0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XlcVPX6B/DPCLgBbgi4AGLubIJiuYuYmRaopRUuKJbd\nFi1bNZer9+pVqJtbaaWZWnmVtGvu3TSkLMMWVNRckhxwIXMBjVWW7++P+c0cQNbhzJw5cz7v14vX\ndWDmzMPT3Hl4vs/5ntEJIQSIiEhz6ikdABERKYMFgIhIo1gAiIg0igWAiEijWACIiDSKBYCISKNY\nAMgsCxYswMSJE5UOQxaHDh1C165dzXrsiBEj8Mknn8gcUeXmzp0Ld3d3tGnTpkb3r1evHn7//XcA\nwLPPPotFixaZ9bxhYWFYt26dWY8l28UCQJX6z3/+g9DQULi6uqJNmzYYMWIEvv/+ewCATqdTODqD\nDRs2YMCAAXU6xoABA3DmzJlq71dR0du7d6/VCmF6ejqWLl2KM2fO4MqVK7V+/HvvvYe5c+ea9dw6\nnc5m/puTfFgAqEJLly7FSy+9hLlz5+LPP//ExYsX8fzzz2PXrl0AADn3DxYXF8t2rNoqKipS7Llr\nKz09HW5ubnBzc1M6FLIXgqicrKws4eLiIrZt21bpfRYsWCAee+wxER0dLVxdXYW/v7/4+eefTT9f\nsmSJ6NChg3B1dRV+fn5i+/btpp+tX79e9O3bV7z00kvCzc1NzJs3T6SmporBgwcLNzc30bJlSzF+\n/HiRlZVlekx6eroYPXq0cHd3F25ubmLatGni9OnTokGDBsLBwUG4uLiI5s2bCyGEyM/PF6+88orw\n8fERnp6e4plnnhF5eXlCCCEOHj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mVqKgonDhxAlFRUQCA1q1bIzY2FoMHD0ZwcDBC\nQ0NNSzfGN1w3Nzf069cPgYGBmDlzJsaPH4+ff/4ZQUFB+OSTT0wfvB4aGorIyEgEBQVhxIgRCAwM\nNH0m76ZNm7Bu3ToEBwcjICCgzODYqF+/fnd9gMvjjz+O//znP2WWfwDg6NGj6NOnj7zJISqHl4Mm\nqoWcnBw4OzsjNzcXgwYNwtq1axEcHFzjx4eHh2PTpk1lZgHlnTt3Dq+++mqFRYRITuwAiGrh6aef\nRkhICHr27IkxY8bU6s0fAF599VW8//77Vd7n/fffx+uvv16XMIlqhB0AEZFGsQMgItIoFgAiIo1i\nASAi0igWACIijWIBICLSKBYAIiKN+j91tdZGQm+jrgAAAABJRU5ErkJggg==\n", - "text": [ - "" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "example 2.2:\n", - "repeat the example 2.1 for R =2\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 Page : 60" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 2.6\n", - "#For the series diode configuration of Fig. 2.16, determine VD, VR, and ID.\n", - "\n", - "import math\n", - "\n", - "#initialisation of variables\n", - "\n", - "\n", - "E=8 #E in V\n", - "R=2.2 #R in Kohm\n", - "Vd=0.7 #Vd in V \n", - "\n", - "#Calculations\n", - "\n", - "Vr=E-Vd \n", - "Id=Vr/R \n", - "print \"Since the applied voltage establishes a current in the clockwise direction to match thearrow of the symbol \\nand the diode is in the 'on' state,\\n\"\n", - "print \"The diode voltage is = %.1fV\"%(Vd),\";Id=0A\"\n", - "print \"The voltage Vr is = %.1fV\"%(Vr)\n", - "print \"The current Id is = %.2fmA \"%(Id)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Since the applied voltage establishes a current in the clockwise direction to match thearrow of the symbol \n", - "and the diode is in the 'on' state,\n", - "\n", - "The diode voltage is = 0.7V ;Id=0A\n", - "The voltage Vr is = 7.3V\n", - "The current Id is = 3.32mA \n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 Page : 60" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 2.7\n", - "#Repeat Example 2.6 with the diode reversed\n", - "\n", - "import math\n", - "\n", - "#initialisation of variables\n", - "\n", - "\n", - "E=8 #E in V\n", - "R=2.2 #R in Kohm\n", - "I=0 #For open circuit\n", - "\n", - "#Calculations\n", - "\n", - "Vr=I*R \n", - "Vd=E-Vr \n", - "print \"Removing the diode, we find that the direction of I is opposite to the arrow in the diode symbol \\nand the diode equivalent is the open circuit no matter which model isemployed.\"\n", - "print \"The result is the network of Fig. 2.17, where ID = 0A due to the open circuit.\\n\"\n", - "print \"The voltage Vr is = %.1fV\"%(Vr)\n", - "print \"The diode voltage is = %.1fV\"%(Vd)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Removing the diode, we find that the direction of I is opposite to the arrow in the diode symbol \n", - "and the diode equivalent is the open circuit no matter which model isemployed.\n", - "The result is the network of Fig. 2.17, where ID = 0A due to the open circuit.\n", - "\n", - "The voltage Vr is = 0.0V\n", - "The diode voltage is = 8.0V\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8 Page : 61" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 2.8\n", - "#For the series diode configuration of Fig. 2.19, determine VD, VR, and ID.\n", - "\n", - "import math\n", - "\n", - "#initialisation of variables\n", - "\n", - "\n", - "E=0.5 #E in volt\n", - "R=1.2 #R in Kohm\n", - "Id=0 #For open circuit\n", - "\n", - "\n", - "#calculation\n", - "\n", - "Vr=Id*R\n", - "Vd=E\n", - "\n", - "print \"The voltage Vr is = %.1fV\"%(Vr)\n", - "print \"The diode voltage Vd is = %.1fV\"%(Vd)\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The voltage Vr is = 0.0V\n", - "The diode voltage Vd is = 0.5V\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.9 Page : 62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 2.9 Page no 62\n", - "\n", - "#initialisation of variables\n", - "\n", - "R=5.6 # resistance in kilo ohm\n", - "E=12\t\t\t # supply voltage in volt\n", - "Vt1=0.7 # threshold voltage of siicon in volt\n", - "Vt2=0.3 # threshold voltage of germanium in volt\n", - "\n", - "print \"Applying KVL rule in fig 2.2,\"\n", - "\n", - "Vo=E-(Vt1+Vt2) # resulting voltage in volt\n", - "\n", - "Id=(Vo/R)\n", - "\n", - "print \"The resulting voltage is = %dV\"%(Vo)\n", - "\n", - "print \"The current through diode is = %.2fmA\"%(Id)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Applying KVL rule in fig 2.2,\n", - "The resulting voltage is = 11V\n", - "The current through diode is = 1.96mA\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.12 Page : 64" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialisation of variables\n", - "\n", - "E=10 #supply voltage in vol't\n", - "R=0.33 #resistance in kilo ohms\n", - "Vd=0.7 # voltage across silicon diode\n", - "\n", - "print\"From figure 2.31 it can be said that both diodes are opened so\"\n", - "\n", - "Vo=0.7 # resulting voltage in volt\n", - "\n", - "I1=(E-Vd)/R\n", - "print\"the value of Id1 is = %.2fmA\"%(I1)\n", - "print\"\\nDiodes are of similar characteristics so\"\n", - "\n", - "Id2=(I1/2)\n", - "print\"the value of Id2 is = %.2fmA\"%(Id2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "From figure 2.31 it can be said that both diodes are opened so\n", - "the value of Id1 is = 28.18mA\n", - "\n", - "Diodes are of similar characteristics so\n", - "the value of Id2 is = 14.09mA\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.13 Page : 65" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialization of variables\n", - "\n", - "E1=20 #supply voltage in V\n", - "E2=4 #second port voltage in V\n", - "Vd=0.7 #thresold voltage\n", - "R=2.2 #R in Kohm\n", - "\n", - "\n", - "#calculation\n", - "\n", - "I = (E1-E2-Vd)/R\n", - "\n", - "print \"Diode D1 turn on and Diode D2 turn off\"\n", - "print \"the resultant current I is = %.2fmA\" %(I)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diode D1 turn on and Diode D2 turn off\n", - "the resultant current I is = 6.95mA\n" - ] - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.14 Page :66" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialization of variables\n", - "E=12 #supply Voltage in V\n", - "Vd=0.3 #thresold voltage in V\n", - "\n", - "\n", - "#calculation\n", - "\n", - "V0 = E-Vd\n", - "\n", - "print \"If initially both were 'on,'' the 0.7-V drop across the silicon diode would not match the 0.3 V \"\n", - "print \"Across the germanium diode as required by the fact that the voltage across parallel elements must be the same.\"\n", - "print \"\\nThe silicon diode will never have the opportunity to capture its required 0.7 V \\nand therefore remains in its open-circuit state.\"\n", - "print \"the resultant Voltage V0 is = %.1fV\" % (V0)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "If initially both were 'on,'' the 0.7-V drop across the silicon diode would not match the 0.3 V \n", - "Across the germanium diode as required by the fact that the voltage across parallel elements must be the same.\n", - "\n", - "The silicon diode will never have the opportunity to capture its required 0.7 V \n", - "and therefore remains in its open-circuit state.\n", - "the resultant Voltage V0 is = 11.7V\n" - ] - } - ], - "prompt_number": 32 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.15 Page :66" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialization of variables\n", - "\n", - "E=20 #supply voltage in V\n", - "VT1=0.7 #thresold voltage\n", - "VT2=0.7 #thresold voltage\n", - "R1=3.3 #R in Kohm\n", - "R2=5.6 #R in Kohm\n", - "\n", - "#calculation\n", - "\n", - "print \"Both Diodes will turn 'on'\"\n", - "print \"So diode voltage will appear over the resistance\"\n", - "\n", - "I1 = (VT2)/R1\n", - "\n", - "print \"the resultant current I2 is = %.3fmA\" %(I1)\n", - "\n", - "print \"\\nApplying Kirchhoff's voltage law around the indicated loop in the clockwise direction yields\"\n", - "\n", - "V2 = E-VT1-VT2\n", - "I2 = V2/R2\n", - "\n", - "print \"the voltage V2 = %.1fV\" %(V2)\n", - "print \"the current I2 = %.2fmA\"%(I2)\n", - "\n", - "#At hte bottom node (a)\n", - "\n", - "ID2=I2-I1\n", - "\n", - "print \"the current I2 = %.3fmA\" %(ID2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Both Diodes will turn 'on'\n", - "So diode voltage will appear over the resistance\n", - "the resultant current I2 is = 0.212mA\n", - "\n", - "Applying Kirchhoff's voltage law around the indicated loop in the clockwise direction yields\n", - "the voltage V2 = 18.6V\n", - "the current I2 = 3.32mA\n", - "the current I2 = 3.109mA\n" - ] - } - ], - "prompt_number": 35 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.18 Page :71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialization of variables\n", - "\n", - "Vm=20 #peak voltage in V\n", - "VT=0.7 #thresold voltage in V\n", - "\n", - "\n", - "#calculation\n", - "#(a)\n", - "print \"(a)\\nIdeal Diode:\"\n", - "\n", - "Vdc1= -(0.318*Vm) #Vdc=-0.318(Vm-VT)\n", - "\n", - "print \" In this situation the diode will conduct during the negative part of the input\"\n", - "print \"For the full period DC level is = %.2fV\" %(Vdc1)\n", - "print \"\\nThe negative sign indicates that the polarity of the output is opposite to the defined polarity\"\n", - "\n", - "\n", - "#(b)\n", - "\n", - "print \"\\n(b)\\nsilicon Diode:\"\n", - "\n", - "Vdc2= -0.318*(Vm-0.7)\n", - "\n", - "print \"Vdc2 = %.2fV\" %(Vdc2)\n", - "\n", - "#(c)\n", - "\n", - "print \"\\n(c)\\nIf Vm is increased to 200V:\"\n", - "\n", - "Vm = 200 #new peak voltage\n", - "Vdc1= -(0.318*Vm)\n", - "Vdc2= -0.318*(Vm-0.7)\n", - "\n", - "print \"using (a), Vdc = %.2fV\" %(Vdc1)\n", - "print \"using (b), Vdc = %.2fV\" %(Vdc2)\n", - "\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a)\n", - "Ideal Diode:\n", - " In this situation the diode will conduct during the negative part of the input\n", - "For the full period DC level is = -6.36V\n", - "\n", - "The negative sign indicates that the polarity of the output is opposite to the defined polarity\n", - "\n", - "(b)\n", - "silicon Diode:\n", - "Vdc2 = -6.14V\n", - "\n", - "(c)\n", - "If Vm is increased to 200V:\n", - "using (a), Vdc = -63.60V\n", - "using (b), Vdc = -63.38V\n" - ] - } - ], - "prompt_number": 43 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.19 Page :75" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 2.19 page no.75\n", - "\n", - "import math\n", - "\n", - "#initialization of variables\n", - "Vi=10 #input voltage in V\n", - "\n", - "#calculation\n", - "\n", - "print \"After redrawing the network configuration,\"\n", - "\n", - "V0 = 0.5*Vi\n", - "\n", - "print \"voltage across the resistance V0 = %dV\" %(V0)\n", - "print \"\\nFor the negative part of the input the roles of the diodes will be interchanged\"\n", - "\n", - "#The effect of removing diodes\n", - "\n", - "Vdc = 0.636*(V0)\n", - "print \"The effect of removing diodes:\"\n", - "print \"\\tReduced available DC level = %.2fV\" %(Vdc)\n", - "print \"\\tPIV = the maximum voltage across R is = %dV\" %(V0)\n", - "print \"or half of that required for a half-wave rectifier with the same input\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "After redrawing the network configuration,\n", - "voltage across the resistance V0 = 5V\n", - "\n", - "For the negative part of the input the roles of the diodes will be interchanged\n", - "The effect of removing diodes:\n", - "\tReduced available DC level = 3.18V\n", - "\tPIV = the maximum voltage across R is = 5V\n", - "or half of that required for a half-wave rectifier with the same input\n" - ] - } - ], - "prompt_number": 38 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/DeepTrambadia/sc201.ipynb b/sample_notebooks/DeepTrambadia/sc201.ipynb deleted file mode 100755 index b76b0ff0..00000000 --- a/sample_notebooks/DeepTrambadia/sc201.ipynb +++ /dev/null @@ -1,53 +0,0 @@ -import math - -#(a) -#initialisation of variables - -E=10 #E in V -R=1 #R in Kohm - - -#Calculations - -Id=E/R #Eq.(2.2) -Vd=E -print "The current Ic is= %fmA "%(Id),";Vd=0V" -print "The diode voltage is= %fV"%(Vd),";Id=0A" -print "The resulting load line appears in Fig. 2.4. The intersection between the load line and the characteristic curve defines the Q-point as" -print "The level of VD is certainly an estimate, and the accuracy of ID is limited by the chosenscale. A higher degree of accuracy would require a plot that would be much large and perhaps unwieldy" - - -#(B) -print "(B)" -Ir=9.25 #Ir in mA -Vdq=0.78 #Vdq in v -Vr=Ir*R -print "Vr = Ir*R = Idq*R %d="%(Vr),"or" -Vr = E-Vdq -print "Vr = E-Vdq = %f" %(Vr) -print "The difference in results is due to the accuracy with which the graph can be read. Ideally,the results obtained either way should be the same." - -#Graph solution to example 2.1 - -import numpy as np -import matplotlib.pyplot as plt - -Vd = np.linspace(0.0,10.0) -Id = np.linspace(0.0,10.0) -Id= -Vd + 10 -plt.plot(Vd, Id) -Vd = [0,0,0.1,0.1,0.2,0.2,0.3,0.3,0.3,0.3,0.4,0.5,0.6,0.7] -Id = [0,0,0,0,0,0,0,0,0.1,0.1,0.3,0.7,2.0,10.0] - -plt.plot(Vd, Id,'yo-') - -plt.xlabel('Voltage (v)') -plt.ylabel('current (mA)') -plt.title('About as simple as it gets, folks') -plt.grid(True) -plt.savefig("test.png") - -plt.show() - -print "example 2.2:" -print "repeat the example 2.1 for R =2" \ No newline at end of file diff --git a/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication.ipynb b/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication.ipynb new file mode 100755 index 00000000..42a985ca --- /dev/null +++ b/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication.ipynb @@ -0,0 +1,102 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 Introduction to Radio Communication Systems" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_3 pgno:3" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The transfer function has no finite zeros \n", + "The poles \n", + "[-0.25+0.96824584j -0.25-0.96824584j]\n" + ] + } + ], + "source": [ + "\n", + "#Chapter 1:Introduction to Radio Communication\n", + "#example 1.3 page no 3\n", + "#given\n", + "import numpy\n", + "print('The transfer function has no finite zeros ')\n", + "p=numpy.array([1, 0.5, 1])\n", + "x=numpy.roots(p)\n", + "print('The poles ')\n", + "print(x)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_4 pgno:8" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the image frequency is MHz 1.91\n" + ] + } + ], + "source": [ + "\n", + "#Chapter 1:Introduction to Radio Communication Systems\n", + "#example 1.4 page no 8\n", + "#given\n", + "fIF=455*10**3#intermediate frequency\n", + "fO=1.455*10**6#oscillator frequency\n", + "fIM=fIF+fO#image frequency\n", + "print'the image frequency is MHz',fIM*1e-6\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication_Systems.ipynb b/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication_Systems.ipynb deleted file mode 100755 index 42a985ca..00000000 --- a/sample_notebooks/DesuSandeep Kumar/Chapter_1_Introduction_to_Radio_Communication_Systems.ipynb +++ /dev/null @@ -1,102 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 Introduction to Radio Communication Systems" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_3 pgno:3" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The transfer function has no finite zeros \n", - "The poles \n", - "[-0.25+0.96824584j -0.25-0.96824584j]\n" - ] - } - ], - "source": [ - "\n", - "#Chapter 1:Introduction to Radio Communication\n", - "#example 1.3 page no 3\n", - "#given\n", - "import numpy\n", - "print('The transfer function has no finite zeros ')\n", - "p=numpy.array([1, 0.5, 1])\n", - "x=numpy.roots(p)\n", - "print('The poles ')\n", - "print(x)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_4 pgno:8" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the image frequency is MHz 1.91\n" - ] - } - ], - "source": [ - "\n", - "#Chapter 1:Introduction to Radio Communication Systems\n", - "#example 1.4 page no 8\n", - "#given\n", - "fIF=455*10**3#intermediate frequency\n", - "fO=1.455*10**6#oscillator frequency\n", - "fIM=fIF+fO#image frequency\n", - "print'the image frequency is MHz',fIM*1e-6\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Dileep KumarShakya/Dileep KumarShakya_version_backup/chapter1.ipynb b/sample_notebooks/Dileep KumarShakya/Dileep KumarShakya_version_backup/chapter1.ipynb new file mode 100755 index 00000000..74cd1fa5 --- /dev/null +++ b/sample_notebooks/Dileep KumarShakya/Dileep KumarShakya_version_backup/chapter1.ipynb @@ -0,0 +1 @@ +{"nbformat_minor": 0, "cells": [{"source": "#Chapter1 : Electromagnetic Field Radiation", "cell_type": "markdown", "metadata": {}}, {"source": "##Example 1.1, Page number 23", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable declaration\nE= 2 #electric field strength of wave in V/m\nn=120*math.pi #where n is mu [free space impedence (120xpi)]\n\n#calculations\nH=E/n # As n = E/H\nH=H*10**3\n\n#results\nprint \"strength of magnetic field H in free space is %r mA/metre\" % round(H,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "strength of magnetic field H in free space is 5.305 mA/metre\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.2, Page number 23", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nP= 625*10**3 #power of transmitting antenna in Watt\nr=30*10**3 #distance in meter\n\n#calculations\nErms=math.sqrt(90*P)/r\nErms=Erms*10**3\n\n#Results\nprint\"Field strength is %r mV/metre.\" %round(Erms,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Field strength is 250.0 mV/metre.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.3, Page number 24", "cell_type": "markdown", "metadata": {}}, {"execution_count": 15, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nf=10 #frequency in Mega Hertz\nle=60 #Height of antenna in metres\nlemda=300/f\n\n#calculations\nRr= 160*(math.pi)**2*le**2/lemda**2\nRr=Rr/10**3\n\n#Results\nprint \"Radiation resistance of antenna is %r Kilo ohms.\" %round(Rr,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiation resistance of antenna is 6.317 Kilo ohms.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.4, Page number 24", "cell_type": "markdown", "metadata": {}}, {"execution_count": 16, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nle=100 # height of antenna in Metres\nIrms=450 # current at the base in Amperes\nf= 40000.0 # frequency in Hertz\nf=f/10**6 # frequency in Mega Hertz\n\nlemda= 300/f # as per the formula where frequncy in MHz\n\n#calculations\nRr=160*(math.pi)**2*le**2/lemda**2 #Rr is radiated resistance in ohms\n\n#Results\nprint \"Radiation resistance is %r ohms.\"%round(Rr,2)\n\n#calculations\nPr= Irms**2*Rr # Power radiated in Watts\nPr= Pr/10**3 # Power radiated in Kilo Watts\n\n#Results\nprint \"Power radiated is %r kW.\"%round(Pr,2)\n\n#variable Declaration\nRl=1.12 # otal reistance of antenna circuit in ohms\nn= Rr/Rl # Efficiancy of the antenna n= Radiation Resistance/Total antenna Resistance\n\n#calculations\nnper= n*100 # Efficiancy of the antenna (in percentage)\n\n#Results\nprint \"Efficiancy of antenna is %r percent. \"%round(nper,2)\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiation resistance is 0.28 ohms.\nPower radiated is 56.85 kW.\nEfficiancy of antenna is 25.07 percent. \n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.5, Page number 25", "cell_type": "markdown", "metadata": {}}, {"execution_count": 17, "cell_type": "code", "source": "\n#variable Declaration\nI=20 # current in Amperers\nRrad= 50 # Radiated resistance in Ohms\n\n#calculations\nPr= I**2*Rrad # Power radiated in watts\n\n#Results\nprint \"Antenna will radiate %r Watts of power.\"%Pr\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Antenna will radiate 20000 Watts of power.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.6, Page number 25", "cell_type": "markdown", "metadata": {}}, {"execution_count": 18, "cell_type": "code", "source": "\n#variable Declaration\nP=5*10**3 # Power radiated in watts\nI= 15.0 # current in Ampers\n#calculations\nRrad=P/I**2 # Radiated resistance in Ohms\n\n#Results\nprint \"Radiated power is %r ohms.\"%round(Rrad,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiated power is 22.22 ohms.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.7, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 19, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nRrad= 75 # Radiation resistance in ohms\nPr= 10 # Power radiated in kW\nPr=Pr*10**3 # Power radiated in W\n\n#calculations\nI=math.sqrt(Pr/Rrad)\n\n#Results\nprint \"%r Amperes current flows in the antenna\"%round(I,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "11.55 Amperes current flows in the antenna\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.8, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 20, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nP=W= 100*10**3 # power radiated in watt\nr= 100 # distance in kilo metres\nr=r*10**3 # distance in metres\n\n#calculations\nErms= math.sqrt(90*W)/r\n\n#Results\nprint \"Strength of electric field Erms is %r V/m.\"%Erms\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Strength of electric field Erms is 0.03 V/m.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.9, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 21, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nIrms= 25 # transmitting antenna rms current in A\nf=0.150 # frequency in Mega Hertz(MHz)\nErms= 1.5 # Field strength in mV/m\nErms=Erms/10**3 # Field strength in V/m\nr=25 # distance in kilo metre\nr=r*10**3 # distance in metre\n\n#calculations\nlemda= 300/f\nle= Erms*lemda*r/(60*math.pi*Irms) # le is effective height of the antenna in metres\n\n#Results\nprint \"Effective heigth of the antenna le = %r metres.\"%round(le,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Effective heigth of the antenna le = 15.92 metres.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.10, Page number 27", "cell_type": "markdown", "metadata": {}}, {"execution_count": 22, "cell_type": "code", "source": "from __future__ import division\nimport math\n\nle= 100 # Heigth of the antenna in metre\nIrms= 100 # rms current in amperes\nr=10 # distance in kilo metre\nr=r*10**3 # distance in metre\nf=300.0 # frequency in KHz\nf=f/10**3 # frequency in MHz\n\nlemda=300/f\n\n#Calculations\nErms= (120*math.pi*Irms*le)/(lemda*r)\n\nRr= (160*(math.pi)**2*le**2)/(lemda**2)\n\nP= Irms**2*Rr # Power radiated in watts\nP= P/10**3 # POwer radiated in kilo watts(kW)\n\n#Results\nprint \"(i)Field strength at Erms is %r mV/m\"%round(Erms*10**3,2)\nprint \"(ii)The power radiated is %r kW.\" %round(P,2)\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "(i)Field strength at Erms is 376.99 mV/m\n(ii)The power radiated is 157.91 kW.\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/Dileep KumarShakya/chapter1.ipynb b/sample_notebooks/Dileep KumarShakya/chapter1.ipynb deleted file mode 100755 index 74cd1fa5..00000000 --- a/sample_notebooks/Dileep KumarShakya/chapter1.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"nbformat_minor": 0, "cells": [{"source": "#Chapter1 : Electromagnetic Field Radiation", "cell_type": "markdown", "metadata": {}}, {"source": "##Example 1.1, Page number 23", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable declaration\nE= 2 #electric field strength of wave in V/m\nn=120*math.pi #where n is mu [free space impedence (120xpi)]\n\n#calculations\nH=E/n # As n = E/H\nH=H*10**3\n\n#results\nprint \"strength of magnetic field H in free space is %r mA/metre\" % round(H,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "strength of magnetic field H in free space is 5.305 mA/metre\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.2, Page number 23", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nP= 625*10**3 #power of transmitting antenna in Watt\nr=30*10**3 #distance in meter\n\n#calculations\nErms=math.sqrt(90*P)/r\nErms=Erms*10**3\n\n#Results\nprint\"Field strength is %r mV/metre.\" %round(Erms,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Field strength is 250.0 mV/metre.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.3, Page number 24", "cell_type": "markdown", "metadata": {}}, {"execution_count": 15, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nf=10 #frequency in Mega Hertz\nle=60 #Height of antenna in metres\nlemda=300/f\n\n#calculations\nRr= 160*(math.pi)**2*le**2/lemda**2\nRr=Rr/10**3\n\n#Results\nprint \"Radiation resistance of antenna is %r Kilo ohms.\" %round(Rr,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiation resistance of antenna is 6.317 Kilo ohms.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.4, Page number 24", "cell_type": "markdown", "metadata": {}}, {"execution_count": 16, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nle=100 # height of antenna in Metres\nIrms=450 # current at the base in Amperes\nf= 40000.0 # frequency in Hertz\nf=f/10**6 # frequency in Mega Hertz\n\nlemda= 300/f # as per the formula where frequncy in MHz\n\n#calculations\nRr=160*(math.pi)**2*le**2/lemda**2 #Rr is radiated resistance in ohms\n\n#Results\nprint \"Radiation resistance is %r ohms.\"%round(Rr,2)\n\n#calculations\nPr= Irms**2*Rr # Power radiated in Watts\nPr= Pr/10**3 # Power radiated in Kilo Watts\n\n#Results\nprint \"Power radiated is %r kW.\"%round(Pr,2)\n\n#variable Declaration\nRl=1.12 # otal reistance of antenna circuit in ohms\nn= Rr/Rl # Efficiancy of the antenna n= Radiation Resistance/Total antenna Resistance\n\n#calculations\nnper= n*100 # Efficiancy of the antenna (in percentage)\n\n#Results\nprint \"Efficiancy of antenna is %r percent. \"%round(nper,2)\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiation resistance is 0.28 ohms.\nPower radiated is 56.85 kW.\nEfficiancy of antenna is 25.07 percent. \n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.5, Page number 25", "cell_type": "markdown", "metadata": {}}, {"execution_count": 17, "cell_type": "code", "source": "\n#variable Declaration\nI=20 # current in Amperers\nRrad= 50 # Radiated resistance in Ohms\n\n#calculations\nPr= I**2*Rrad # Power radiated in watts\n\n#Results\nprint \"Antenna will radiate %r Watts of power.\"%Pr\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Antenna will radiate 20000 Watts of power.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.6, Page number 25", "cell_type": "markdown", "metadata": {}}, {"execution_count": 18, "cell_type": "code", "source": "\n#variable Declaration\nP=5*10**3 # Power radiated in watts\nI= 15.0 # current in Ampers\n#calculations\nRrad=P/I**2 # Radiated resistance in Ohms\n\n#Results\nprint \"Radiated power is %r ohms.\"%round(Rrad,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Radiated power is 22.22 ohms.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.7, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 19, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nRrad= 75 # Radiation resistance in ohms\nPr= 10 # Power radiated in kW\nPr=Pr*10**3 # Power radiated in W\n\n#calculations\nI=math.sqrt(Pr/Rrad)\n\n#Results\nprint \"%r Amperes current flows in the antenna\"%round(I,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "11.55 Amperes current flows in the antenna\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.8, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 20, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nP=W= 100*10**3 # power radiated in watt\nr= 100 # distance in kilo metres\nr=r*10**3 # distance in metres\n\n#calculations\nErms= math.sqrt(90*W)/r\n\n#Results\nprint \"Strength of electric field Erms is %r V/m.\"%Erms\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Strength of electric field Erms is 0.03 V/m.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.9, Page number 26", "cell_type": "markdown", "metadata": {}}, {"execution_count": 21, "cell_type": "code", "source": "from __future__ import division\nimport math\n\n#variable Declaration\nIrms= 25 # transmitting antenna rms current in A\nf=0.150 # frequency in Mega Hertz(MHz)\nErms= 1.5 # Field strength in mV/m\nErms=Erms/10**3 # Field strength in V/m\nr=25 # distance in kilo metre\nr=r*10**3 # distance in metre\n\n#calculations\nlemda= 300/f\nle= Erms*lemda*r/(60*math.pi*Irms) # le is effective height of the antenna in metres\n\n#Results\nprint \"Effective heigth of the antenna le = %r metres.\"%round(le,2)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Effective heigth of the antenna le = 15.92 metres.\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 1.10, Page number 27", "cell_type": "markdown", "metadata": {}}, {"execution_count": 22, "cell_type": "code", "source": "from __future__ import division\nimport math\n\nle= 100 # Heigth of the antenna in metre\nIrms= 100 # rms current in amperes\nr=10 # distance in kilo metre\nr=r*10**3 # distance in metre\nf=300.0 # frequency in KHz\nf=f/10**3 # frequency in MHz\n\nlemda=300/f\n\n#Calculations\nErms= (120*math.pi*Irms*le)/(lemda*r)\n\nRr= (160*(math.pi)**2*le**2)/(lemda**2)\n\nP= Irms**2*Rr # Power radiated in watts\nP= P/10**3 # POwer radiated in kilo watts(kW)\n\n#Results\nprint \"(i)Field strength at Erms is %r mV/m\"%round(Erms*10**3,2)\nprint \"(ii)The power radiated is %r kW.\" %round(P,2)\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "(i)Field strength at Erms is 376.99 mV/m\n(ii)The power radiated is 157.91 kW.\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/DivyangGandhi/DivyangGandhi_version_backup/ch2.ipynb b/sample_notebooks/DivyangGandhi/DivyangGandhi_version_backup/ch2.ipynb new file mode 100755 index 00000000..a473f6ff --- /dev/null +++ b/sample_notebooks/DivyangGandhi/DivyangGandhi_version_backup/ch2.ipynb @@ -0,0 +1,80 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:47d75f27ec6c94d8690b19c8285770e7f28c9cd54fabd419e1b2d7d6e6d4afe5" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : Transmission Lion Structures and Equipment" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 Page No : 77" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "# GIVEN DATA\n", + "t_s = 0.49 ; # Human body is in contact with 60 Hz power for 0.49 sec\n", + "r = 100 ; # Resistivity of soil based on IEEE std 80-2000 \n", + "\n", + "# CALCULATIONS\n", + "# For case (a)\n", + "v_touch50 = 0.116*(1000+1.5*r)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 50 kg body weight in volts\n", + "\n", + "# For case (b)\n", + "v_step50 = 0.116*(1000+6*r)/math.sqrt(t_s) ; # Maximum allowable step voltage for 50 kg body weight in volts\n", + "# Above Equations of case (a) & (b) applicable if no protective surface layer is used\n", + "\n", + "# For metal to metal contact below equation holds good . Hence resistivity is zero\n", + "r_1 = 0 ; # Resistivity is zero\n", + "\n", + "# For case (c)\n", + "v_mm_touch50 = 0.116*(1000)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 50 kg body weight in volts for metal to metal contact\n", + "\n", + "# For case (d)\n", + "v_mm_touch70 = 0.157*(1000)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 70 kg body weight in volts for metal to metal contact\n", + "\n", + "# DISPLAY RESULTS\n", + "print \" a) Tolerable Touch potential , V_touch50 = %.f V , for 50 kg body weight \"%(v_touch50) ;\n", + "print \" b) Tolerable Step potential , V_step50 = %.f V , for 50 kg body weight \"%(v_step50) ;\n", + "print \" c) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch50 = %.1f V , for 50 kg body weight \"%(v_mm_touch50) ;\n", + "print \" d) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch70 = %.1f V , for 70 kg body weight \"%(v_mm_touch70) ;\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " a) Tolerable Touch potential , V_touch50 = 191 V , for 50 kg body weight \n", + " b) Tolerable Step potential , V_step50 = 265 V , for 50 kg body weight \n", + " c) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch50 = 165.7 V , for 50 kg body weight \n", + " d) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch70 = 224.3 V , for 70 kg body weight \n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/DivyangGandhi/ch2.ipynb b/sample_notebooks/DivyangGandhi/ch2.ipynb deleted file mode 100755 index a473f6ff..00000000 --- a/sample_notebooks/DivyangGandhi/ch2.ipynb +++ /dev/null @@ -1,80 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:47d75f27ec6c94d8690b19c8285770e7f28c9cd54fabd419e1b2d7d6e6d4afe5" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 : Transmission Lion Structures and Equipment" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 Page No : 77" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "# GIVEN DATA\n", - "t_s = 0.49 ; # Human body is in contact with 60 Hz power for 0.49 sec\n", - "r = 100 ; # Resistivity of soil based on IEEE std 80-2000 \n", - "\n", - "# CALCULATIONS\n", - "# For case (a)\n", - "v_touch50 = 0.116*(1000+1.5*r)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 50 kg body weight in volts\n", - "\n", - "# For case (b)\n", - "v_step50 = 0.116*(1000+6*r)/math.sqrt(t_s) ; # Maximum allowable step voltage for 50 kg body weight in volts\n", - "# Above Equations of case (a) & (b) applicable if no protective surface layer is used\n", - "\n", - "# For metal to metal contact below equation holds good . Hence resistivity is zero\n", - "r_1 = 0 ; # Resistivity is zero\n", - "\n", - "# For case (c)\n", - "v_mm_touch50 = 0.116*(1000)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 50 kg body weight in volts for metal to metal contact\n", - "\n", - "# For case (d)\n", - "v_mm_touch70 = 0.157*(1000)/math.sqrt(t_s) ; # Maximum allowable touch voltage for 70 kg body weight in volts for metal to metal contact\n", - "\n", - "# DISPLAY RESULTS\n", - "print \" a) Tolerable Touch potential , V_touch50 = %.f V , for 50 kg body weight \"%(v_touch50) ;\n", - "print \" b) Tolerable Step potential , V_step50 = %.f V , for 50 kg body weight \"%(v_step50) ;\n", - "print \" c) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch50 = %.1f V , for 50 kg body weight \"%(v_mm_touch50) ;\n", - "print \" d) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch70 = %.1f V , for 70 kg body weight \"%(v_mm_touch70) ;\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " a) Tolerable Touch potential , V_touch50 = 191 V , for 50 kg body weight \n", - " b) Tolerable Step potential , V_step50 = 265 V , for 50 kg body weight \n", - " c) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch50 = 165.7 V , for 50 kg body weight \n", - " d) Tolerable Touch Voltage for metal-to-metal contact , V_mm_touch70 = 224.3 V , for 70 kg body weight \n" - ] - } - ], - "prompt_number": 1 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices.ipynb b/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices.ipynb new file mode 100755 index 00000000..ade5b7fd --- /dev/null +++ b/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices.ipynb @@ -0,0 +1,223 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3 Semoconductor Devices Fundamentals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.2 page no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "resistivity of the si doped with n−dopant is : \n", + "0.089 ohm−cm \n" + ] + } + ], + "source": [ + "def resistivity(u,n): #n:doped concentration =10**17 atoms/cubic cm, u: mobility of electrons =700square cm/v−sec .\n", + " q=1.6*10**-19 #q: charge\n", + " Res=1/(q*u*n)# since P is neglegible . \n", + " print \"resistivity of the si doped with n−dopant is : \"\n", + " print \"%0.3f ohm−cm \"%Res \n", + "resistivity(10**17,700)\n", + "# after executing calling resitivity ( u=700 and n =10ˆ17)i .e. , resistivity (10ˆ17 ,700) ;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.3 page no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "resistivity of intrinsic Ge is : \n", + "2595245510.225 ohm−cm \n" + ] + } + ], + "source": [ + "def resistivity(un,np): # un: electron concentration , up: hole concentration\n", + " q=1.6*10**-19 #in coulumb \n", + " ni=2.5*10*13 # concentration in cmˆ−3 \n", + " Res=1/(q*ni*un*np) # since n=p=ni \n", + " print \"resistivity of intrinsic Ge is : \"\n", + " print \"%0.3f ohm−cm \"%Res \n", + "resistivity(3900,1900)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.4 page no:37" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hole concentrartion at 300K is : \n", + "2250.000000 per cubic cm \n" + ] + } + ], + "source": [ + "def holeconcentration(ni,Nd): # Nd: donar concentration ; since , Nd>>ni , so Nd=n=10ˆ17 atoms/cmˆ3.\n", + " p=ni**2/Nd\n", + " print \"hole concentrartion at 300K is : \"\n", + " print \"%f per cubic cm \"%p\n", + "holeconcentration(1.5*10**10,10**17);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.5 page no:39" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "resistivity of the copper is : \n", + "2.29779411765e-08 ohm−meter\n" + ] + } + ], + "source": [ + "q=1.6*10**-19;\n", + "n=8.5*10**28;\n", + "u=3.2*10**-3;\n", + "p=1/(n*q*u);\n", + "print \"resistivity of the copper is : \"\n", + "print p,\" ohm−meter\"\n", + "# 2.298D−08 means 2.298∗10ˆ −8" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.6 page no:41" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Cu is: 0.0570814666846 pF\n", + "Ccs is: 0.282102806737 pF\n", + "gm is : 7.7519379845 mA/V\n", + "C1 is: 3.32558139535 pF\n", + "R1 is: 25.8 kilo ohm\n", + "R0 is 645.0 kilo Ohm \n", + "Ru is: 1290.0 Mega Ohm \n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "\n", + "Cuo=0.25; # collector −base depletion region capacitance in pico Farad(pF) for zero bias\n", + "Ccso=1.5 ; # collector −substrate junction capacitance in pico Farad(pF) for zero bias\n", + "q=1.6*10**-19 ; # electron charge in coulomb\n", + "Ic=0.2 ; #collector current in ampere(A)\n", + "k=8.6*10**-5; #in eV/K, where 1eV=1.6∗10ˆ−19\n", + "T=300; # absolute temperature in kelvin (K)\n", + "Vcb=10 ; #forward bias on the junction in volt(v)\n", + "Vcs=15 ; # collector −substrate bias in volt (V)\n", + "Cje=1 ; #depletion region capacitance in pico Farad(pF)\n", + "Bo=200; #small signal current gain\n", + "Tf=0.3; #transit time in forward direction in nano seconds (nS)\n", + "n=2*10**-4; # proportionality constant for Ro and gm\n", + "Vo=0.55; # bias voltage in volt (V)\n", + "Cu=Cuo/sqrt(1+(Vcb/Vo));# collector −base capacitance\n", + "print \"Cu is: \",Cu,\" pF\"\n", + "Ccs=Ccso/sqrt(1+(Vcs/Vo)); # capacitance collector −substrate\n", + "print \"Ccs is: \",Ccs,\"pF\"\n", + "gm=q*Ic/(k*T*1.6*10**-19);# since k is in eV so converting it in Coulomb/Kelvin\n", + "print \"gm is :\",gm,\"mA/V\"# transconductance of the bipolar transistor here\n", + "Cb=Tf*gm;# diffusion capacitance in pico Farad(pF)\n", + "C1=Cb+Cje;#small signal capacitance of bipolar transistor\n", + "print \"C1 is: \",C1,\"pF\"\n", + "R1=Bo/gm;# small signal input resistance of bipolar transistor\n", + "print \"R1 is: \",R1,\" kilo ohm\"\n", + "Ro=1/(n*gm);#small signal output resistance\n", + "print \"R0 is \",Ro,\" kilo Ohm \"\n", + "Ru=10*Bo*Ro/10**3;# collector −base resistance\n", + "print \"Ru is: \",Ru,\"Mega Ohm \"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices_Fundamentals.ipynb b/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices_Fundamentals.ipynb deleted file mode 100755 index ade5b7fd..00000000 --- a/sample_notebooks/DurgasriInnamuri/Chapter_3_Semoconductor_Devices_Fundamentals.ipynb +++ /dev/null @@ -1,223 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 3 Semoconductor Devices Fundamentals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.2 page no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "resistivity of the si doped with n−dopant is : \n", - "0.089 ohm−cm \n" - ] - } - ], - "source": [ - "def resistivity(u,n): #n:doped concentration =10**17 atoms/cubic cm, u: mobility of electrons =700square cm/v−sec .\n", - " q=1.6*10**-19 #q: charge\n", - " Res=1/(q*u*n)# since P is neglegible . \n", - " print \"resistivity of the si doped with n−dopant is : \"\n", - " print \"%0.3f ohm−cm \"%Res \n", - "resistivity(10**17,700)\n", - "# after executing calling resitivity ( u=700 and n =10ˆ17)i .e. , resistivity (10ˆ17 ,700) ;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.3 page no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "resistivity of intrinsic Ge is : \n", - "2595245510.225 ohm−cm \n" - ] - } - ], - "source": [ - "def resistivity(un,np): # un: electron concentration , up: hole concentration\n", - " q=1.6*10**-19 #in coulumb \n", - " ni=2.5*10*13 # concentration in cmˆ−3 \n", - " Res=1/(q*ni*un*np) # since n=p=ni \n", - " print \"resistivity of intrinsic Ge is : \"\n", - " print \"%0.3f ohm−cm \"%Res \n", - "resistivity(3900,1900)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.4 page no:37" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hole concentrartion at 300K is : \n", - "2250.000000 per cubic cm \n" - ] - } - ], - "source": [ - "def holeconcentration(ni,Nd): # Nd: donar concentration ; since , Nd>>ni , so Nd=n=10ˆ17 atoms/cmˆ3.\n", - " p=ni**2/Nd\n", - " print \"hole concentrartion at 300K is : \"\n", - " print \"%f per cubic cm \"%p\n", - "holeconcentration(1.5*10**10,10**17);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.5 page no:39" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "resistivity of the copper is : \n", - "2.29779411765e-08 ohm−meter\n" - ] - } - ], - "source": [ - "q=1.6*10**-19;\n", - "n=8.5*10**28;\n", - "u=3.2*10**-3;\n", - "p=1/(n*q*u);\n", - "print \"resistivity of the copper is : \"\n", - "print p,\" ohm−meter\"\n", - "# 2.298D−08 means 2.298∗10ˆ −8" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.6 page no:41" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cu is: 0.0570814666846 pF\n", - "Ccs is: 0.282102806737 pF\n", - "gm is : 7.7519379845 mA/V\n", - "C1 is: 3.32558139535 pF\n", - "R1 is: 25.8 kilo ohm\n", - "R0 is 645.0 kilo Ohm \n", - "Ru is: 1290.0 Mega Ohm \n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "\n", - "Cuo=0.25; # collector −base depletion region capacitance in pico Farad(pF) for zero bias\n", - "Ccso=1.5 ; # collector −substrate junction capacitance in pico Farad(pF) for zero bias\n", - "q=1.6*10**-19 ; # electron charge in coulomb\n", - "Ic=0.2 ; #collector current in ampere(A)\n", - "k=8.6*10**-5; #in eV/K, where 1eV=1.6∗10ˆ−19\n", - "T=300; # absolute temperature in kelvin (K)\n", - "Vcb=10 ; #forward bias on the junction in volt(v)\n", - "Vcs=15 ; # collector −substrate bias in volt (V)\n", - "Cje=1 ; #depletion region capacitance in pico Farad(pF)\n", - "Bo=200; #small signal current gain\n", - "Tf=0.3; #transit time in forward direction in nano seconds (nS)\n", - "n=2*10**-4; # proportionality constant for Ro and gm\n", - "Vo=0.55; # bias voltage in volt (V)\n", - "Cu=Cuo/sqrt(1+(Vcb/Vo));# collector −base capacitance\n", - "print \"Cu is: \",Cu,\" pF\"\n", - "Ccs=Ccso/sqrt(1+(Vcs/Vo)); # capacitance collector −substrate\n", - "print \"Ccs is: \",Ccs,\"pF\"\n", - "gm=q*Ic/(k*T*1.6*10**-19);# since k is in eV so converting it in Coulomb/Kelvin\n", - "print \"gm is :\",gm,\"mA/V\"# transconductance of the bipolar transistor here\n", - "Cb=Tf*gm;# diffusion capacitance in pico Farad(pF)\n", - "C1=Cb+Cje;#small signal capacitance of bipolar transistor\n", - "print \"C1 is: \",C1,\"pF\"\n", - "R1=Bo/gm;# small signal input resistance of bipolar transistor\n", - "print \"R1 is: \",R1,\" kilo ohm\"\n", - "Ro=1/(n*gm);#small signal output resistance\n", - "print \"R0 is \",Ro,\" kilo Ohm \"\n", - "Ru=10*Bo*Ro/10**3;# collector −base resistance\n", - "print \"Ru is: \",Ru,\"Mega Ohm \"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Ershad AhamedChemmalasseri/Ershad AhamedChemmalasseri_version_backup/chapter1.ipynb b/sample_notebooks/Ershad AhamedChemmalasseri/Ershad AhamedChemmalasseri_version_backup/chapter1.ipynb new file mode 100755 index 00000000..251df967 --- /dev/null +++ b/sample_notebooks/Ershad AhamedChemmalasseri/Ershad AhamedChemmalasseri_version_backup/chapter1.ipynb @@ -0,0 +1,556 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:65f02fae284344ccd8037c2004c0386b9cc4ee681cfc1240a77e3be2fe2aff5e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Introductory Concepts" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1, Page number 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Express absolute viscosity of fluids in SI units and calculate the kinematic viscosity\n", + "\n", + "# Import required modules\n", + "\n", + "import numpy as np\n", + "from prettytable import PrettyTable\n", + "\n", + "# Given\n", + "\n", + "mu = np.array([1,0.018,100]) # Absolute viscosities in centipoise\n", + "mu_poise = np.array([1,0.018,100])/100 # Absolute viscosities in poise\n", + "rho = np.array([1.0,0.0012,0.930]) # Densities in gm/cm^3\n", + "mu_SI = mu/1000 # Absolute viscosities in SI units\n", + "rho_SI = rho*1000 # Densities in SI units\n", + "nu = mu_poise/rho # Kinematic viscosities in Stokes\n", + "nu_SI = mu_SI/rho_SI # Kinematic viscosities in SI units\n", + "\n", + "# Tabulate results\n", + "\n", + "table = PrettyTable([\"Property\", \"Water\", \"Air\", \"Lube Oil\"])\n", + "table.add_row(['Absolute Viscosity mu',' ',' ',' '])\n", + "table.add_row([\"centipoise cP\",mu[0],mu[1],mu[2]])\n", + "table.add_row([\"SI units (Ns/m^2)\",mu_SI[0],mu_SI[1],mu_SI[2]])\n", + "table.add_row([' ',' ',' ',' '])\n", + "table.add_row(['Mass Density rho',' ',' ',' '])\n", + "table.add_row([\"g/cm^3\",rho[0],rho[1],rho[2]])\n", + "table.add_row([\"SI units (kg/m^3)\",rho_SI[0],rho_SI[1],rho_SI[2]])\n", + "table.add_row([' ',' ',' ',' '])\n", + "table.add_row(['Kinematic Viscosity nu',' ',' ',' '])\n", + "table.add_row([\"St\",nu[0],nu[1],round(nu[2],2)])\n", + "table.add_row([\"SI units (m^2/s)\",nu_SI[0],nu_SI[1],\"{:.2e}\".format(nu_SI[2])])\n", + "print table" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "+------------------------+--------+---------+----------+\n", + "| Property | Water | Air | Lube Oil |\n", + "+------------------------+--------+---------+----------+\n", + "| Absolute Viscosity mu | | | |\n", + "| centipoise cP | 1.0 | 0.018 | 100.0 |\n", + "| SI units (Ns/m^2) | 0.001 | 1.8e-05 | 0.1 |\n", + "| | | | |\n", + "| Mass Density rho | | | |\n", + "| g/cm^3 | 1.0 | 0.0012 | 0.93 |\n", + "| SI units (kg/m^3) | 1000.0 | 1.2 | 930.0 |\n", + "| | | | |\n", + "| Kinematic Viscosity nu | | | |\n", + "| St | 0.01 | 0.15 | 1.08 |\n", + "| SI units (m^2/s) | 1e-06 | 1.5e-05 | 1.08e-04 |\n", + "+------------------------+--------+---------+----------+\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2, Page number 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Calculate the force and power required to maintain the velocity\n", + "\n", + "# Given\n", + "A = 0.1 # Area of the flat plate (m^2)\n", + "U = 0.3 # Velocity of the flat plate (m/s)\n", + "mu = 0.001 # viscosity of the fluid separating the plates (m)\n", + "du = U - 0 # relative velocity between the plates\n", + "dy = 0.0001 # relative distance between the plates\n", + "\n", + "tau = mu*du/dy # Shear stress (N/m^2)\n", + "F = tau * A # Shear force (N)\n", + "Power = F * U # Power required (W)\n", + "print(\"The force required to maintain the velocity is %.2f N.\" %F)\n", + "print(\"The power required is %.2f W.\" %Power)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The force required to maintain the velocity is 0.30 N.\n", + "The power required is 0.09 W.\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3, Page number 24" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine the torque and power\n", + "\n", + "# Import required modules\n", + "\n", + "import math \n", + "import sympy\n", + "\n", + "# Given\n", + "l = 0.10 # length of the shaft (m)\n", + "d = 0.05 # diameter of the shaft (m)\n", + "D = 0.051 # diameter of the concentric bearing (m)\n", + "N = 500 # Rotational speed of the shaft (rpm)\n", + "mu = 0.1 # Viscosity of the lubricating oil (Ns/m^2)\n", + "theta = sympy.Symbol('theta')\n", + "\n", + "u = round(math.pi*d*N/60,2) # Peripheral speed of the shaft (m/s)\n", + "du = u - 0 \n", + "dy = (D-d)/2\n", + "tau = round(mu*du/dy,0) # Shear stress (N/m^2)\n", + "T = sympy.integrate(tau*d/2*d/2*l,(theta,0,2*math.pi)) # Torque required to turn the shaft (Nm)\n", + "omega = u/(d/2) # Angular speed of the shaft\n", + "Power = round(T,3)*omega # Power required to turn the shaft (W)\n", + "\n", + "print(\"The power required to turn the shaft is %1.3f W.\" %Power)\n", + "# Wrong rounding-off of Torque T in textbook. Hence, the difference in value of power. Textbook answer Power = 5.387 W" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The power required to turn the shaft is 5.397 W.\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4, Page number 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# The power dissipated in the bearing\n", + "\n", + "# Import required modules\n", + "import sympy\n", + "\n", + "# Given\n", + "R = 0.1/2 # Radius of the bearing (m)\n", + "mu = 0.08 # Viscosity of oil film (Ns/m^2)\n", + "dy = 0.0015 # separation distance (m)\n", + "N = 100 # Rotational speed of the bearing (rpm)\n", + "r = sympy.Symbol('r')\n", + "theta = sympy.Symbol('theta')\n", + "\n", + "omega = round(2*math.pi*100/60,2) # Angular velocity of the bearing (rad/s)\n", + "u = r*omega # Linear velocity of the bearing (m/s)\n", + "du = u - 0 # Relative velocity \n", + "tau = mu * du/dy # Shear stress (N/m^2)\n", + "T = sympy.integrate(tau*r*r,(theta,0,2*math.pi),(r,0,R)) # Total torque on the shaft (Nm)\n", + "Power = round(T,5)*omega # Power dissipated (W)\n", + "print(\"The power dissipated by the bearing is %.4f W.\" %Power)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The power dissipated by the bearing is 0.0574 W.\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5, Page number 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine shear stress for r/R ratios and calculate drag force per meter length of the pipe\n", + "\n", + "# Import required modules\n", + "import sympy\n", + "import math\n", + "from tabulate import tabulate\n", + "\n", + "# Given\n", + "r = sympy.Symbol('r') # Radial distance for the point\n", + "R = sympy.Symbol('R') # Radial distance for the wall\n", + "U = 10 # Centreline velocity (m/s)\n", + "mu = 0.002 # Viscosity (Ns/m^2)\n", + "r_R = [0.0,0.2,0.5,0.8,1.0] # r/R ratios\n", + "u = U*(1-(r/R)**2) # Expression for velocity in a pipe-flow\n", + "y = R-r # Distance from the wall\n", + "\n", + "du = sympy.diff(u,r) # Derivative of 'u' expression\n", + "dy = sympy.diff(y,r) \n", + "tau = mu*du/dy # Newton's law of viscosity (N/m^2)\n", + "F = 2*math.pi*R*tau # Drag force (N)\n", + "\n", + "# Substitution of r/R ratios\n", + "table = []\n", + "for i, r_R in enumerate(r_R): \n", + " table.append([r_R,round(tau.subs([(R,1.0/2.0),(r,r_R*1.0/2.0)]),4),\n", + " round(F.subs([(R,1.0/2.0),(r,r_R*1.0/2.0)]),4)])\n", + "print tabulate(table, headers=['r/R', 'Shear stress, tau (N/m^2)', 'Drag force, F (N)'],tablefmt='grid',numalign=\"center\")\n", + "# The Drag force printed in the textbook for the r/R = 0.8 is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "+-------+-----------------------------+---------------------+\n", + "| r/R | Shear stress, tau (N/m^2) | Drag force, F (N) |\n", + "+=======+=============================+=====================+\n", + "| 0 | 0 | 0 |\n", + "+-------+-----------------------------+---------------------+\n", + "| 0.2 | 0.016 | 0.0503 |\n", + "+-------+-----------------------------+---------------------+\n", + "| 0.5 | 0.04 | 0.1257 |\n", + "+-------+-----------------------------+---------------------+\n", + "| 0.8 | 0.064 | 0.2011 |\n", + "+-------+-----------------------------+---------------------+\n", + "| 1 | 0.08 | 0.2513 |\n", + "+-------+-----------------------------+---------------------+\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6, Page number 27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine average thickness of the film\n", + "\n", + "# Import required modules\n", + "import sympy\n", + "\n", + "# Given\n", + "n = 800 # Normal reaction by the ice on the skater (N)\n", + "f = 0.02 # Coefficient of friction between the skates and the ice \n", + "u = 54*1000/3600 # Speed of the skater (m/s)\n", + "A = 10e-4 # Skating area (m^2)\n", + "mu = 0.001 # Viscosity of water (Ns/m^2)\n", + "h = sympy.Symbol('h') # average thickness of the film\n", + "\n", + "F = f*n # Frictional reaction (N)\n", + "du_dy = (u-0)/h # Velocity gradient\n", + "tau = mu*du_dy # Shear stress (N/m^2)\n", + "print('The average thickness of the film is %.3e m.'\n", + " %sympy.solve(sympy.Eq(tau*A,F),h)[0]) # Solve for h by equating drag force to frictional reaction" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The average thickness of the film is 9.375e-07 m.\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, Page number 30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Determine necessary increase of pressure\n", + "\n", + "# Given\n", + "K = 2.07e6 # Bulk modulus of water (kN/m^2)\n", + "gamma = 1.4 # Specific heat ratio\n", + "p = 101.324 # Atmospheric pressure (kN/m^2)\n", + "vol_red = 0.01 # Volume reduction \n", + "\n", + "# (a) At same temperature\n", + "dp = vol_red * K # increase in pressure (kN/m^2)\n", + "print('The increase in pressure required for water is %d kN/m^2.' %dp)\n", + "# (b) isentropic compression of air\n", + "K = gamma * p # Bulk modulus of air (kN/m^2)\n", + "dp = vol_red * K # increase in pressure (kN/m^2)\n", + "print('The increase in pressure required for air is %.2f kN/m^2.' %dp)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The increase in pressure required for water is 20700 kN/m^2.\n", + "The increase in pressure required for air is 1.42 kN/m^2.\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, Page number 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Height of capillary rise\n", + "\n", + "# Import required modules\n", + "import math\n", + "\n", + "# Given\n", + "sigma = 0.0736 # Surface tension between water and glass (N/m)\n", + "theta = 0 # Angle of contact\n", + "d = 2e-3 # Diameter of the glass tube (m)\n", + "g = 9.81 # Acceleration due to gravity (m/s^2)\n", + "rho = 1000 # Density of water (kg/m^3)\n", + "\n", + "h = 4*sigma*math.cos(theta)/(rho*g*d) # height of capillary rise (m)\n", + "print('The water in the glass tube rises through a height of %0.3f m'%h)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The water in the glass tube rises through a height of 0.015 m\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8, Page number 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Gauge pressure and absolute pressure within a droplet and a jet\n", + "\n", + "# Given\n", + "d_droplet = 0.004 # Diamter of the droplet (m)\n", + "d_jet = 0.004 # Diameter of the jet (m)\n", + "sigma = 0.073 # Viscosity of water (Ns/m^2)\n", + "P_atm = 101300 # Atmospheric pressure (N/m^2)\n", + "\n", + "# (a) For the droplet\n", + "P_gauge = 4*sigma/d_droplet # Gauge pressure for droplet (N/m^2)\n", + "P_abs = P_atm + P_gauge # Absolute pressure (N/m^2)\n", + "print('The gauge pressure and absolute pressure within a droplet is %d N/m^2 and %.3f kN/m^2 respectively.' %(P_gauge,P_abs/1000))\n", + "\n", + "# (a) For the jet\n", + "P_gauge = 2*sigma/d_jet # Gauge pressure for jet (N/m^2)\n", + "P_abs = P_atm + P_gauge # Absolute pressure (N/m^2)\n", + "print('The gauge pressure and absolute pressure within a jet is %.1f N/m^2 and %.2f kN/m^2 respectively.' %(P_gauge,P_abs/1000))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The gauge pressure and absolute pressure within a droplet is 73 N/m^2 and 101.373 kN/m^2 respectively.\n", + "The gauge pressure and absolute pressure within a jet is 36.5 N/m^2 and 101.34 kN/m^2 respectively.\n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9, Page number 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Difference in level of the miniscii\n", + "\n", + "# Import required modules\n", + "import sympy\n", + "\n", + "# Given\n", + "d_1 = 1.0e-3 # Diameter of capillary (m)\n", + "d_2 = 1.5e-3 # Diameter of another capillary (m)\n", + "sigma = 0.0075 # Surface tension of water (Ns/m^2)\n", + "g = 9.81 # Acceleration due to gravity (m/s^2)\n", + "rho = 1000 # Density of water (kg/m^3)\n", + "h = sympy.Symbol('h') # Difference in level of the miniscii (m)\n", + "\n", + "h = sympy.solve(sympy.Eq(math.pi*d_2*sigma-math.pi*d_1*sigma,math.pi*d_2**2*h*rho*g/4),h)[0]*1000 # Solve for h\n", + "print('The difference in level of the miniscii is %.2f mm' %h)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The difference in level of the miniscii is 0.68 mm\n" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.10, Page number 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Shear stress calculation and estimate the viscosity\n", + "\n", + "# Import required modules\n", + "import sympy\n", + "\n", + "# Given\n", + "U_max = 0.2 # Maximum velocity (m/s)\n", + "h = 0.01 # film thickness (m)\n", + "mu = 0.5 # Viscosity of the non-Newtonian fluid (Ns/m^2)\n", + "y = sympy.Symbol('y') \n", + "u = sympy.Symbol('u') \n", + "u = U_max * (2*(y/h)-(y/h)**3/3) # Expression for velocity\n", + "\n", + "# (a) Shear stress calculation\n", + "du_dy = sympy.diff(u,y) # Velocity gradient\n", + "tau = mu*(round(du_dy.subs(y,h)))**1.3 # Shear stress of the non-Newtonian fluid (N/m^2)\n", + "print('The shear stress at the solid surface is %.2f N/m^2.' %tau)\n", + "\n", + "# (b) Estimation of the viscosity of the Newtonian fluid\n", + "mu = sympy.Symbol('mu')\n", + "mu = sympy.solve(sympy.Eq(round(tau,2),mu*round(du_dy.subs(y,h))))[0] # Solve for mu for the same shear stress using Newton's law of viscosity\n", + "print('The viscosity of a Newtonian fluid to induce the same shear stress is %.2f Ns/m^2.' %mu)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The shear stress at the solid surface is 24.56 N/m^2.\n", + "The viscosity of a Newtonian fluid to induce the same shear stress is 1.23 Ns/m^2.\n" + ] + } + ], + "prompt_number": 69 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Ershad AhamedChemmalasseri/chapter1.ipynb b/sample_notebooks/Ershad AhamedChemmalasseri/chapter1.ipynb deleted file mode 100755 index 251df967..00000000 --- a/sample_notebooks/Ershad AhamedChemmalasseri/chapter1.ipynb +++ /dev/null @@ -1,556 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:65f02fae284344ccd8037c2004c0386b9cc4ee681cfc1240a77e3be2fe2aff5e" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Introductory Concepts" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1, Page number 23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Express absolute viscosity of fluids in SI units and calculate the kinematic viscosity\n", - "\n", - "# Import required modules\n", - "\n", - "import numpy as np\n", - "from prettytable import PrettyTable\n", - "\n", - "# Given\n", - "\n", - "mu = np.array([1,0.018,100]) # Absolute viscosities in centipoise\n", - "mu_poise = np.array([1,0.018,100])/100 # Absolute viscosities in poise\n", - "rho = np.array([1.0,0.0012,0.930]) # Densities in gm/cm^3\n", - "mu_SI = mu/1000 # Absolute viscosities in SI units\n", - "rho_SI = rho*1000 # Densities in SI units\n", - "nu = mu_poise/rho # Kinematic viscosities in Stokes\n", - "nu_SI = mu_SI/rho_SI # Kinematic viscosities in SI units\n", - "\n", - "# Tabulate results\n", - "\n", - "table = PrettyTable([\"Property\", \"Water\", \"Air\", \"Lube Oil\"])\n", - "table.add_row(['Absolute Viscosity mu',' ',' ',' '])\n", - "table.add_row([\"centipoise cP\",mu[0],mu[1],mu[2]])\n", - "table.add_row([\"SI units (Ns/m^2)\",mu_SI[0],mu_SI[1],mu_SI[2]])\n", - "table.add_row([' ',' ',' ',' '])\n", - "table.add_row(['Mass Density rho',' ',' ',' '])\n", - "table.add_row([\"g/cm^3\",rho[0],rho[1],rho[2]])\n", - "table.add_row([\"SI units (kg/m^3)\",rho_SI[0],rho_SI[1],rho_SI[2]])\n", - "table.add_row([' ',' ',' ',' '])\n", - "table.add_row(['Kinematic Viscosity nu',' ',' ',' '])\n", - "table.add_row([\"St\",nu[0],nu[1],round(nu[2],2)])\n", - "table.add_row([\"SI units (m^2/s)\",nu_SI[0],nu_SI[1],\"{:.2e}\".format(nu_SI[2])])\n", - "print table" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "+------------------------+--------+---------+----------+\n", - "| Property | Water | Air | Lube Oil |\n", - "+------------------------+--------+---------+----------+\n", - "| Absolute Viscosity mu | | | |\n", - "| centipoise cP | 1.0 | 0.018 | 100.0 |\n", - "| SI units (Ns/m^2) | 0.001 | 1.8e-05 | 0.1 |\n", - "| | | | |\n", - "| Mass Density rho | | | |\n", - "| g/cm^3 | 1.0 | 0.0012 | 0.93 |\n", - "| SI units (kg/m^3) | 1000.0 | 1.2 | 930.0 |\n", - "| | | | |\n", - "| Kinematic Viscosity nu | | | |\n", - "| St | 0.01 | 0.15 | 1.08 |\n", - "| SI units (m^2/s) | 1e-06 | 1.5e-05 | 1.08e-04 |\n", - "+------------------------+--------+---------+----------+\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2, Page number 23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Calculate the force and power required to maintain the velocity\n", - "\n", - "# Given\n", - "A = 0.1 # Area of the flat plate (m^2)\n", - "U = 0.3 # Velocity of the flat plate (m/s)\n", - "mu = 0.001 # viscosity of the fluid separating the plates (m)\n", - "du = U - 0 # relative velocity between the plates\n", - "dy = 0.0001 # relative distance between the plates\n", - "\n", - "tau = mu*du/dy # Shear stress (N/m^2)\n", - "F = tau * A # Shear force (N)\n", - "Power = F * U # Power required (W)\n", - "print(\"The force required to maintain the velocity is %.2f N.\" %F)\n", - "print(\"The power required is %.2f W.\" %Power)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The force required to maintain the velocity is 0.30 N.\n", - "The power required is 0.09 W.\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3, Page number 24" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Determine the torque and power\n", - "\n", - "# Import required modules\n", - "\n", - "import math \n", - "import sympy\n", - "\n", - "# Given\n", - "l = 0.10 # length of the shaft (m)\n", - "d = 0.05 # diameter of the shaft (m)\n", - "D = 0.051 # diameter of the concentric bearing (m)\n", - "N = 500 # Rotational speed of the shaft (rpm)\n", - "mu = 0.1 # Viscosity of the lubricating oil (Ns/m^2)\n", - "theta = sympy.Symbol('theta')\n", - "\n", - "u = round(math.pi*d*N/60,2) # Peripheral speed of the shaft (m/s)\n", - "du = u - 0 \n", - "dy = (D-d)/2\n", - "tau = round(mu*du/dy,0) # Shear stress (N/m^2)\n", - "T = sympy.integrate(tau*d/2*d/2*l,(theta,0,2*math.pi)) # Torque required to turn the shaft (Nm)\n", - "omega = u/(d/2) # Angular speed of the shaft\n", - "Power = round(T,3)*omega # Power required to turn the shaft (W)\n", - "\n", - "print(\"The power required to turn the shaft is %1.3f W.\" %Power)\n", - "# Wrong rounding-off of Torque T in textbook. Hence, the difference in value of power. Textbook answer Power = 5.387 W" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The power required to turn the shaft is 5.397 W.\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4, Page number 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# The power dissipated in the bearing\n", - "\n", - "# Import required modules\n", - "import sympy\n", - "\n", - "# Given\n", - "R = 0.1/2 # Radius of the bearing (m)\n", - "mu = 0.08 # Viscosity of oil film (Ns/m^2)\n", - "dy = 0.0015 # separation distance (m)\n", - "N = 100 # Rotational speed of the bearing (rpm)\n", - "r = sympy.Symbol('r')\n", - "theta = sympy.Symbol('theta')\n", - "\n", - "omega = round(2*math.pi*100/60,2) # Angular velocity of the bearing (rad/s)\n", - "u = r*omega # Linear velocity of the bearing (m/s)\n", - "du = u - 0 # Relative velocity \n", - "tau = mu * du/dy # Shear stress (N/m^2)\n", - "T = sympy.integrate(tau*r*r,(theta,0,2*math.pi),(r,0,R)) # Total torque on the shaft (Nm)\n", - "Power = round(T,5)*omega # Power dissipated (W)\n", - "print(\"The power dissipated by the bearing is %.4f W.\" %Power)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The power dissipated by the bearing is 0.0574 W.\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5, Page number 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Determine shear stress for r/R ratios and calculate drag force per meter length of the pipe\n", - "\n", - "# Import required modules\n", - "import sympy\n", - "import math\n", - "from tabulate import tabulate\n", - "\n", - "# Given\n", - "r = sympy.Symbol('r') # Radial distance for the point\n", - "R = sympy.Symbol('R') # Radial distance for the wall\n", - "U = 10 # Centreline velocity (m/s)\n", - "mu = 0.002 # Viscosity (Ns/m^2)\n", - "r_R = [0.0,0.2,0.5,0.8,1.0] # r/R ratios\n", - "u = U*(1-(r/R)**2) # Expression for velocity in a pipe-flow\n", - "y = R-r # Distance from the wall\n", - "\n", - "du = sympy.diff(u,r) # Derivative of 'u' expression\n", - "dy = sympy.diff(y,r) \n", - "tau = mu*du/dy # Newton's law of viscosity (N/m^2)\n", - "F = 2*math.pi*R*tau # Drag force (N)\n", - "\n", - "# Substitution of r/R ratios\n", - "table = []\n", - "for i, r_R in enumerate(r_R): \n", - " table.append([r_R,round(tau.subs([(R,1.0/2.0),(r,r_R*1.0/2.0)]),4),\n", - " round(F.subs([(R,1.0/2.0),(r,r_R*1.0/2.0)]),4)])\n", - "print tabulate(table, headers=['r/R', 'Shear stress, tau (N/m^2)', 'Drag force, F (N)'],tablefmt='grid',numalign=\"center\")\n", - "# The Drag force printed in the textbook for the r/R = 0.8 is wrong" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "+-------+-----------------------------+---------------------+\n", - "| r/R | Shear stress, tau (N/m^2) | Drag force, F (N) |\n", - "+=======+=============================+=====================+\n", - "| 0 | 0 | 0 |\n", - "+-------+-----------------------------+---------------------+\n", - "| 0.2 | 0.016 | 0.0503 |\n", - "+-------+-----------------------------+---------------------+\n", - "| 0.5 | 0.04 | 0.1257 |\n", - "+-------+-----------------------------+---------------------+\n", - "| 0.8 | 0.064 | 0.2011 |\n", - "+-------+-----------------------------+---------------------+\n", - "| 1 | 0.08 | 0.2513 |\n", - "+-------+-----------------------------+---------------------+\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6, Page number 27" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Determine average thickness of the film\n", - "\n", - "# Import required modules\n", - "import sympy\n", - "\n", - "# Given\n", - "n = 800 # Normal reaction by the ice on the skater (N)\n", - "f = 0.02 # Coefficient of friction between the skates and the ice \n", - "u = 54*1000/3600 # Speed of the skater (m/s)\n", - "A = 10e-4 # Skating area (m^2)\n", - "mu = 0.001 # Viscosity of water (Ns/m^2)\n", - "h = sympy.Symbol('h') # average thickness of the film\n", - "\n", - "F = f*n # Frictional reaction (N)\n", - "du_dy = (u-0)/h # Velocity gradient\n", - "tau = mu*du_dy # Shear stress (N/m^2)\n", - "print('The average thickness of the film is %.3e m.'\n", - " %sympy.solve(sympy.Eq(tau*A,F),h)[0]) # Solve for h by equating drag force to frictional reaction" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The average thickness of the film is 9.375e-07 m.\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, Page number 30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Determine necessary increase of pressure\n", - "\n", - "# Given\n", - "K = 2.07e6 # Bulk modulus of water (kN/m^2)\n", - "gamma = 1.4 # Specific heat ratio\n", - "p = 101.324 # Atmospheric pressure (kN/m^2)\n", - "vol_red = 0.01 # Volume reduction \n", - "\n", - "# (a) At same temperature\n", - "dp = vol_red * K # increase in pressure (kN/m^2)\n", - "print('The increase in pressure required for water is %d kN/m^2.' %dp)\n", - "# (b) isentropic compression of air\n", - "K = gamma * p # Bulk modulus of air (kN/m^2)\n", - "dp = vol_red * K # increase in pressure (kN/m^2)\n", - "print('The increase in pressure required for air is %.2f kN/m^2.' %dp)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The increase in pressure required for water is 20700 kN/m^2.\n", - "The increase in pressure required for air is 1.42 kN/m^2.\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, Page number 34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Height of capillary rise\n", - "\n", - "# Import required modules\n", - "import math\n", - "\n", - "# Given\n", - "sigma = 0.0736 # Surface tension between water and glass (N/m)\n", - "theta = 0 # Angle of contact\n", - "d = 2e-3 # Diameter of the glass tube (m)\n", - "g = 9.81 # Acceleration due to gravity (m/s^2)\n", - "rho = 1000 # Density of water (kg/m^3)\n", - "\n", - "h = 4*sigma*math.cos(theta)/(rho*g*d) # height of capillary rise (m)\n", - "print('The water in the glass tube rises through a height of %0.3f m'%h)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The water in the glass tube rises through a height of 0.015 m\n" - ] - } - ], - "prompt_number": 28 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8, Page number 34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Gauge pressure and absolute pressure within a droplet and a jet\n", - "\n", - "# Given\n", - "d_droplet = 0.004 # Diamter of the droplet (m)\n", - "d_jet = 0.004 # Diameter of the jet (m)\n", - "sigma = 0.073 # Viscosity of water (Ns/m^2)\n", - "P_atm = 101300 # Atmospheric pressure (N/m^2)\n", - "\n", - "# (a) For the droplet\n", - "P_gauge = 4*sigma/d_droplet # Gauge pressure for droplet (N/m^2)\n", - "P_abs = P_atm + P_gauge # Absolute pressure (N/m^2)\n", - "print('The gauge pressure and absolute pressure within a droplet is %d N/m^2 and %.3f kN/m^2 respectively.' %(P_gauge,P_abs/1000))\n", - "\n", - "# (a) For the jet\n", - "P_gauge = 2*sigma/d_jet # Gauge pressure for jet (N/m^2)\n", - "P_abs = P_atm + P_gauge # Absolute pressure (N/m^2)\n", - "print('The gauge pressure and absolute pressure within a jet is %.1f N/m^2 and %.2f kN/m^2 respectively.' %(P_gauge,P_abs/1000))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The gauge pressure and absolute pressure within a droplet is 73 N/m^2 and 101.373 kN/m^2 respectively.\n", - "The gauge pressure and absolute pressure within a jet is 36.5 N/m^2 and 101.34 kN/m^2 respectively.\n" - ] - } - ], - "prompt_number": 38 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9, Page number 34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Difference in level of the miniscii\n", - "\n", - "# Import required modules\n", - "import sympy\n", - "\n", - "# Given\n", - "d_1 = 1.0e-3 # Diameter of capillary (m)\n", - "d_2 = 1.5e-3 # Diameter of another capillary (m)\n", - "sigma = 0.0075 # Surface tension of water (Ns/m^2)\n", - "g = 9.81 # Acceleration due to gravity (m/s^2)\n", - "rho = 1000 # Density of water (kg/m^3)\n", - "h = sympy.Symbol('h') # Difference in level of the miniscii (m)\n", - "\n", - "h = sympy.solve(sympy.Eq(math.pi*d_2*sigma-math.pi*d_1*sigma,math.pi*d_2**2*h*rho*g/4),h)[0]*1000 # Solve for h\n", - "print('The difference in level of the miniscii is %.2f mm' %h)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The difference in level of the miniscii is 0.68 mm\n" - ] - } - ], - "prompt_number": 51 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.10, Page number 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Shear stress calculation and estimate the viscosity\n", - "\n", - "# Import required modules\n", - "import sympy\n", - "\n", - "# Given\n", - "U_max = 0.2 # Maximum velocity (m/s)\n", - "h = 0.01 # film thickness (m)\n", - "mu = 0.5 # Viscosity of the non-Newtonian fluid (Ns/m^2)\n", - "y = sympy.Symbol('y') \n", - "u = sympy.Symbol('u') \n", - "u = U_max * (2*(y/h)-(y/h)**3/3) # Expression for velocity\n", - "\n", - "# (a) Shear stress calculation\n", - "du_dy = sympy.diff(u,y) # Velocity gradient\n", - "tau = mu*(round(du_dy.subs(y,h)))**1.3 # Shear stress of the non-Newtonian fluid (N/m^2)\n", - "print('The shear stress at the solid surface is %.2f N/m^2.' %tau)\n", - "\n", - "# (b) Estimation of the viscosity of the Newtonian fluid\n", - "mu = sympy.Symbol('mu')\n", - "mu = sympy.solve(sympy.Eq(round(tau,2),mu*round(du_dy.subs(y,h))))[0] # Solve for mu for the same shear stress using Newton's law of viscosity\n", - "print('The viscosity of a Newtonian fluid to induce the same shear stress is %.2f Ns/m^2.' %mu)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The shear stress at the solid surface is 24.56 N/m^2.\n", - "The viscosity of a Newtonian fluid to induce the same shear stress is 1.23 Ns/m^2.\n" - ] - } - ], - "prompt_number": 69 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/GauravMittal/GauravMittal_version_backup/chapter2.ipynb b/sample_notebooks/GauravMittal/GauravMittal_version_backup/chapter2.ipynb new file mode 100755 index 00000000..739819fc --- /dev/null +++ b/sample_notebooks/GauravMittal/GauravMittal_version_backup/chapter2.ipynb @@ -0,0 +1,349 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-2 : DC Machines" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.1 page 112" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "#Calculate the increase of main field flux in percentage\n", + "N_1=750 #speed of dc machine(in rpm)\n", + "E_1=220 #induced emf in dc machine when running at N_1\n", + "N_2=700 #speed of dc machine second time (in rpm)\n", + "E_2=250 #induced emf in dc machine when running at N_2\n", + "F=E_2*N_1/(E_1*N_2) \n", + "Inc=(F-1) \n", + "print 'increase in main field flux of the dc machine =',round((Inc*100),2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "increase in main field flux of the dc machine = 21.75\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.2 page 114" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#a)find the emf generated in a 6 pole machine b)find speed at which machine generated 550 V emf\n", + "F_1=0.06 #Flux per pole(in Wb)\n", + "N_1=250 #speed of the rotor(in rpm)\n", + "A=2 #number of parllel (paths armature wave wound)\n", + "P=6 #poles in machine\n", + "Z=664 #total conductor in machine\n", + "E_g=P*F_1*N_1*Z/(60*A) #emf generated\n", + "print \"emf generated in machine =\",E_g,\"Volts\"\n", + "E_2=550 #new emf generating machine(in V)\n", + "F_2=0.058 #flux per pole (in Wb) for generating E_2\n", + "N_2=60*E_2*A/(P*F_2*Z) #new speed at which machine generating E_2(in rpm)\n", + "print \"new speed of the rotor =\",round(N_2,2),\"rpm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "emf generated in machine = 498.0 Volts\n", + "new speed of the rotor = 285.63 rpm\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.3 page 116" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#determine the value of torque in Nw-m\n", + "F=24 #flux per pole (in m Wb)\n", + "F_1=F*10**-3 #flux per pole (in Wb)\n", + "Z=760 #number of conductors in armature\n", + "P=4 #number of pole\n", + "A=2 #number of parallel paths\n", + "I_a=50 #armature cuurrent(in Amp)\n", + "T_a=0.159*F_1*Z*P*I_a/A #torque develope(in Nw-m)\n", + "print \"torque developed in machine =\",round(T_a,2),\"Nw-m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "torque developed in machine = 290.02 Nw-m\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.4 page 119" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the total torque in Nw-m\n", + "P=6 #poles \n", + "A=P #number of parallel paths\n", + "S=60 #slots in motor\n", + "C_s=12 #conductor per slot\n", + "Z=S*C_s #total conductor in machine\n", + "I_a=50 #armature current(in Amp)\n", + "F_1=20#flux per pole(in m Wb)\n", + "F_2=F_1*10**-3 #flux per pole)(in Wb)\n", + "T=0.15924*F_2*Z*P*I_a/A #total torque (in Nw-m)\n", + "print 'total torque by motor =',T,'Nw-m' " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "total torque by motor = 114.6528 Nw-m\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam 2.5 page 132" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import ceil\n", + "#Calculate the drop in speed when motor takes 51 Amp\n", + "V=220 #supply voltage(in V)\n", + "R_sh=220 #shunt field resistance(in Ohm)\n", + "R_a=0.2 #armature resistance(in Ohm)\n", + "I_sh=V/R_sh #shunt field current(in Amp)\n", + "N_1=1200 #starting speed of the motor(in rpm)\n", + "I_1=5.4 #at N_1 speed current in motor(in Amp)\n", + "I_a1=I_1-I_sh #armature current at speed N_1(in Amp)\n", + "E_b1=V-I_a1*R_a #emf induced due to I_a1(in V)\n", + "I_2=51 #new current which motor taking(in Amp)\n", + "I_a2=I_2-I_sh #armature current at I_2(in Amp)\n", + "E_b2=V-I_a2*R_a #emf induced due to I_a2(in V)\n", + "N_2=E_b2*N_1/E_b1 #speed of the motor when taking I_2 current(in rpm)\n", + "N_r=ceil(N_1-N_2) #reduction in speed(in rpm)\n", + "print 'reduction in speed =',N_r,'rpm'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "reduction in speed = 50.0 rpm\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.6 page 135" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#In a dc machine Calculate (a)induced emf (b)Electro magnetic torque (c)armature copper loss \n", + "V=220 #voltage at the armature of dc motor\n", + "I_a=15 #current through armature(in Amp)\n", + "R_a=1 #armature resistance(in Ohm)\n", + "w=100 #speed of the machine(in radian/sec)\n", + "E=V-I_a*R_a #induced emf(in V)\n", + "print 'induced emf =',E,'V' \n", + "T=E*I_a/w #electro magnentic torque developed(in Nw-m)\n", + "print 'electro magnentic torque developed =',T,'Nw-m'\n", + "L=(I_a**2)*R_a #Armature copper loss(in Watt)\n", + "print 'Armature copper loss =',L,'Watt'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "induced emf = 205 V\n", + "electro magnentic torque developed = 30.75 Nw-m\n", + "Armature copper loss = 225 Watt\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.7 page 135" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Calculate the electro magnetic torque\n", + "E=250 #emf induced in dc machine(in V)\n", + "I_a=20 #current flowing through the armature(in Amp)\n", + "N=1500 #speed(in rpm)\n", + "T_e=0.1591*E*I_a*60/N #torque developed in machine(in Nw-m)\n", + "print 'electro magnetic torque developed in dc machine =',T_e,'Nw-m'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "electro magnetic torque developed in dc machine = 31.82 Nw-m\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.8 page 136" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate the gross torque in dc machine\n", + "P=4 #number of poles \n", + "Z=1600 #number of armature conductor\n", + "F=0.027 #flux per pole(in Wb)\n", + "A=2 #number of parallel paths (wave wound)\n", + "I=75 #current in machine(in Amp)\n", + "N=1000 #speed of the motor(in rpm)\n", + "T=0.1591*P*F*Z*I/A #torque generate in machine(in Nw-m)\n", + "print 'Torque generated in machine =',T,'Nw-m'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Torque generated in machine = 1030.968 Nw-m\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exam:2.9 page 140" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Calculate the value of back emf\n", + "V=230 #applied voltage (in V)\n", + "R_a=0.1 #armature resistance(in Ohm)\n", + "I_a=60 #armature current (in Amp)\n", + "E_b=V-I_a*R_a #back emf(in Volts)\n", + "print 'back emf produced by machine =',E_b,'V'" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "back emf produced by machine = 224.0 V\n" + ] + } + ], + "prompt_number": 24 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/GauravMittal/chapter2.ipynb b/sample_notebooks/GauravMittal/chapter2.ipynb deleted file mode 100755 index 739819fc..00000000 --- a/sample_notebooks/GauravMittal/chapter2.ipynb +++ /dev/null @@ -1,349 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Ch-2 : DC Machines" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.1 page 112" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "#Calculate the increase of main field flux in percentage\n", - "N_1=750 #speed of dc machine(in rpm)\n", - "E_1=220 #induced emf in dc machine when running at N_1\n", - "N_2=700 #speed of dc machine second time (in rpm)\n", - "E_2=250 #induced emf in dc machine when running at N_2\n", - "F=E_2*N_1/(E_1*N_2) \n", - "Inc=(F-1) \n", - "print 'increase in main field flux of the dc machine =',round((Inc*100),2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "increase in main field flux of the dc machine = 21.75\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.2 page 114" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#a)find the emf generated in a 6 pole machine b)find speed at which machine generated 550 V emf\n", - "F_1=0.06 #Flux per pole(in Wb)\n", - "N_1=250 #speed of the rotor(in rpm)\n", - "A=2 #number of parllel (paths armature wave wound)\n", - "P=6 #poles in machine\n", - "Z=664 #total conductor in machine\n", - "E_g=P*F_1*N_1*Z/(60*A) #emf generated\n", - "print \"emf generated in machine =\",E_g,\"Volts\"\n", - "E_2=550 #new emf generating machine(in V)\n", - "F_2=0.058 #flux per pole (in Wb) for generating E_2\n", - "N_2=60*E_2*A/(P*F_2*Z) #new speed at which machine generating E_2(in rpm)\n", - "print \"new speed of the rotor =\",round(N_2,2),\"rpm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "emf generated in machine = 498.0 Volts\n", - "new speed of the rotor = 285.63 rpm\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.3 page 116" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#determine the value of torque in Nw-m\n", - "F=24 #flux per pole (in m Wb)\n", - "F_1=F*10**-3 #flux per pole (in Wb)\n", - "Z=760 #number of conductors in armature\n", - "P=4 #number of pole\n", - "A=2 #number of parallel paths\n", - "I_a=50 #armature cuurrent(in Amp)\n", - "T_a=0.159*F_1*Z*P*I_a/A #torque develope(in Nw-m)\n", - "print \"torque developed in machine =\",round(T_a,2),\"Nw-m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "torque developed in machine = 290.02 Nw-m\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.4 page 119" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate the total torque in Nw-m\n", - "P=6 #poles \n", - "A=P #number of parallel paths\n", - "S=60 #slots in motor\n", - "C_s=12 #conductor per slot\n", - "Z=S*C_s #total conductor in machine\n", - "I_a=50 #armature current(in Amp)\n", - "F_1=20#flux per pole(in m Wb)\n", - "F_2=F_1*10**-3 #flux per pole)(in Wb)\n", - "T=0.15924*F_2*Z*P*I_a/A #total torque (in Nw-m)\n", - "print 'total torque by motor =',T,'Nw-m' " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "total torque by motor = 114.6528 Nw-m\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam 2.5 page 132" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import ceil\n", - "#Calculate the drop in speed when motor takes 51 Amp\n", - "V=220 #supply voltage(in V)\n", - "R_sh=220 #shunt field resistance(in Ohm)\n", - "R_a=0.2 #armature resistance(in Ohm)\n", - "I_sh=V/R_sh #shunt field current(in Amp)\n", - "N_1=1200 #starting speed of the motor(in rpm)\n", - "I_1=5.4 #at N_1 speed current in motor(in Amp)\n", - "I_a1=I_1-I_sh #armature current at speed N_1(in Amp)\n", - "E_b1=V-I_a1*R_a #emf induced due to I_a1(in V)\n", - "I_2=51 #new current which motor taking(in Amp)\n", - "I_a2=I_2-I_sh #armature current at I_2(in Amp)\n", - "E_b2=V-I_a2*R_a #emf induced due to I_a2(in V)\n", - "N_2=E_b2*N_1/E_b1 #speed of the motor when taking I_2 current(in rpm)\n", - "N_r=ceil(N_1-N_2) #reduction in speed(in rpm)\n", - "print 'reduction in speed =',N_r,'rpm'" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "reduction in speed = 50.0 rpm\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.6 page 135" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#In a dc machine Calculate (a)induced emf (b)Electro magnetic torque (c)armature copper loss \n", - "V=220 #voltage at the armature of dc motor\n", - "I_a=15 #current through armature(in Amp)\n", - "R_a=1 #armature resistance(in Ohm)\n", - "w=100 #speed of the machine(in radian/sec)\n", - "E=V-I_a*R_a #induced emf(in V)\n", - "print 'induced emf =',E,'V' \n", - "T=E*I_a/w #electro magnentic torque developed(in Nw-m)\n", - "print 'electro magnentic torque developed =',T,'Nw-m'\n", - "L=(I_a**2)*R_a #Armature copper loss(in Watt)\n", - "print 'Armature copper loss =',L,'Watt'" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "induced emf = 205 V\n", - "electro magnentic torque developed = 30.75 Nw-m\n", - "Armature copper loss = 225 Watt\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.7 page 135" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Calculate the electro magnetic torque\n", - "E=250 #emf induced in dc machine(in V)\n", - "I_a=20 #current flowing through the armature(in Amp)\n", - "N=1500 #speed(in rpm)\n", - "T_e=0.1591*E*I_a*60/N #torque developed in machine(in Nw-m)\n", - "print 'electro magnetic torque developed in dc machine =',T_e,'Nw-m'" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "electro magnetic torque developed in dc machine = 31.82 Nw-m\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.8 page 136" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate the gross torque in dc machine\n", - "P=4 #number of poles \n", - "Z=1600 #number of armature conductor\n", - "F=0.027 #flux per pole(in Wb)\n", - "A=2 #number of parallel paths (wave wound)\n", - "I=75 #current in machine(in Amp)\n", - "N=1000 #speed of the motor(in rpm)\n", - "T=0.1591*P*F*Z*I/A #torque generate in machine(in Nw-m)\n", - "print 'Torque generated in machine =',T,'Nw-m'" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Torque generated in machine = 1030.968 Nw-m\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exam:2.9 page 140" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Calculate the value of back emf\n", - "V=230 #applied voltage (in V)\n", - "R_a=0.1 #armature resistance(in Ohm)\n", - "I_a=60 #armature current (in Amp)\n", - "E_b=V-I_a*R_a #back emf(in Volts)\n", - "print 'back emf produced by machine =',E_b,'V'" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "back emf produced by machine = 224.0 V\n" - ] - } - ], - "prompt_number": 24 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/GirishVora/GirishVora_version_backup/ch2.ipynb b/sample_notebooks/GirishVora/GirishVora_version_backup/ch2.ipynb new file mode 100755 index 00000000..9eb5c1ee --- /dev/null +++ b/sample_notebooks/GirishVora/GirishVora_version_backup/ch2.ipynb @@ -0,0 +1,428 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:3545b25396a8ddd5a6290547da9d278c18ef204a72b66bd3a11c0eea3ce41199" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : METHODS OF IRRIGATION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 pg : 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\n", + "#Given\n", + "Q = 0.0108 #discharge through well\n", + "y = 0.075 #average depth of flow\n", + "I = 0.05 #average infiltration rate\n", + "A = 0.1 #area to cover\n", + "\n", + "# Calculations\n", + "t = (60*2.303*y*math.log10(Q/(Q-I*A)))/I\n", + "\n", + "# Results\n", + "print \"Time required to cover given area = %.f minutes.\"%(t)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time required to cover given area = 56 minutes.\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 pg : 21" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Given\n", + "Q = 0.0108 #discharge through well\n", + "y = 0.075 #average depth of flow\n", + "I = 0.05 #average infiltration rate\n", + "A = 0.1 #area to cover\n", + "\n", + "# Calculations\n", + "Amax = Q/I;\n", + "\n", + "# Results\n", + "print \"Maximum area that can be irrigated = %.2f hectare.\"%(Amax);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum area that can be irrigated = 0.22 hectare.\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 pg : 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\n", + "\n", + "#time of water application\n", + "#optimum length of each border strip\n", + "#dischrge for each border strip\n", + "\n", + "#Given\n", + "d = 0.05;\t\t\t\t\t\t\t\t#depth of root zone\n", + "I = 1.25E-5;\t\t\t\t\t\t\t\t#average infiltration rate\n", + "s = 0.0035\t\t\t\t\t\t\t\t#slope of border strip\n", + "t = d/(I*3600);\n", + "\n", + "# Calculations and Results\n", + "t = round(t*1000)/1000;\n", + "print \"Time of water application = %.2f hours.\"%(t);\n", + "\n", + "#Part (a)\n", + "q = 2E-3;\t\t\t\t\t\t\t\t#discharge entering water source\n", + "qdash = q*100**2*60;\n", + "n = 0.55425-(0.0001386*qdash);\n", + "yo = (n*q/(s**0.5))**0.6;\n", + "y = 0.665*yo;\n", + "L = (q/I)*(1-math.e**(-d/y));\n", + "L = round(10*L)/10;\n", + "print \"Part a:\";\n", + "print \"Optimum length of each border strip = %.2f m.\"%(L);\n", + "\n", + "#Part (b)\n", + "Lgiven = 150\t\t\t\t\t\t\t\t#given value of length\n", + "#First Trial\n", + "q = 3E-3;\n", + "qdash = q*100**2*60;\n", + "n = 0.55425-(0.0001386*qdash);\n", + "yo = (n*q/(s**0.5))**0.6;\n", + "y = 0.665*yo;\n", + "L = (q/I)*(1-math.e**(-d/y));\n", + "#second trial\n", + "q = 3.15E-3;\n", + "qdash = q*100**2*60;\n", + "n = 0.55425-(0.0001386*qdash);\n", + "yo = (n*q/(s**0.5))**0.6;\n", + "y = 0.665*yo;\n", + "L = (q/I)*(1-math.e**(-d/y));\n", + "q = 9*Lgiven*q*1000/L;\n", + "q = round(q*10)/10;\n", + "print \"Part b:\";\n", + "print \"Discharge for each border strip = %.2f lps.\"%(q);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time of water application = 1.11 hours.\n", + "Part a:\n", + "Optimum length of each border strip = 101.90 m.\n", + "Part b:\n", + "Discharge for each border strip = 28.20 lps.\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 pg : 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\n", + "\n", + "\n", + "#deep percolation loss\n", + "#water application efficiency and time of irrigation.\n", + "\n", + "#Given\n", + "B = 12.;\t\t\t\t#breadth of bamath.sin\n", + "L = 36.\t\t\t\t#length of bamath.sin\n", + "d = 70.\t\t\t\t#depth of irrigation\n", + "Ic = 70.\t\t\t\t#cumulative infiltration\n", + "kdash = 9;\n", + "ndash = 0.42;\n", + "#Part (a) \n", + "a = 5;\n", + "b = 0.6;\n", + "q = 1.5;\t\t\t\t#stream size\n", + "\n", + "# Calculations and Results\n", + "Q = (q*B)/1000;\n", + "tl = (L/a)**(1/b);\n", + "td = (Ic/kdash)**(1/ndash);\n", + "T = tl+td;\n", + "p = (1-(td/T)**(ndash))*100;\n", + "eita = (1-p/100)*100;\n", + "Tdash = (d*L*B)/(10*eita*Q*60);\n", + "p = round(p*100)/100;\n", + "eita = round(eita*100)/100;\n", + "Tdash = round(Tdash*10)/10;\n", + "print \"Part a:\"\n", + "print \"Deep percolation loss = %.2f percent.\"%(p);\n", + "print \"Water application efficiency = %.2f percent.\"%(eita);\n", + "print \"Time of irrigation = %.2f minutes.\"%(Tdash);\n", + "#part (b)\n", + "a = 8;\n", + "b = 0.6;\n", + "q = 3;\n", + "Q = (q*B)/1000;\n", + "tl = (L/a)**(1/b);\n", + "td = (Ic/kdash)**(1/ndash);\n", + "T = tl+td;\n", + "p = (1-(td/T)**(ndash))*100;\n", + "eita = (1-p/100)*100;\n", + "Tdash = (d*L*B)/(10*eita*Q*60);\n", + "p = round(p*100)/100;\n", + "eita = round(eita*100)/100;\n", + "Tdash = round(Tdash*10)/10;\n", + "\n", + "print \"Part b:\"\n", + "print \"Deep percolation loss = %.2f percent.\"%(p);\n", + "print \"Water application efficiency = %.2f percent.\"%(eita);\n", + "print \"Time of irrigation = %.2f minutes.\"%(Tdash);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part a:\n", + "Deep percolation loss = 7.47 percent.\n", + "Water application efficiency = 92.53 percent.\n", + "Time of irrigation = 30.30 minutes.\n", + "Part b:\n", + "Deep percolation loss = 3.66 percent.\n", + "Water application efficiency = 96.34 percent.\n", + "Time of irrigation = 14.50 minutes.\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 pg : 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "from numpy import zeros\n", + "\n", + "\n", + "#given\n", + "d = 37.5\t\t\t\t#crop water requirement\n", + "W = 1.\t\t\t\t#furrow spacing\n", + "L = 120.\t\t\t\t#length of furrow\n", + "n = -0.49;\n", + "k = 38.;\n", + "Ttotal = 143.;\t\t\t\t#Total time of irrigation\n", + "A = [0 ,23, 52 ,88, 127]\t\t\t\t#given values of time of advance\n", + "B = zeros(5)\n", + "C = zeros(5)\n", + "D = zeros(5)\n", + "E = zeros(5)\n", + "\n", + "# Calculations\n", + "for i in range(5):\t\t\t\t#loop to find respective values of time of ponding\n", + " B[i] = 143-A[i] \n", + "\n", + "for j in range(5):\t\t\t\t#loop to find respective furrow infiltration\n", + " C[j] = B[j]**(n)*k;\n", + "\n", + "for K in range(4):\t\t\t\t#loop to find respective average infiltration\n", + " D[K] = (C[K]+C[K+1])/2;\n", + "\n", + "\n", + "E[0] = D[0];\n", + "for l in range(1,4):\t\t\t\t#loop to determine cumulative infiltration\n", + " E[l] = D[l]+E[l-1];\n", + "\n", + "I = E[3];\n", + "\n", + "T = (30*d*W*(n+1)/k)**(1/(n+1));\n", + "dav = ((24.5*Ttotal)+(I*(T-Ttotal)))/L;\n", + "q = ((120*37.5)-(24.5*143))/62;\n", + "T = round(T);\n", + "dav = round(dav*10)/10;\n", + "q = round(q*100)/100;\n", + "I = round(I*100)/100;\n", + "\n", + "# Results\n", + "print \"Maximum size of cut-back stream = %.2f lpm.\"%(I);\n", + "print \"Minimum size of cut-back stream = %.2f lpm.\"%(q);\n", + "print \"Time required for putting 37.5mm depth of water = %.2f minutes.\"%(T);\n", + "print \"Average depth of water required = %.2f mm.\"%(dav);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum size of cut-back stream = 19.69 lpm.\n", + "Minimum size of cut-back stream = 16.07 lpm.\n", + "Time required for putting 37.5mm depth of water = 205.00 minutes.\n", + "Average depth of water required = 39.40 mm.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 pg : 32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#Given\n", + "L = 100.;\t\t\t\t#length of furrow\n", + "W = 1.;\t\t\t\t#furrow spacing\n", + "s = 0.3\t\t\t\t#longitudnal slope of furrow\n", + "t1 = 80.\t\t\t\t#initial time flow of stream\n", + "t2 = 35.\t\t\t\t#final time flow of stream\n", + "\n", + "# Calculations\n", + "qm = 0.6/s;\n", + "q = qm*0.4;\n", + "dav = ((q*t2*60)+(2*t1*60))/100;\n", + "\n", + "# Results\n", + "print \"Average depth of water applied = %.2f mm.\"%(dav);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average depth of water applied = 112.80 mm.\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 pg : 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "\n", + "#Given\n", + "Q = 0.0072;\t\t\t\t#discharge through well\n", + "y = 0.1;\t\t\t\t#average depth of flow\n", + "I = 0.05\t\t\t\t#infiltration capacity of soil\n", + "A = 0.04\t\t\t\t#area of land\n", + "\n", + "# Calculations\n", + "t = (2.303*y*60/I)*math.log10(Q/(Q-I*A));\n", + "Amax = Q/I;\n", + "t = round(t*100)/100;\n", + "\n", + "# Results\n", + "print \"Time required to irrigate = %.2f minutes.\"%(t);\n", + "print \"Maximum area that can be irrigated = %.2f ha.\"%(Amax);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time required to irrigate = 39.06 minutes.\n", + "Maximum area that can be irrigated = 0.14 ha.\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/GirishVora/ch2.ipynb b/sample_notebooks/GirishVora/ch2.ipynb deleted file mode 100755 index 9eb5c1ee..00000000 --- a/sample_notebooks/GirishVora/ch2.ipynb +++ /dev/null @@ -1,428 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:3545b25396a8ddd5a6290547da9d278c18ef204a72b66bd3a11c0eea3ce41199" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 : METHODS OF IRRIGATION" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 pg : 21" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "\n", - "#Given\n", - "Q = 0.0108 #discharge through well\n", - "y = 0.075 #average depth of flow\n", - "I = 0.05 #average infiltration rate\n", - "A = 0.1 #area to cover\n", - "\n", - "# Calculations\n", - "t = (60*2.303*y*math.log10(Q/(Q-I*A)))/I\n", - "\n", - "# Results\n", - "print \"Time required to cover given area = %.f minutes.\"%(t)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time required to cover given area = 56 minutes.\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2 pg : 21" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "#Given\n", - "Q = 0.0108 #discharge through well\n", - "y = 0.075 #average depth of flow\n", - "I = 0.05 #average infiltration rate\n", - "A = 0.1 #area to cover\n", - "\n", - "# Calculations\n", - "Amax = Q/I;\n", - "\n", - "# Results\n", - "print \"Maximum area that can be irrigated = %.2f hectare.\"%(Amax);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum area that can be irrigated = 0.22 hectare.\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 pg : 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "\n", - "\n", - "#time of water application\n", - "#optimum length of each border strip\n", - "#dischrge for each border strip\n", - "\n", - "#Given\n", - "d = 0.05;\t\t\t\t\t\t\t\t#depth of root zone\n", - "I = 1.25E-5;\t\t\t\t\t\t\t\t#average infiltration rate\n", - "s = 0.0035\t\t\t\t\t\t\t\t#slope of border strip\n", - "t = d/(I*3600);\n", - "\n", - "# Calculations and Results\n", - "t = round(t*1000)/1000;\n", - "print \"Time of water application = %.2f hours.\"%(t);\n", - "\n", - "#Part (a)\n", - "q = 2E-3;\t\t\t\t\t\t\t\t#discharge entering water source\n", - "qdash = q*100**2*60;\n", - "n = 0.55425-(0.0001386*qdash);\n", - "yo = (n*q/(s**0.5))**0.6;\n", - "y = 0.665*yo;\n", - "L = (q/I)*(1-math.e**(-d/y));\n", - "L = round(10*L)/10;\n", - "print \"Part a:\";\n", - "print \"Optimum length of each border strip = %.2f m.\"%(L);\n", - "\n", - "#Part (b)\n", - "Lgiven = 150\t\t\t\t\t\t\t\t#given value of length\n", - "#First Trial\n", - "q = 3E-3;\n", - "qdash = q*100**2*60;\n", - "n = 0.55425-(0.0001386*qdash);\n", - "yo = (n*q/(s**0.5))**0.6;\n", - "y = 0.665*yo;\n", - "L = (q/I)*(1-math.e**(-d/y));\n", - "#second trial\n", - "q = 3.15E-3;\n", - "qdash = q*100**2*60;\n", - "n = 0.55425-(0.0001386*qdash);\n", - "yo = (n*q/(s**0.5))**0.6;\n", - "y = 0.665*yo;\n", - "L = (q/I)*(1-math.e**(-d/y));\n", - "q = 9*Lgiven*q*1000/L;\n", - "q = round(q*10)/10;\n", - "print \"Part b:\";\n", - "print \"Discharge for each border strip = %.2f lps.\"%(q);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time of water application = 1.11 hours.\n", - "Part a:\n", - "Optimum length of each border strip = 101.90 m.\n", - "Part b:\n", - "Discharge for each border strip = 28.20 lps.\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 pg : 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "\n", - "\n", - "\n", - "#deep percolation loss\n", - "#water application efficiency and time of irrigation.\n", - "\n", - "#Given\n", - "B = 12.;\t\t\t\t#breadth of bamath.sin\n", - "L = 36.\t\t\t\t#length of bamath.sin\n", - "d = 70.\t\t\t\t#depth of irrigation\n", - "Ic = 70.\t\t\t\t#cumulative infiltration\n", - "kdash = 9;\n", - "ndash = 0.42;\n", - "#Part (a) \n", - "a = 5;\n", - "b = 0.6;\n", - "q = 1.5;\t\t\t\t#stream size\n", - "\n", - "# Calculations and Results\n", - "Q = (q*B)/1000;\n", - "tl = (L/a)**(1/b);\n", - "td = (Ic/kdash)**(1/ndash);\n", - "T = tl+td;\n", - "p = (1-(td/T)**(ndash))*100;\n", - "eita = (1-p/100)*100;\n", - "Tdash = (d*L*B)/(10*eita*Q*60);\n", - "p = round(p*100)/100;\n", - "eita = round(eita*100)/100;\n", - "Tdash = round(Tdash*10)/10;\n", - "print \"Part a:\"\n", - "print \"Deep percolation loss = %.2f percent.\"%(p);\n", - "print \"Water application efficiency = %.2f percent.\"%(eita);\n", - "print \"Time of irrigation = %.2f minutes.\"%(Tdash);\n", - "#part (b)\n", - "a = 8;\n", - "b = 0.6;\n", - "q = 3;\n", - "Q = (q*B)/1000;\n", - "tl = (L/a)**(1/b);\n", - "td = (Ic/kdash)**(1/ndash);\n", - "T = tl+td;\n", - "p = (1-(td/T)**(ndash))*100;\n", - "eita = (1-p/100)*100;\n", - "Tdash = (d*L*B)/(10*eita*Q*60);\n", - "p = round(p*100)/100;\n", - "eita = round(eita*100)/100;\n", - "Tdash = round(Tdash*10)/10;\n", - "\n", - "print \"Part b:\"\n", - "print \"Deep percolation loss = %.2f percent.\"%(p);\n", - "print \"Water application efficiency = %.2f percent.\"%(eita);\n", - "print \"Time of irrigation = %.2f minutes.\"%(Tdash);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Part a:\n", - "Deep percolation loss = 7.47 percent.\n", - "Water application efficiency = 92.53 percent.\n", - "Time of irrigation = 30.30 minutes.\n", - "Part b:\n", - "Deep percolation loss = 3.66 percent.\n", - "Water application efficiency = 96.34 percent.\n", - "Time of irrigation = 14.50 minutes.\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5 pg : 31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "from numpy import zeros\n", - "\n", - "\n", - "#given\n", - "d = 37.5\t\t\t\t#crop water requirement\n", - "W = 1.\t\t\t\t#furrow spacing\n", - "L = 120.\t\t\t\t#length of furrow\n", - "n = -0.49;\n", - "k = 38.;\n", - "Ttotal = 143.;\t\t\t\t#Total time of irrigation\n", - "A = [0 ,23, 52 ,88, 127]\t\t\t\t#given values of time of advance\n", - "B = zeros(5)\n", - "C = zeros(5)\n", - "D = zeros(5)\n", - "E = zeros(5)\n", - "\n", - "# Calculations\n", - "for i in range(5):\t\t\t\t#loop to find respective values of time of ponding\n", - " B[i] = 143-A[i] \n", - "\n", - "for j in range(5):\t\t\t\t#loop to find respective furrow infiltration\n", - " C[j] = B[j]**(n)*k;\n", - "\n", - "for K in range(4):\t\t\t\t#loop to find respective average infiltration\n", - " D[K] = (C[K]+C[K+1])/2;\n", - "\n", - "\n", - "E[0] = D[0];\n", - "for l in range(1,4):\t\t\t\t#loop to determine cumulative infiltration\n", - " E[l] = D[l]+E[l-1];\n", - "\n", - "I = E[3];\n", - "\n", - "T = (30*d*W*(n+1)/k)**(1/(n+1));\n", - "dav = ((24.5*Ttotal)+(I*(T-Ttotal)))/L;\n", - "q = ((120*37.5)-(24.5*143))/62;\n", - "T = round(T);\n", - "dav = round(dav*10)/10;\n", - "q = round(q*100)/100;\n", - "I = round(I*100)/100;\n", - "\n", - "# Results\n", - "print \"Maximum size of cut-back stream = %.2f lpm.\"%(I);\n", - "print \"Minimum size of cut-back stream = %.2f lpm.\"%(q);\n", - "print \"Time required for putting 37.5mm depth of water = %.2f minutes.\"%(T);\n", - "print \"Average depth of water required = %.2f mm.\"%(dav);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum size of cut-back stream = 19.69 lpm.\n", - "Minimum size of cut-back stream = 16.07 lpm.\n", - "Time required for putting 37.5mm depth of water = 205.00 minutes.\n", - "Average depth of water required = 39.40 mm.\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 pg : 32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "#Given\n", - "L = 100.;\t\t\t\t#length of furrow\n", - "W = 1.;\t\t\t\t#furrow spacing\n", - "s = 0.3\t\t\t\t#longitudnal slope of furrow\n", - "t1 = 80.\t\t\t\t#initial time flow of stream\n", - "t2 = 35.\t\t\t\t#final time flow of stream\n", - "\n", - "# Calculations\n", - "qm = 0.6/s;\n", - "q = qm*0.4;\n", - "dav = ((q*t2*60)+(2*t1*60))/100;\n", - "\n", - "# Results\n", - "print \"Average depth of water applied = %.2f mm.\"%(dav);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Average depth of water applied = 112.80 mm.\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 pg : 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "\n", - "#Given\n", - "Q = 0.0072;\t\t\t\t#discharge through well\n", - "y = 0.1;\t\t\t\t#average depth of flow\n", - "I = 0.05\t\t\t\t#infiltration capacity of soil\n", - "A = 0.04\t\t\t\t#area of land\n", - "\n", - "# Calculations\n", - "t = (2.303*y*60/I)*math.log10(Q/(Q-I*A));\n", - "Amax = Q/I;\n", - "t = round(t*100)/100;\n", - "\n", - "# Results\n", - "print \"Time required to irrigate = %.2f minutes.\"%(t);\n", - "print \"Maximum area that can be irrigated = %.2f ha.\"%(Amax);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time required to irrigate = 39.06 minutes.\n", - "Maximum area that can be irrigated = 0.14 ha.\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Gopi KrishnaManchukonda/Chapter2Electrostatics.ipynb b/sample_notebooks/Gopi KrishnaManchukonda/Chapter2Electrostatics.ipynb new file mode 100755 index 00000000..8ece860c --- /dev/null +++ b/sample_notebooks/Gopi KrishnaManchukonda/Chapter2Electrostatics.ipynb @@ -0,0 +1,281 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Electrostatics " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_1 pgno:13" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Resultant force acting on charge at C= N 12.72\n" + ] + } + ], + "source": [ + "from math import pi,sqrt,cos,sin\n", + "\n", + "epsilon=8.854e-12\n", + "r=sqrt(.1**2+.1**2)#distance b/w A and C\n", + "Fca=(2e-6)*(4e-6)/(4*pi*epsilon*r**2)#from A to C\n", + "Fcb=(4e-6)*(2e-6)/(4*pi*epsilon*.1**2)#from C to B\n", + "Fcd=(4e-6)*(4e-6)/(4*pi*epsilon*.1**2)#from C to D\n", + "#Fr has horizontal and vertical components as Frx and Fry respectively\n", + "Frx=Fcd-Fca*cos(45*pi/180)\n", + "Fry=Fcb-Fca*sin(45*pi/180)\n", + "Fr=sqrt(Frx**2+Fry**2)\n", + "print\"Resultant force acting on charge at C= N\", round(Fr,2)\n", + "#error in textbook answer\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_ pgno:15" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Resultant intensity on charge at C=*10**4 N/C at angle eegrees 25.44 37.0\n" + ] + } + ], + "source": [ + "from math import pi,cos,sin,sqrt,atan\n", + "epsilon=8.854e-12\n", + "E1=(4e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at A,eirection is from e to A\n", + "r=sqrt(2*.05**2)#eistance b/w B ane e\n", + "E2=(4e-8)/(4*pi*epsilon*r**2)#fiele intensity eue to charge at B,eirection is from B to e along eiagonal Be\n", + "E3=(8e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at C,eirection is from e to C\n", + "#Er has horizontal ane vertical components as Erx ane Ery respectively\n", + "Erx=E3-E2*cos(45*pi/180)\n", + "Ery=-E1+E2*sin(45*pi/180)\n", + "Er=sqrt(Erx**2+Ery**2)\n", + "theta=atan(Ery/Erx)\n", + "print\"Resultant intensity on charge at C=*10**4 N/C at angle eegrees\", round(Er/10**4,2),round(-theta*100)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_3 pgno:15" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Potential at A eue to charges at B, C ane e= V 3.73\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "epsilon=8.854e-12\n", + "AB=.05\n", + "BC=.07\n", + "AC=sqrt(.05**2+.07**2)\n", + "V1=2e-10/(4*pi*epsilon*.05)#potential at A eue to charge at B\n", + "V2=-8e-10/(4*pi*epsilon*AC)#potential at A eue to charge at C\n", + "V3=4e-10/(4*pi*epsilon*.07)#potential at A eue to charge at e\n", + "V=V1+V2+V3 \n", + "print\"Potential at A eue to charges at B, C ane e= V\", round(V,2)\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_4 pgno:16" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Time constant T= sec\n", + "0.015\n", + "Initial current= A\n", + "0.2\n", + "Charge on the capacitor after 0.05 sec is C\n", + "0.003\n", + "Charging current after 0.05 sec is A\n", + "0.007\n", + "Charging current after 0.015 sec is A\n", + "0.074\n", + "Voltage across 500 ohm resistor after 0.05 sec is V 3.567\n" + ] + } + ], + "source": [ + "from math import exp\n", + "C=30e-6\n", + "R=500.\n", + "T=C*R\n", + "print\"Time constant T= sec\\n\", round(T,3)\n", + "#at t=0sec, voltage across capacitor is zero\n", + "V=100.#apliee voltage\n", + "I=V/R#Ohm's Law\n", + "print\"Initial current= A\\n\", round(I,3)\n", + "t=.05\n", + "Q=C*V\n", + "q=Q*(1-exp(-t/T))\n", + "print\"Charge on the capacitor after 0.05 sec is C\\n\", round(q,3)\n", + "i1=I*exp(-t/T)\n", + "print\"Charging current after 0.05 sec is A\\n\",round(i1,3)\n", + "t=.015\n", + "i2=I*exp(-t/T)\n", + "print\"Charging current after 0.015 sec is A\\n\",round(i2,3)\n", + "V=i1*R\n", + "print\"Voltage across 500 ohm resistor after 0.05 sec is V\", round(V,3)\n", + "#answers vary from the textbook eue to roune off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_5 pgno:17" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "P.e. across the combination = V\n", + "133.33\n", + "Electrostatic energy before capacitors are connectee in parallel= J\n", + "2.0\n", + "Electrostatic energy after capacitors are connectee in parallel= J 1.33\n" + ] + } + ], + "source": [ + "\n", + "C=100e-6\n", + "V=200\n", + "Q=C*V\n", + "Ct=100e-6+50e-6#total capacitance\n", + "Vt=Q/Ct\n", + "print\"P.e. across the combination = V\\n\", round(Vt,2)\n", + "EE1=100e-6*V**2/2\n", + "print\"Electrostatic energy before capacitors are connectee in parallel= J\\n\", EE1\n", + "EE2=Ct*Vt**2/2\n", + "print\"Electrostatic energy after capacitors are connectee in parallel= J\",round( EE2,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_6 pgno:18" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Three capacitors have capacitances microF, microF ane microF\n", + "80.0 100.0 120.0\n", + "Voltage across the combination = V 50.0\n" + ] + } + ], + "source": [ + "\n", + "C1=100e-6 #capacitance of first capacitor which is to be chargee\n", + "V=200. #voltage across C1\n", + "Q=C1*V\n", + "#Let Q1, Q2, Q3, Q4 be the charges on respective capacitors after connection\n", + "Q2=4000e-6\n", + "Q3=5000e-6\n", + "Q4=6000e-6\n", + "Q1=Q-(Q2+Q3+Q4)\n", + "C2=C1*(Q2/Q1)\n", + "C3=C1*(Q3/Q1)\n", + "C4=C1*(Q4/Q1)\n", + "print\"Three capacitors have capacitances microF, microF ane microF\\n\", C2*10**6,C3*10**6,C4*10**6\n", + "Vt=Q1/C1\n", + "print\"Voltage across the combination = V\", Vt\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Gopi KrishnaManchukonda/Chapter8.ipynb b/sample_notebooks/Gopi KrishnaManchukonda/Chapter8.ipynb deleted file mode 100755 index c1c1744c..00000000 --- a/sample_notebooks/Gopi KrishnaManchukonda/Chapter8.ipynb +++ /dev/null @@ -1,286 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 8 - Thermal flow" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1 - pg 168" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)Final velocity of steam is (m/s) = 636.38\n", - "(b)Percentage reduction in velocity is (percent) = 6.19\n" - ] - } - ], - "source": [ - "#calculate the Final velocity and percentage reduction in velocity\n", - "#Input data\n", - "P1=12.;#Pressure of Dry saturated steam entering a steam nozzle in bar\n", - "P2=1.5;#Discharge pressure of Dry saturated steam in bar\n", - "f=0.95;#Dryness fraction of the discharged steam\n", - "l=12.;#Heat drop lost in friction in percentage\n", - "hg1=2784.8;#Specific enthalpy of steam at 12 bar from steam tables in kJ/kg\n", - "hg2=2582.3;#Specific enthalpy of 0.95 dry steam at 1.5 bar from steam tables in kJ/kg\n", - "\n", - "#Calculations\n", - "hd=hg1-hg2;#Heat drop in kJ/kg\n", - "V1=44.72*(hd)**(0.5);#Velocity of steam at discharge from the nozzle in m/s\n", - "n=1-(l/100.);#Nozzle coefficient when 12 percent heat drop is lost in friction\n", - "V2=44.72*(n*hd)**(0.5);#Velocity of steam in m/s\n", - "percentV=((V1-V2)/V1)*100;#Percentage reduction in velocity\n", - "\n", - "#Output\n", - "print '(a)Final velocity of steam is (m/s) = ',round(V1 ,2)\n", - "print '(b)Percentage reduction in velocity is (percent) = ',round(percentV,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2 - pg 174" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The mass of steam discharged,when the exit diameter of the nozzle is 12mm is (kg/hour) = 236.47\n" - ] - } - ], - "source": [ - "#calculate the mass of steam\n", - "#Input data\n", - "P1=12.;#Initial pressure of dry saturated steam expanded in a nozzle in bar\n", - "P2=0.95;#Final pressure of dry saturated steam expanded in a nozzle in bar\n", - "f=10.;#Frictional loss in the nozzle of the total heat drop in percentage\n", - "d=12.;#Exit diameter of the nozzle in mm\n", - "hd=437.1;#Heat drop in kJ/kg from steam tables\n", - "q=0.859;#Dryness fraction of steam at discharge pressure\n", - "vg=1.777;#Specific volume of dry saturated steam at 0.95 bar\n", - "\n", - "#Calculations\n", - "n=1-(f/100);#Nozzle coefficient from moiller chart\n", - "V2=44.72*(n*hd)**(0.5);#Velocity of steam at nozzle exit in m/s\n", - "A=(3.14/4)*(0.012)**(2);#Area of the nozzle at the exit in mm**2\n", - "m=((A*V2)/(q*vg))*3600;#Mass of steam discharged through the nozzle per hour in kg/hour\n", - "\n", - "#Output\n", - "print 'The mass of steam discharged,when the exit diameter of the nozzle is 12mm is (kg/hour) = ',round(m,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3 - pg 176" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)Throat area of steam nozzle is (cm^2) = 1.67\n", - "(b)Exit area of steam nozzle is (cm^2) = 2.016\n", - "(c)Exit velocity of the nozzle is (m/s) = 831.62\n" - ] - } - ], - "source": [ - "#calculate the throat area of steam and exit area,exit velocity\n", - "#Input data\n", - "P1=12.;#Inlet pressure of steam nozzle in bar\n", - "T1=250.;#Inlet temperature of steam nozzle in degrees celcius\n", - "P2=2.;#Final pressure of the steam nozzle in bar\n", - "n=1.3;#Polytropic constant for superheated steam\n", - "St=6.831;#For isentropic expansion, entropy remains constant in kJ/kg\n", - "h1=2935.4#Enthalpy of steam at P1 from steam table in kJ/kg\n", - "ht=2860.;#Enthalpy of steam at pt in kJ/kg\n", - "vt=0.325;#Specific volume of steam at the throat conditions in m**3/kg\n", - "m=0.2;#Mass of steam discharged through the nozzle in kg/hour\n", - "q=0.947;#The dryness fraction of steam at exit from steam tables\n", - "hg=2589.6;#Enthalpy of steam at exit in kJ/kg\n", - "vs=0.8854;#Specific volume of saturated steam in m**3/kg\n", - "\n", - "#Calculations\n", - "pt=(P2/(n+1))**(n/(n-1))*P1;#Critical pressure ratio i.e.,Throat pressure in bar\n", - "Vt=(2*1000*(h1-ht))**(0.5);#Velocity of steam at throat in m/s\n", - "At=((m*vt)/Vt)*10**4;#Area of the throat in cm**2 from continuity equation\n", - "ve=q*vs;#Specific volume of steam at exit in m**3/kg\n", - "Ve=(2*1000*(h1-hg))**(0.5);#Velocity of steam at nozzle exit in m/s\n", - "Ae=((m*ve)/Ve)*10**4;#Exit area in cm**2\n", - "\n", - "#Output\n", - "print '(a)Throat area of steam nozzle is (cm^2) = ',round(At,2)\n", - "print '(b)Exit area of steam nozzle is (cm^2) = ',round(Ae,3)\n", - "print '(c)Exit velocity of the nozzle is (m/s) = ',round(Ve,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4 - pg 177" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)Final exit velocity of steam is (m/s) = 785.246\n", - "(b)Cross sectional area of the nozzle at exit for maximum discharge is (mm^2) = 677.736\n" - ] - } - ], - "source": [ - "#calculate the Final exit velocity, Cross sectional area\n", - "#Input data\n", - "P1=10.;#Pressure of steam in bar\n", - "f=0.9;#Dryness fraction of steam\n", - "At=350.;#Throat area in mm**2\n", - "Pb=1.4;#Back pressure in bar\n", - "h1=2574.8;#Enthalpy of steam at nozzle inlet from steam tables in kJ/kg\n", - "ft=0.87;#Dryness fraction of steam at throat pressure\n", - "fe=0.81;#Dryness fraction of steam at exit pressure\n", - "ht=2481.;#Enthalpy of steam at throat pressure at ft in kJ/kg\n", - "vt=0.285;#Specific volume of steam at throat in m**3/kg\n", - "he=2266.2;#Enthalpy of steam at exit conditions in kJ/kg\n", - "ve=1.001;#Specific volume of steam at exit conditions in m**3/kg\n", - "\n", - "#Calculations\n", - "Pt=0.582*P1;#Steam pressure at the throat in bar\n", - "hd=h1-ht;#Enthalpy drop upto the throat in kJ/kg\n", - "Vt=44.7*(hd)**(0.5);#Velocity of steam at the throat in m/s\n", - "hde=h1-he;#Enthalpy drop from nozzle entrance to exit in kJ/kg\n", - "Ve=44.7*(hde)**(0.5);#Velocity of steam at nozzle exit in m/s\n", - "Ae=(At*Vt*ve)/(Ve*vt);#Exit area of nozzle from the mass rate of flow equation in mm**2\n", - "\n", - "#Output\n", - "print '(a)Final exit velocity of steam is (m/s) = ',round(Ve,3)\n", - "print '(b)Cross sectional area of the nozzle at exit for maximum discharge is (mm^2) = ',round(Ae,3)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5 - pg 192" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)Velocity of steam at throat is (m/s) = 530.78\n", - "(b)Temperature of steam at the throat is (degrees celcius) = 202.8\n", - "(c)Cone angle of the divergent portion is (degrees) = 2.134\n" - ] - } - ], - "source": [ - "#calculate the Velocity of steam at throat, temperature and cone angle\n", - "#Input data\n", - "import math\n", - "P1=7.;#Inlet pressure of a convergent divergent steam nozzle in bar\n", - "T1=275.;#Inlet temperature of the nozzle in degrees celcius\n", - "P2=1.;#Discharge pressure of steam in bar\n", - "l=60.;#Length of diverging portion of the nozzle in mm\n", - "dt=6.;#Diameter of the throat in mm\n", - "f1=10.;#Percent of total available enthalpy drop lost in friction in the diverging portion in percentage\n", - "h1=3006.9;#Enthalpy of steam at 7bar pressure and 275 degrees celcius in kJ/kg\n", - "ht=2865.9;#Enthalpy at the throat from Moiller chart in kJ/kg\n", - "he=2616.7;#Enthalpy at the exit from moiller chart in kJ/kg\n", - "vt=0.555;#Specific volume of steam at throat in m**3/kg\n", - "Tt=202.8;#Temperature of steam at throat in degrees celcius from moiller chart\n", - "ve=1.65;#Volume of steam at exit in m**3/kg\n", - "\n", - "#Calculations\n", - "Pt=0.546*P1;#The throat pressure for maximum discharge in bar\n", - "hd=h1-ht;#Enthalpy drop upto throat in kJ/kg\n", - "Vt=44.7*(hd)**(0.5);#Velocity of steam at throat in m/s\n", - "hid=h1-he;#Total isentropic drop from 7 bar,275 degrees celcius to 1 bar in kJ/kg\n", - "hda=(1-(f1/100.))*(hid);#Actual heat drop in kJ/kg\n", - "Ve=44.7*(hda)**(0.5);#Velocity at exit in m/s\n", - "At=(3.14/4)*(6./1000)**(2);#Throat area of the nozzle in m**2\n", - "m=(At*Vt)/vt;#Mass flow rate at nozzle throat in kg/s\n", - "Ae=((m*ve)/Ve)*10**4;#Exit area of the nozzle in cm**2\n", - "de=(((Ae*4)/3.14)**(0.5))*10;#Diameter of the nozzle at exit in mm\n", - "alpha=math.atan((de-dt)/(2*60))*180/math.pi;#Half of the cone angle of the nozzle in degrees\n", - "alpha1=2*alpha;#Cone angle of the nozzle in degrees\n", - "\n", - "#Output\n", - "print '(a)Velocity of steam at throat is (m/s) = ',round(Vt,2)\n", - "print '(b)Temperature of steam at the throat is (degrees celcius) =',Tt\n", - "print '(c)Cone angle of the divergent portion is (degrees) =',round(alpha1,3)\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Gopi KrishnaManchukonda/Chapter_2_Electrostatics_.ipynb b/sample_notebooks/Gopi KrishnaManchukonda/Chapter_2_Electrostatics_.ipynb deleted file mode 100755 index 8ece860c..00000000 --- a/sample_notebooks/Gopi KrishnaManchukonda/Chapter_2_Electrostatics_.ipynb +++ /dev/null @@ -1,281 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Electrostatics " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_1 pgno:13" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Resultant force acting on charge at C= N 12.72\n" - ] - } - ], - "source": [ - "from math import pi,sqrt,cos,sin\n", - "\n", - "epsilon=8.854e-12\n", - "r=sqrt(.1**2+.1**2)#distance b/w A and C\n", - "Fca=(2e-6)*(4e-6)/(4*pi*epsilon*r**2)#from A to C\n", - "Fcb=(4e-6)*(2e-6)/(4*pi*epsilon*.1**2)#from C to B\n", - "Fcd=(4e-6)*(4e-6)/(4*pi*epsilon*.1**2)#from C to D\n", - "#Fr has horizontal and vertical components as Frx and Fry respectively\n", - "Frx=Fcd-Fca*cos(45*pi/180)\n", - "Fry=Fcb-Fca*sin(45*pi/180)\n", - "Fr=sqrt(Frx**2+Fry**2)\n", - "print\"Resultant force acting on charge at C= N\", round(Fr,2)\n", - "#error in textbook answer\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_ pgno:15" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Resultant intensity on charge at C=*10**4 N/C at angle eegrees 25.44 37.0\n" - ] - } - ], - "source": [ - "from math import pi,cos,sin,sqrt,atan\n", - "epsilon=8.854e-12\n", - "E1=(4e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at A,eirection is from e to A\n", - "r=sqrt(2*.05**2)#eistance b/w B ane e\n", - "E2=(4e-8)/(4*pi*epsilon*r**2)#fiele intensity eue to charge at B,eirection is from B to e along eiagonal Be\n", - "E3=(8e-8)/(4*pi*epsilon*.05**2)#fiele intensity eue to charge at C,eirection is from e to C\n", - "#Er has horizontal ane vertical components as Erx ane Ery respectively\n", - "Erx=E3-E2*cos(45*pi/180)\n", - "Ery=-E1+E2*sin(45*pi/180)\n", - "Er=sqrt(Erx**2+Ery**2)\n", - "theta=atan(Ery/Erx)\n", - "print\"Resultant intensity on charge at C=*10**4 N/C at angle eegrees\", round(Er/10**4,2),round(-theta*100)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_3 pgno:15" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Potential at A eue to charges at B, C ane e= V 3.73\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "epsilon=8.854e-12\n", - "AB=.05\n", - "BC=.07\n", - "AC=sqrt(.05**2+.07**2)\n", - "V1=2e-10/(4*pi*epsilon*.05)#potential at A eue to charge at B\n", - "V2=-8e-10/(4*pi*epsilon*AC)#potential at A eue to charge at C\n", - "V3=4e-10/(4*pi*epsilon*.07)#potential at A eue to charge at e\n", - "V=V1+V2+V3 \n", - "print\"Potential at A eue to charges at B, C ane e= V\", round(V,2)\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_4 pgno:16" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time constant T= sec\n", - "0.015\n", - "Initial current= A\n", - "0.2\n", - "Charge on the capacitor after 0.05 sec is C\n", - "0.003\n", - "Charging current after 0.05 sec is A\n", - "0.007\n", - "Charging current after 0.015 sec is A\n", - "0.074\n", - "Voltage across 500 ohm resistor after 0.05 sec is V 3.567\n" - ] - } - ], - "source": [ - "from math import exp\n", - "C=30e-6\n", - "R=500.\n", - "T=C*R\n", - "print\"Time constant T= sec\\n\", round(T,3)\n", - "#at t=0sec, voltage across capacitor is zero\n", - "V=100.#apliee voltage\n", - "I=V/R#Ohm's Law\n", - "print\"Initial current= A\\n\", round(I,3)\n", - "t=.05\n", - "Q=C*V\n", - "q=Q*(1-exp(-t/T))\n", - "print\"Charge on the capacitor after 0.05 sec is C\\n\", round(q,3)\n", - "i1=I*exp(-t/T)\n", - "print\"Charging current after 0.05 sec is A\\n\",round(i1,3)\n", - "t=.015\n", - "i2=I*exp(-t/T)\n", - "print\"Charging current after 0.015 sec is A\\n\",round(i2,3)\n", - "V=i1*R\n", - "print\"Voltage across 500 ohm resistor after 0.05 sec is V\", round(V,3)\n", - "#answers vary from the textbook eue to roune off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_5 pgno:17" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "P.e. across the combination = V\n", - "133.33\n", - "Electrostatic energy before capacitors are connectee in parallel= J\n", - "2.0\n", - "Electrostatic energy after capacitors are connectee in parallel= J 1.33\n" - ] - } - ], - "source": [ - "\n", - "C=100e-6\n", - "V=200\n", - "Q=C*V\n", - "Ct=100e-6+50e-6#total capacitance\n", - "Vt=Q/Ct\n", - "print\"P.e. across the combination = V\\n\", round(Vt,2)\n", - "EE1=100e-6*V**2/2\n", - "print\"Electrostatic energy before capacitors are connectee in parallel= J\\n\", EE1\n", - "EE2=Ct*Vt**2/2\n", - "print\"Electrostatic energy after capacitors are connectee in parallel= J\",round( EE2,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_6 pgno:18" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Three capacitors have capacitances microF, microF ane microF\n", - "80.0 100.0 120.0\n", - "Voltage across the combination = V 50.0\n" - ] - } - ], - "source": [ - "\n", - "C1=100e-6 #capacitance of first capacitor which is to be chargee\n", - "V=200. #voltage across C1\n", - "Q=C1*V\n", - "#Let Q1, Q2, Q3, Q4 be the charges on respective capacitors after connection\n", - "Q2=4000e-6\n", - "Q3=5000e-6\n", - "Q4=6000e-6\n", - "Q1=Q-(Q2+Q3+Q4)\n", - "C2=C1*(Q2/Q1)\n", - "C3=C1*(Q3/Q1)\n", - "C4=C1*(Q4/Q1)\n", - "print\"Three capacitors have capacitances microF, microF ane microF\\n\", C2*10**6,C3*10**6,C4*10**6\n", - "Vt=Q1/C1\n", - "print\"Voltage across the combination = V\", Vt\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Gopi KrishnaManchukonda/Gopi KrishnaManchukonda_version_backup/Chapter8.ipynb b/sample_notebooks/Gopi KrishnaManchukonda/Gopi KrishnaManchukonda_version_backup/Chapter8.ipynb new file mode 100755 index 00000000..c1c1744c --- /dev/null +++ b/sample_notebooks/Gopi KrishnaManchukonda/Gopi KrishnaManchukonda_version_backup/Chapter8.ipynb @@ -0,0 +1,286 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 8 - Thermal flow" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1 - pg 168" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Final velocity of steam is (m/s) = 636.38\n", + "(b)Percentage reduction in velocity is (percent) = 6.19\n" + ] + } + ], + "source": [ + "#calculate the Final velocity and percentage reduction in velocity\n", + "#Input data\n", + "P1=12.;#Pressure of Dry saturated steam entering a steam nozzle in bar\n", + "P2=1.5;#Discharge pressure of Dry saturated steam in bar\n", + "f=0.95;#Dryness fraction of the discharged steam\n", + "l=12.;#Heat drop lost in friction in percentage\n", + "hg1=2784.8;#Specific enthalpy of steam at 12 bar from steam tables in kJ/kg\n", + "hg2=2582.3;#Specific enthalpy of 0.95 dry steam at 1.5 bar from steam tables in kJ/kg\n", + "\n", + "#Calculations\n", + "hd=hg1-hg2;#Heat drop in kJ/kg\n", + "V1=44.72*(hd)**(0.5);#Velocity of steam at discharge from the nozzle in m/s\n", + "n=1-(l/100.);#Nozzle coefficient when 12 percent heat drop is lost in friction\n", + "V2=44.72*(n*hd)**(0.5);#Velocity of steam in m/s\n", + "percentV=((V1-V2)/V1)*100;#Percentage reduction in velocity\n", + "\n", + "#Output\n", + "print '(a)Final velocity of steam is (m/s) = ',round(V1 ,2)\n", + "print '(b)Percentage reduction in velocity is (percent) = ',round(percentV,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2 - pg 174" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The mass of steam discharged,when the exit diameter of the nozzle is 12mm is (kg/hour) = 236.47\n" + ] + } + ], + "source": [ + "#calculate the mass of steam\n", + "#Input data\n", + "P1=12.;#Initial pressure of dry saturated steam expanded in a nozzle in bar\n", + "P2=0.95;#Final pressure of dry saturated steam expanded in a nozzle in bar\n", + "f=10.;#Frictional loss in the nozzle of the total heat drop in percentage\n", + "d=12.;#Exit diameter of the nozzle in mm\n", + "hd=437.1;#Heat drop in kJ/kg from steam tables\n", + "q=0.859;#Dryness fraction of steam at discharge pressure\n", + "vg=1.777;#Specific volume of dry saturated steam at 0.95 bar\n", + "\n", + "#Calculations\n", + "n=1-(f/100);#Nozzle coefficient from moiller chart\n", + "V2=44.72*(n*hd)**(0.5);#Velocity of steam at nozzle exit in m/s\n", + "A=(3.14/4)*(0.012)**(2);#Area of the nozzle at the exit in mm**2\n", + "m=((A*V2)/(q*vg))*3600;#Mass of steam discharged through the nozzle per hour in kg/hour\n", + "\n", + "#Output\n", + "print 'The mass of steam discharged,when the exit diameter of the nozzle is 12mm is (kg/hour) = ',round(m,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3 - pg 176" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Throat area of steam nozzle is (cm^2) = 1.67\n", + "(b)Exit area of steam nozzle is (cm^2) = 2.016\n", + "(c)Exit velocity of the nozzle is (m/s) = 831.62\n" + ] + } + ], + "source": [ + "#calculate the throat area of steam and exit area,exit velocity\n", + "#Input data\n", + "P1=12.;#Inlet pressure of steam nozzle in bar\n", + "T1=250.;#Inlet temperature of steam nozzle in degrees celcius\n", + "P2=2.;#Final pressure of the steam nozzle in bar\n", + "n=1.3;#Polytropic constant for superheated steam\n", + "St=6.831;#For isentropic expansion, entropy remains constant in kJ/kg\n", + "h1=2935.4#Enthalpy of steam at P1 from steam table in kJ/kg\n", + "ht=2860.;#Enthalpy of steam at pt in kJ/kg\n", + "vt=0.325;#Specific volume of steam at the throat conditions in m**3/kg\n", + "m=0.2;#Mass of steam discharged through the nozzle in kg/hour\n", + "q=0.947;#The dryness fraction of steam at exit from steam tables\n", + "hg=2589.6;#Enthalpy of steam at exit in kJ/kg\n", + "vs=0.8854;#Specific volume of saturated steam in m**3/kg\n", + "\n", + "#Calculations\n", + "pt=(P2/(n+1))**(n/(n-1))*P1;#Critical pressure ratio i.e.,Throat pressure in bar\n", + "Vt=(2*1000*(h1-ht))**(0.5);#Velocity of steam at throat in m/s\n", + "At=((m*vt)/Vt)*10**4;#Area of the throat in cm**2 from continuity equation\n", + "ve=q*vs;#Specific volume of steam at exit in m**3/kg\n", + "Ve=(2*1000*(h1-hg))**(0.5);#Velocity of steam at nozzle exit in m/s\n", + "Ae=((m*ve)/Ve)*10**4;#Exit area in cm**2\n", + "\n", + "#Output\n", + "print '(a)Throat area of steam nozzle is (cm^2) = ',round(At,2)\n", + "print '(b)Exit area of steam nozzle is (cm^2) = ',round(Ae,3)\n", + "print '(c)Exit velocity of the nozzle is (m/s) = ',round(Ve,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4 - pg 177" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Final exit velocity of steam is (m/s) = 785.246\n", + "(b)Cross sectional area of the nozzle at exit for maximum discharge is (mm^2) = 677.736\n" + ] + } + ], + "source": [ + "#calculate the Final exit velocity, Cross sectional area\n", + "#Input data\n", + "P1=10.;#Pressure of steam in bar\n", + "f=0.9;#Dryness fraction of steam\n", + "At=350.;#Throat area in mm**2\n", + "Pb=1.4;#Back pressure in bar\n", + "h1=2574.8;#Enthalpy of steam at nozzle inlet from steam tables in kJ/kg\n", + "ft=0.87;#Dryness fraction of steam at throat pressure\n", + "fe=0.81;#Dryness fraction of steam at exit pressure\n", + "ht=2481.;#Enthalpy of steam at throat pressure at ft in kJ/kg\n", + "vt=0.285;#Specific volume of steam at throat in m**3/kg\n", + "he=2266.2;#Enthalpy of steam at exit conditions in kJ/kg\n", + "ve=1.001;#Specific volume of steam at exit conditions in m**3/kg\n", + "\n", + "#Calculations\n", + "Pt=0.582*P1;#Steam pressure at the throat in bar\n", + "hd=h1-ht;#Enthalpy drop upto the throat in kJ/kg\n", + "Vt=44.7*(hd)**(0.5);#Velocity of steam at the throat in m/s\n", + "hde=h1-he;#Enthalpy drop from nozzle entrance to exit in kJ/kg\n", + "Ve=44.7*(hde)**(0.5);#Velocity of steam at nozzle exit in m/s\n", + "Ae=(At*Vt*ve)/(Ve*vt);#Exit area of nozzle from the mass rate of flow equation in mm**2\n", + "\n", + "#Output\n", + "print '(a)Final exit velocity of steam is (m/s) = ',round(Ve,3)\n", + "print '(b)Cross sectional area of the nozzle at exit for maximum discharge is (mm^2) = ',round(Ae,3)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5 - pg 192" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Velocity of steam at throat is (m/s) = 530.78\n", + "(b)Temperature of steam at the throat is (degrees celcius) = 202.8\n", + "(c)Cone angle of the divergent portion is (degrees) = 2.134\n" + ] + } + ], + "source": [ + "#calculate the Velocity of steam at throat, temperature and cone angle\n", + "#Input data\n", + "import math\n", + "P1=7.;#Inlet pressure of a convergent divergent steam nozzle in bar\n", + "T1=275.;#Inlet temperature of the nozzle in degrees celcius\n", + "P2=1.;#Discharge pressure of steam in bar\n", + "l=60.;#Length of diverging portion of the nozzle in mm\n", + "dt=6.;#Diameter of the throat in mm\n", + "f1=10.;#Percent of total available enthalpy drop lost in friction in the diverging portion in percentage\n", + "h1=3006.9;#Enthalpy of steam at 7bar pressure and 275 degrees celcius in kJ/kg\n", + "ht=2865.9;#Enthalpy at the throat from Moiller chart in kJ/kg\n", + "he=2616.7;#Enthalpy at the exit from moiller chart in kJ/kg\n", + "vt=0.555;#Specific volume of steam at throat in m**3/kg\n", + "Tt=202.8;#Temperature of steam at throat in degrees celcius from moiller chart\n", + "ve=1.65;#Volume of steam at exit in m**3/kg\n", + "\n", + "#Calculations\n", + "Pt=0.546*P1;#The throat pressure for maximum discharge in bar\n", + "hd=h1-ht;#Enthalpy drop upto throat in kJ/kg\n", + "Vt=44.7*(hd)**(0.5);#Velocity of steam at throat in m/s\n", + "hid=h1-he;#Total isentropic drop from 7 bar,275 degrees celcius to 1 bar in kJ/kg\n", + "hda=(1-(f1/100.))*(hid);#Actual heat drop in kJ/kg\n", + "Ve=44.7*(hda)**(0.5);#Velocity at exit in m/s\n", + "At=(3.14/4)*(6./1000)**(2);#Throat area of the nozzle in m**2\n", + "m=(At*Vt)/vt;#Mass flow rate at nozzle throat in kg/s\n", + "Ae=((m*ve)/Ve)*10**4;#Exit area of the nozzle in cm**2\n", + "de=(((Ae*4)/3.14)**(0.5))*10;#Diameter of the nozzle at exit in mm\n", + "alpha=math.atan((de-dt)/(2*60))*180/math.pi;#Half of the cone angle of the nozzle in degrees\n", + "alpha1=2*alpha;#Cone angle of the nozzle in degrees\n", + "\n", + "#Output\n", + "print '(a)Velocity of steam at throat is (m/s) = ',round(Vt,2)\n", + "print '(b)Temperature of steam at the throat is (degrees celcius) =',Tt\n", + "print '(c)Cone angle of the divergent portion is (degrees) =',round(alpha1,3)\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/GudePrithvi/Chapter_3.ipynb b/sample_notebooks/GudePrithvi/Chapter_3.ipynb deleted file mode 100755 index f808f1b3..00000000 --- a/sample_notebooks/GudePrithvi/Chapter_3.ipynb +++ /dev/null @@ -1,536 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:f3be7a31a0f3d765e50f86fbfff2be30e114da24ff9eb4121f1f8157ce8ea60f" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 3: Transmission Lines" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 3.1, Page number 47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Terminating impedance\n", - "#Variable declaration\n", - "Zo = 100 #o/p impedance(Ohms)\n", - "s = 5 #VSWR\n", - "\n", - "#Calculations\n", - "Zmax = Zo*s\n", - "\n", - "#Results\n", - "print \"Terminating impedance = \",Zmax,\"Ohms\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Terminating impedance = 500 Ohms\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.2, Page number 47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Characteristic impedance,Attenuation constant,Phase constant,Power delivered to the load\n", - "import math\n", - "import cmath\n", - "\n", - "#Varaible declaration \n", - "R = 8 #resistance(Ohms)\n", - "L = 2*10**-3 #inductance(H/km)\n", - "C = 0.002*10**-6 #capacitance(F)\n", - "G = 0.07*10**-6 #conductance(s/km)\n", - "f = 2*10**3 #frequency(Hz)\n", - "Vs = 2 #input signal(V)\n", - "l = 500. #line length(km)\n", - "\n", - "#Calculations\n", - "w = 2*math.pi*f\n", - "x = complex(R,w*L)\n", - "y = complex(G,w*C)\n", - "Zo = cmath.sqrt(x/y)\n", - "gamma = cmath.sqrt(x*y)\n", - "Is = Vs/Zo.real\n", - "Il = Is*cmath.exp(-1*gamma*l)\n", - "P = Il**2*Zo.real\n", - "\n", - "#Results\n", - "print \"Characteristic impedance =\",Zo,\"Ohms\"\n", - "print \"Attenuation constant =\",round(gamma.real,6),\"NP/km\"\n", - "print \"Phase constant =\", round(gamma.imag,6),\"rad/km\"\n", - "print \"\\ncalculation error in the textbook\"\n", - "print \"\\nPower delivered to the load =\", round((abs(P)/1E-6),1), \"uW\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Characteristic impedance = (1012.50018135-155.813417548j) Ohms\n", - "Attenuation constant = 0.003987 NP/km\n", - "Phase constant = 0.025436 rad/km\n", - "\n", - "calculation error in the textbook\n", - "\n", - "Power delivered to the load = 73.3 uW\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.3, Page number 48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Phase velocity\n", - "import math\n", - "\n", - "#Varaible declaration\n", - "f = 2*10**3 #frequency(Hz)\n", - "B = 0.02543 #phase constant(rad/km)\n", - "\n", - "#Calculations\n", - "w = 2*math.pi*f\n", - "Vp = w/B\n", - "\n", - "#Results\n", - "print \"Phase velocity =\",round((Vp/1E+3),2),\"km/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Phase velocity = 494.16 km/sec\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.4, Page number 48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Current drawn from generator,Power delivered to the load,Current flowing through the load\n", - "\n", - "import cmath\n", - "import math\n", - "\n", - "#Variable declaration\n", - "f = 37.5*10**6 #frequency(Hz)\n", - "V = 200 #Voltage signal(Vrms)\n", - "r = 200 #internal resistance(Ohms)\n", - "Zo = 200 #characteristic impedance(Ohms)\n", - "l = 10 #line length(m)\n", - "Zl = 100 #resistive load(Ohms)\n", - "c = 3*10**8 #velocity of propagation(m/s)\n", - "\n", - "#Calculations\n", - "#Part a\n", - "lamda = c/f\n", - "Bl = (5*math.degrees(math.pi))/4\n", - "x = complex(Zl,(Zo*math.tan(Bl)))\n", - "y = complex(Zo,(Zl*math.tan(Bl)))\n", - "Zi = Zo*(x/y)\n", - "Vs = (Zi.real*Zo)/(Zi.real+Zo)\n", - "Is = Zo/(Zi.real+Zo)\n", - "\n", - "#Part b\n", - "P = Vs*Is\n", - "\n", - "#Part c\n", - "Il = math.sqrt(P/Zl)\n", - "\n", - "#Results\n", - "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", - "print \"Current drawn from generator is\",round(Is,3),\"A\" \n", - "print \"Power delivered to the load is\",round(P,2),\"W\"\n", - "print \"Current flowing through the load is\",round(Il,3),\"A\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", - "\n", - "Current drawn from generator is 0.41 A\n", - "Power delivered to the load is 48.47 W\n", - "Current flowing through the load is 0.696 A\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.5, Page number 50" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Reflection co-efficient, VSWR\n", - "import cmath\n", - "import math\n", - "\n", - "#Variable declaration\n", - "zo = 50 #characteristic impedance(Ohms)\n", - "f = 300*10**6 #frequency(Hz)\n", - "zl = complex(50,50) #terminating load(Ohms)\n", - "c = 3*10**8 #velocity of propagation(m/s)\n", - "\n", - "#Calculations\n", - "lamda = c/f\n", - "rho = (zl-zo)/(zl+zo)\n", - "phi = cmath.phase(rho)\n", - "s = (1+abs(rho))/(1-abs(rho))\n", - "\n", - "#Results\n", - "print \"Reflection co-efficient =\",round(abs(rho),4),\"with phase =\",round(math.degrees(phi),1)\n", - "print \"VSWR =\",round(s,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Reflection co-efficient = 0.4472 with phase = 63.4\n", - "VSWR = 2.62\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.6, Page number 50" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate position of the stub,Length of stub \n", - "import math\n", - "\n", - "#Variable declaration\n", - "Zl = 100. #load resistance(Ohms)\n", - "Zo = 600. #characteristic impedance(Ohms)\n", - "f = 100*10**6 #frequency(Hz)\n", - "c = 3*10**8 #velocity of propagation(m/s)\n", - "\n", - "#Calculations\n", - "lamda = c/f\n", - "l = (lamda*math.atan(math.sqrt(Zl/Zo)))/(2*math.pi)\n", - "l_dash = (lamda*math.atan(math.sqrt((Zl*Zo)/(Zo-Zl))))/(2*math.pi)\n", - "\n", - "#Results\n", - "print \"The position of the stub is\", round(l,3),\"m\\n\"\n", - "print \"Please note that the solution for l_dash given in the textbook is incorrect\"\n", - "print \"Length of stub is\",round(l_dash,3),\"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The position of the stub is 0.185 m\n", - "\n", - "Please note that the solution for l_dash given in the textbook is incorrect\n", - "Length of stub is 0.707 m\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.7, Page number 50" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Terminating impedance\n", - "import cmath\n", - "import math\n", - "\n", - "#Variable declaration\n", - "s = 3.2 #VSWR\n", - "Xmin = 0.237 #minimum voltage(V)\n", - "Zo = 50 #characteristic impedance(Ohms)\n", - "\n", - "#Calculations\n", - "q = math.tan(math.degrees(2*math.pi*Xmin))\n", - "x = complex(1,-(s*q))\n", - "y = complex(s, -q)\n", - "Zl = Zo*(x/y)\n", - "\n", - "#Result\n", - "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", - "print \"Terminating impedance =\", Zl,\"Ohms\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", - "\n", - "Terminating impedance = (19.6572514629-23.7885950214j) Ohms\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.8, Page number 51" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate VSWR,First Vmax is loacted at load and first Vmin is located at,Vmin,Impedance at Vmin\n", - "import math\n", - "\n", - "#Variable declaration\n", - "Zo = 50. #characteristic impedance(Ohms)\n", - "Zl = 100. #load resistance(Ohms)\n", - "f = 300*10**3 #frequency(Hz)\n", - "Pl = 50*10**-3 #load power(W)\n", - "c = 3*10**8 #velocity of propagation(m/s)\n", - "\n", - "#Calculations\n", - "lamda = c/f\n", - "\n", - "#Part a\n", - "rho = (Zl-Zo)/(Zl+Zo)\n", - "s = (1+abs(rho))/(1-abs(rho))\n", - "\n", - "#Part b\n", - "#Since real Zl>Zo, first Vmax is located at the load\n", - "Vmin_pos = lamda/4\n", - "\n", - "#Part c\n", - "Vmax = math.sqrt(Pl*Zl)\n", - "Vmin = Vmax/s\n", - "\n", - "#Part d\n", - "Zin_at_Vmin = Zo/s\n", - "Zin_at_Vmax = Zo*s\n", - "\n", - "#Results\n", - "print \"VSWR = \", s\n", - "print \"First Vmax is loacted at load and first Vmin is located at=\", Vmin_pos,\"m from the load\"\n", - "print \"Vmax = \",round(Vmax,2),\"V\",\"\\nVmin = \",round(Vmin,2),\"V\"\n", - "print \"Impedance at Vmin is \", Zin_at_Vmin,\"Ohm and impedance at Vmax is\",Zin_at_Vmax,\"Ohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "VSWR = 2.0\n", - "First Vmax is loacted at load and first Vmin is located at= 250 m from the load\n", - "Vmax = 2.24 V \n", - "Vmin = 1.12 V\n", - "Impedance at Vmin is 25.0 Ohm and impedance at Vmax is 100.0 Ohm\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.9, Page number 52" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Reflection loss, transmission loss, return loss\n", - "\n", - "import math\n", - "\n", - "#Variable declaration\n", - "Zo = 600. #characteristic impedance(Ohms)\n", - "Zs = 50 #source impedance(Ohms)\n", - "l = 200 #length of line(m)\n", - "Zl = 500. #load resistance(Ohms)\n", - "\n", - "#Calculations\n", - "rho = (Zl-Zo)/(Zl+Zo)\n", - "\n", - "#Part a\n", - "ref_l = math.log10(1/(1-((abs(rho))**2)))\n", - "\n", - "#Part b\n", - "#Since, the line is lossless,\n", - "att_l = 0\n", - "trans_l = ref_l+att_l\n", - "\n", - "#Part c\n", - "ret_l = math.log10(abs(rho))\n", - "\n", - "#Results\n", - "print \"Reflection loss =\",round(ref_l,4),\"dB\"\n", - "print \"Transmission loss =\",round(trans_l,4),\"dB\"\n", - "print \"Return loss =\",round(ret_l,3),\"dB (Calculation error in the textbook)\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Reflection loss = 0.0036 dB\n", - "Transmission loss = 0.0036 dB\n", - "Return loss = -1.041 dB (Calculation error in the textbook)\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.10, Page number 52" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#calculate Characteristic impedance,Phase velocity \n", - "\n", - "import cmath\n", - "import math\n", - "\n", - "#Variable declaration\n", - "l = 10 #length of line(km)\n", - "zsc = complex(1895.47,2234.29) \n", - "zoc = complex(216.99,-143.37)\n", - "f = 1*10**3 #frequency(Hz)\n", - "\n", - "#Calculations\n", - "zo = cmath.sqrt(zsc*zoc)\n", - "x = cmath.sqrt(zsc/zoc)\n", - "t = (1+x)/(1-x)\n", - "gamma = cmath.log(t)/(l*2)\n", - "B = gamma.imag\n", - "w = 2*math.pi*f\n", - "Vp = w/B\n", - "\n", - "#Results\n", - "print \"There is calculation mistake throughout the problem in the textbook\\n\"\n", - "print \"Characteristic impedance =\",zo,\"Ohms\"\n", - "print \"Phase velocity =\",round((Vp/1E+3),3),\"*10^3 m/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "There is calculation mistake throughout the problem in the textbook\n", - "\n", - "Characteristic impedance = (864.190238563+123.274392427j) Ohms\n", - "Phase velocity = 45.994 *10^3 m/sec\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/GudePrithvi/GudePrithvi_version_backup/Chapter_3.ipynb b/sample_notebooks/GudePrithvi/GudePrithvi_version_backup/Chapter_3.ipynb new file mode 100755 index 00000000..f808f1b3 --- /dev/null +++ b/sample_notebooks/GudePrithvi/GudePrithvi_version_backup/Chapter_3.ipynb @@ -0,0 +1,536 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:f3be7a31a0f3d765e50f86fbfff2be30e114da24ff9eb4121f1f8157ce8ea60f" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3: Transmission Lines" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example number 3.1, Page number 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Terminating impedance\n", + "#Variable declaration\n", + "Zo = 100 #o/p impedance(Ohms)\n", + "s = 5 #VSWR\n", + "\n", + "#Calculations\n", + "Zmax = Zo*s\n", + "\n", + "#Results\n", + "print \"Terminating impedance = \",Zmax,\"Ohms\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Terminating impedance = 500 Ohms\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.2, Page number 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Characteristic impedance,Attenuation constant,Phase constant,Power delivered to the load\n", + "import math\n", + "import cmath\n", + "\n", + "#Varaible declaration \n", + "R = 8 #resistance(Ohms)\n", + "L = 2*10**-3 #inductance(H/km)\n", + "C = 0.002*10**-6 #capacitance(F)\n", + "G = 0.07*10**-6 #conductance(s/km)\n", + "f = 2*10**3 #frequency(Hz)\n", + "Vs = 2 #input signal(V)\n", + "l = 500. #line length(km)\n", + "\n", + "#Calculations\n", + "w = 2*math.pi*f\n", + "x = complex(R,w*L)\n", + "y = complex(G,w*C)\n", + "Zo = cmath.sqrt(x/y)\n", + "gamma = cmath.sqrt(x*y)\n", + "Is = Vs/Zo.real\n", + "Il = Is*cmath.exp(-1*gamma*l)\n", + "P = Il**2*Zo.real\n", + "\n", + "#Results\n", + "print \"Characteristic impedance =\",Zo,\"Ohms\"\n", + "print \"Attenuation constant =\",round(gamma.real,6),\"NP/km\"\n", + "print \"Phase constant =\", round(gamma.imag,6),\"rad/km\"\n", + "print \"\\ncalculation error in the textbook\"\n", + "print \"\\nPower delivered to the load =\", round((abs(P)/1E-6),1), \"uW\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Characteristic impedance = (1012.50018135-155.813417548j) Ohms\n", + "Attenuation constant = 0.003987 NP/km\n", + "Phase constant = 0.025436 rad/km\n", + "\n", + "calculation error in the textbook\n", + "\n", + "Power delivered to the load = 73.3 uW\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.3, Page number 48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Phase velocity\n", + "import math\n", + "\n", + "#Varaible declaration\n", + "f = 2*10**3 #frequency(Hz)\n", + "B = 0.02543 #phase constant(rad/km)\n", + "\n", + "#Calculations\n", + "w = 2*math.pi*f\n", + "Vp = w/B\n", + "\n", + "#Results\n", + "print \"Phase velocity =\",round((Vp/1E+3),2),\"km/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Phase velocity = 494.16 km/sec\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.4, Page number 48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Current drawn from generator,Power delivered to the load,Current flowing through the load\n", + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "f = 37.5*10**6 #frequency(Hz)\n", + "V = 200 #Voltage signal(Vrms)\n", + "r = 200 #internal resistance(Ohms)\n", + "Zo = 200 #characteristic impedance(Ohms)\n", + "l = 10 #line length(m)\n", + "Zl = 100 #resistive load(Ohms)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "#Part a\n", + "lamda = c/f\n", + "Bl = (5*math.degrees(math.pi))/4\n", + "x = complex(Zl,(Zo*math.tan(Bl)))\n", + "y = complex(Zo,(Zl*math.tan(Bl)))\n", + "Zi = Zo*(x/y)\n", + "Vs = (Zi.real*Zo)/(Zi.real+Zo)\n", + "Is = Zo/(Zi.real+Zo)\n", + "\n", + "#Part b\n", + "P = Vs*Is\n", + "\n", + "#Part c\n", + "Il = math.sqrt(P/Zl)\n", + "\n", + "#Results\n", + "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", + "print \"Current drawn from generator is\",round(Is,3),\"A\" \n", + "print \"Power delivered to the load is\",round(P,2),\"W\"\n", + "print \"Current flowing through the load is\",round(Il,3),\"A\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", + "\n", + "Current drawn from generator is 0.41 A\n", + "Power delivered to the load is 48.47 W\n", + "Current flowing through the load is 0.696 A\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.5, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Reflection co-efficient, VSWR\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "zo = 50 #characteristic impedance(Ohms)\n", + "f = 300*10**6 #frequency(Hz)\n", + "zl = complex(50,50) #terminating load(Ohms)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "rho = (zl-zo)/(zl+zo)\n", + "phi = cmath.phase(rho)\n", + "s = (1+abs(rho))/(1-abs(rho))\n", + "\n", + "#Results\n", + "print \"Reflection co-efficient =\",round(abs(rho),4),\"with phase =\",round(math.degrees(phi),1)\n", + "print \"VSWR =\",round(s,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reflection co-efficient = 0.4472 with phase = 63.4\n", + "VSWR = 2.62\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.6, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate position of the stub,Length of stub \n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zl = 100. #load resistance(Ohms)\n", + "Zo = 600. #characteristic impedance(Ohms)\n", + "f = 100*10**6 #frequency(Hz)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "l = (lamda*math.atan(math.sqrt(Zl/Zo)))/(2*math.pi)\n", + "l_dash = (lamda*math.atan(math.sqrt((Zl*Zo)/(Zo-Zl))))/(2*math.pi)\n", + "\n", + "#Results\n", + "print \"The position of the stub is\", round(l,3),\"m\\n\"\n", + "print \"Please note that the solution for l_dash given in the textbook is incorrect\"\n", + "print \"Length of stub is\",round(l_dash,3),\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The position of the stub is 0.185 m\n", + "\n", + "Please note that the solution for l_dash given in the textbook is incorrect\n", + "Length of stub is 0.707 m\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.7, Page number 50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Terminating impedance\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "s = 3.2 #VSWR\n", + "Xmin = 0.237 #minimum voltage(V)\n", + "Zo = 50 #characteristic impedance(Ohms)\n", + "\n", + "#Calculations\n", + "q = math.tan(math.degrees(2*math.pi*Xmin))\n", + "x = complex(1,-(s*q))\n", + "y = complex(s, -q)\n", + "Zl = Zo*(x/y)\n", + "\n", + "#Result\n", + "print \"Please note that the solution given in the textbook is incorrect.Hence the difference in answers\\n\"\n", + "print \"Terminating impedance =\", Zl,\"Ohms\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please note that the solution given in the textbook is incorrect.Hence the difference in answers\n", + "\n", + "Terminating impedance = (19.6572514629-23.7885950214j) Ohms\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.8, Page number 51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate VSWR,First Vmax is loacted at load and first Vmin is located at,Vmin,Impedance at Vmin\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zo = 50. #characteristic impedance(Ohms)\n", + "Zl = 100. #load resistance(Ohms)\n", + "f = 300*10**3 #frequency(Hz)\n", + "Pl = 50*10**-3 #load power(W)\n", + "c = 3*10**8 #velocity of propagation(m/s)\n", + "\n", + "#Calculations\n", + "lamda = c/f\n", + "\n", + "#Part a\n", + "rho = (Zl-Zo)/(Zl+Zo)\n", + "s = (1+abs(rho))/(1-abs(rho))\n", + "\n", + "#Part b\n", + "#Since real Zl>Zo, first Vmax is located at the load\n", + "Vmin_pos = lamda/4\n", + "\n", + "#Part c\n", + "Vmax = math.sqrt(Pl*Zl)\n", + "Vmin = Vmax/s\n", + "\n", + "#Part d\n", + "Zin_at_Vmin = Zo/s\n", + "Zin_at_Vmax = Zo*s\n", + "\n", + "#Results\n", + "print \"VSWR = \", s\n", + "print \"First Vmax is loacted at load and first Vmin is located at=\", Vmin_pos,\"m from the load\"\n", + "print \"Vmax = \",round(Vmax,2),\"V\",\"\\nVmin = \",round(Vmin,2),\"V\"\n", + "print \"Impedance at Vmin is \", Zin_at_Vmin,\"Ohm and impedance at Vmax is\",Zin_at_Vmax,\"Ohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VSWR = 2.0\n", + "First Vmax is loacted at load and first Vmin is located at= 250 m from the load\n", + "Vmax = 2.24 V \n", + "Vmin = 1.12 V\n", + "Impedance at Vmin is 25.0 Ohm and impedance at Vmax is 100.0 Ohm\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.9, Page number 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Reflection loss, transmission loss, return loss\n", + "\n", + "import math\n", + "\n", + "#Variable declaration\n", + "Zo = 600. #characteristic impedance(Ohms)\n", + "Zs = 50 #source impedance(Ohms)\n", + "l = 200 #length of line(m)\n", + "Zl = 500. #load resistance(Ohms)\n", + "\n", + "#Calculations\n", + "rho = (Zl-Zo)/(Zl+Zo)\n", + "\n", + "#Part a\n", + "ref_l = math.log10(1/(1-((abs(rho))**2)))\n", + "\n", + "#Part b\n", + "#Since, the line is lossless,\n", + "att_l = 0\n", + "trans_l = ref_l+att_l\n", + "\n", + "#Part c\n", + "ret_l = math.log10(abs(rho))\n", + "\n", + "#Results\n", + "print \"Reflection loss =\",round(ref_l,4),\"dB\"\n", + "print \"Transmission loss =\",round(trans_l,4),\"dB\"\n", + "print \"Return loss =\",round(ret_l,3),\"dB (Calculation error in the textbook)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Reflection loss = 0.0036 dB\n", + "Transmission loss = 0.0036 dB\n", + "Return loss = -1.041 dB (Calculation error in the textbook)\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.10, Page number 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#calculate Characteristic impedance,Phase velocity \n", + "\n", + "import cmath\n", + "import math\n", + "\n", + "#Variable declaration\n", + "l = 10 #length of line(km)\n", + "zsc = complex(1895.47,2234.29) \n", + "zoc = complex(216.99,-143.37)\n", + "f = 1*10**3 #frequency(Hz)\n", + "\n", + "#Calculations\n", + "zo = cmath.sqrt(zsc*zoc)\n", + "x = cmath.sqrt(zsc/zoc)\n", + "t = (1+x)/(1-x)\n", + "gamma = cmath.log(t)/(l*2)\n", + "B = gamma.imag\n", + "w = 2*math.pi*f\n", + "Vp = w/B\n", + "\n", + "#Results\n", + "print \"There is calculation mistake throughout the problem in the textbook\\n\"\n", + "print \"Characteristic impedance =\",zo,\"Ohms\"\n", + "print \"Phase velocity =\",round((Vp/1E+3),3),\"*10^3 m/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "There is calculation mistake throughout the problem in the textbook\n", + "\n", + "Characteristic impedance = (864.190238563+123.274392427j) Ohms\n", + "Phase velocity = 45.994 *10^3 m/sec\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/GundaChaitnaya rani/Chapter_3_Ionization_and_Deionization_Processes_in_gases.ipynb b/sample_notebooks/GundaChaitnaya rani/Chapter_3_Ionization_and_Deionization_Processes_in_gases.ipynb deleted file mode 100755 index 4ab6ea93..00000000 --- a/sample_notebooks/GundaChaitnaya rani/Chapter_3_Ionization_and_Deionization_Processes_in_gases.ipynb +++ /dev/null @@ -1,656 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.1 pg.no:85" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "speed of oxygen molecule 473.791093 m/s\n" - ] - } - ], - "source": [ - "#Exa 3.7.1 speed of air molecules\n", - "# Example 1# Ch 3\n", - "from math import sqrt\n", - "# given data\n", - "R=8314; # gas constant in J/kg . mol .K\n", - "T=300; # temperature 27 deg C, 27+293=300K\n", - "M=32; # oxygen is diatomic\n", - "v = sqrt(3*R*(T/M));\n", - "print \"speed of oxygen molecule %f m/s\" %v\n", - "# Note: Value of R is given wrong in book\n", - "# So answer in the book is wrong" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.1 pg.no:87" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "volume of gas 1.533151e-03 mˆ3 \n", - "\n", - "total translational kinetic energy is 154.848250 J \n", - "\n" - ] - } - ], - "source": [ - "#Exa 3.7.2 total translational KE\n", - "# Example 2# Ch 3\n", - "# given data\n", - "R=8314; # gas constant in J/kg . mol .K\n", - "T=298;#in kelvin\n", - "M=32; # oxygen is diatomic\n", - "m=2*10**-3; # in kg\n", - "p=1.01*10**5; # 1 atm=1.01∗10ˆ5 N/m2\n", - "G = (m*R*T)/(M*p);#volume of gas\n", - "x=(3/2)*p;#no. of molecules per unit volume where x=N∗0.5∗m∗vˆ2 is given as (3/2)∗p)\n", - "print\"volume of gas %e mˆ3 \\n\"%G\n", - "KE = x*G;#total translational kinetic energy\n", - "print\"total translational kinetic energy is %f J \\n\"%KE\n", - "# Note: Value of G is calculated in book is wrong" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.3 pg.no:88" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "no . of molecules 2.753546e+19\n", - "max pressure in chamber 0.117735 N/m2\n" - ] - } - ], - "source": [ - "#Exa 3.7.3 max pressure in chamber\n", - "# Example 3# Ch 3\n", - "from math import pi\n", - "# given data\n", - "R=8314; # gas constant in J/kg . mol .K\n", - "T=300; # temperature 27 deg C, 27+293=300K\n", - "me=0.10; #mean free path in meters\n", - "rm=1.7*10**-10 #molecular radius in angstrom\n", - "M=28 #im moleˆ−1\n", - "m0=4.8*10**-26 #mass of nitrogen molecule\n", - "N = 1/(4*pi*((rm)**2)*me); # no. of molecules in gas\n", - "print\"no . of molecules %e\"%N \n", - "p = ((N*m0)/M)*R*T; # max pressure in chamber in N/ m2\n", - "print\"max pressure in chamber %f N/m2\"%p\n", - "# Note: Calculation in the book is wrong So answer in the book is wrong" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.4 pg.no:88" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "temperature 7.729469e+03 K\n" - ] - } - ], - "source": [ - "#Exa 3.7.4 temperature at which avg KE of He atoms in gas become 1 eV\n", - "# Example 4# Ch 3\n", - "# given data\n", - "v = 1.6*10**-19; # avg kinetic energy in j\n", - "k = 1.38*10**-23 #boltzmann constant in J/K\n", - "T = (2*v)/(3*k);\n", - "print \"temperature %e K\"%T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.5 pg.no:89" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "volume of 1kg of helium is 11.147071 mˆ3\n" - ] - } - ], - "source": [ - "#Exa 3.7.5 volume of 1 kg of He\n", - "# Example 6# Ch 3\n", - "# given data\n", - "m = 1;#in kg\n", - "M=2.016;#molecular weight of helium\n", - "k =8314# gas constant in J/kg \n", - "p = 1.01*10**5;\n", - "T = 273; # in kelvin\n", - "G = m*k*T/(M*p);#volume of 1kg of helium in mˆ3\n", - "print\"volume of 1kg of helium is %f mˆ3\"%G" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.6 pg.no:92" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "density of ions at distance equal to the mean free path 0.367879n0\n", - "density of ions at distance equal to five times the mean free path 0.006738n0\n" - ] - } - ], - "source": [ - "#Exa 3.7.6 density of ions at dist equal to mfp and five times mfp\n", - "# Example 6# Ch 3\n", - "from math import exp\n", - "# given data\n", - "z1=-1;#ion at a distance equal to mean free path , −x=mfp\n", - "z2=-5;#ion at a distance equal to five times the mean f r e e path , −x=5mfp\n", - "#n0 is the density of ions at the origin\n", - "n1 = exp(z1);#density of ions at distance equal to the mean free path\n", - "n2 = exp(z2);#density of ions at distance equal to five times the mean free path\n", - "print\"density of ions at distance equal to the mean free path %fn0\"%n1\n", - "print\"density of ions at distance equal to five times the mean free path %fn0\"%n2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.7 pg.no:93" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mean square velosity of helium atoms 1304.701955 m/s\n" - ] - } - ], - "source": [ - "#Exa 3.7.7 mean square velocity of He atoms\n", - "# Example 7# Ch 3\n", - "from math import sqrt\n", - "# given data\n", - "N = 178*10**-3 #gas density in kg/mˆ3\n", - "p = 1.01*10**5 # pressure\n", - "v = sqrt((3*p)/N); #mean square velosity of helium atoms\n", - "print\"mean square velosity of helium atoms %f m/s\"%v" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.1 pg.no:93" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "energy of free electron 3.790687 eV\n" - ] - } - ], - "source": [ - "#Exa 3.7.8 energy of free electrons\n", - "#Example 8# Ch 3\n", - "# given data\n", - "k =1.38e-21; #boltzmanns constant\n", - "T = 293; # temperature in K\n", - "e = 1.6*10** -19;\n", - "E =(1.5*k*T)/e;\n", - "print\"energy of free electron %f eV\"%E" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.9 pg.no:95" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "no . of atoms/cmˆ3 4.5168e+22\n", - "avg vokume occupied by one atom 2.213957e-23 cmˆ3\n", - "avg seperation between atoms 1.000000e+00 cm\n" - ] - } - ], - "source": [ - "#Exa 3.7.9 avg separation of atoms and avg vol occupied by one atom\n", - "#Example 9# Ch 3\n", - "# given data\n", - "d = 0.075; #density of solid atomic hydrogen in g/cmˆ3\n", - "N_A = 6.0224*10**23; #1g of H consists of NA atoms\n", - "N = N_A*d; # number of atoms/cmˆ3\n", - "print \"no . of atoms/cmˆ3 \",N\n", - "x = 1/N;#avg volume occupied by one atom in cmˆ3\n", - "y = (x)**(1/3);#avg seperation between atoms in cm\n", - "print \"avg vokume occupied by one atom %e cmˆ3\"%x\n", - "print \"avg seperation between atoms %e cm\"%y" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.10 pg.no:96" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "photon enegy 62.250000 eV\n", - "kinetic energy of photoelectron 48.650000 ev\n", - " velosity of photoelectron 4.133874e+06 m/s\n" - ] - } - ], - "source": [ - "#Exa 3.7.10 KE in eV and velocity of phototelectron\n", - "#Example 10# Ch 3\n", - "from math import sqrt\n", - "# given data\n", - "l=200*10**-10;# wavelength in angstrom\n", - "h=4.15*10**-15;#planks constant\n", - "c=3*10**8;#speed of light\n", - "me=9.11*10**-31;\n", - "BE=13.6;#binding energy in eV\n", - "PE=(h*c)/l;# in eV\n", - "print\"photon enegy %f eV\"%PE\n", - "KE = PE-BE;#in eV\n", - "print\"kinetic energy of photoelectron %f ev\"%KE\n", - "ve=sqrt((2*KE*1.6*10**-19)/me);\n", - "print\" velosity of photoelectron %e m/s\"%ve" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.11 pg.no:98" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "absorption coefficient -0.000000 cmˆ−1\n" - ] - } - ], - "source": [ - "#Exa 3.7.11 liquid photon absorption coefficient\n", - "#Example 11# Ch 3\n", - "from math import log\n", - "# given data\n", - "I = 1.;\n", - "I0 = 6.;\n", - "x=20;#in cm\n", - "u = -(1/x)*log(I/I0);\n", - "print\"absorption coefficient %f cmˆ−1\"%u" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.12 pg.no:98" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "binding energy of gas 12.450000 eV\n" - ] - } - ], - "source": [ - "#Exa 3.7.12 binding energy of the gas\n", - "#Example 12# Ch 3\n", - "# given data\n", - "c=3*10**8;\n", - "h=4.15*10**-15;\n", - "lmax =1000*10** -10;\n", - "We=(c*h)/lmax;\n", - "print\"binding energy of gas %f eV\"%We" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.14 pg.no:105" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "no of gas molecules 3.527492e+22 atoms/mˆ3\n", - "diameter of argon atom 2.769501e-10 m\n" - ] - } - ], - "source": [ - "#Exa 3.7.14 diameter of the argon atom\n", - "#Example 14# Ch 3\n", - "from math import sqrt,pi\n", - "# given data\n", - "p=1.01*10**5/760;# 1 torr in N/m2\n", - "k=1.38*10**-23;\n", - "T=273; # in Kelvin\n", - "n=85*10**2;#no of collisions per meter\n", - "N=p/(k*T);\n", - "print \"no of gas molecules %e atoms/mˆ3\"%N\n", - "r_a=sqrt(n/(pi*N*1));\n", - "print \"diameter of argon atom %e m\"%r_a" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.15 pg.no:106" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mobility of electrons 9375.000000 mˆ2/sV\n" - ] - } - ], - "source": [ - "#Exa 3.7.15 mobility of electrons\n", - "#Example 15# Ch 3\n", - "# given data\n", - "Ie=3;# current flow in amperes\n", - "A=8*10**-4;#area of the electrodes in mˆ2\n", - "V=20;#voltage across the electrodes\n", - "d=0.8;#spacing between the electrodes in meters\n", - "n_e=1*10**17;#electron density in mˆ−3\n", - "e=1.6*10**-19;\n", - "ke=(Ie*d)/(A*V*n_e*e);\n", - "print\"mobility of electrons %f mˆ2/sV\"%ke" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.17 pg.no:108" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ion density 0.02m away 1.911913e+09 ions/mˆ3 \n", - "\n", - "ion density −0.02m away 5.230363e+12 ions/mˆ3 \n", - "\n" - ] - } - ], - "source": [ - "#Exa 3.7.17 ion density point 02 m away in both directions at 25 deg C amperes\n", - "#Example 17# Ch 3\n", - "from math import exp\n", - "# given data\n", - "E = 5; #electric field in V/m\n", - "n_o = 10**11; #ion density in ions/m3\n", - "T = 293; # in kelvin\n", - "z = 0.02; #distance in meters\n", - "e = 1.6*10**-19; #in couloumb\n", - "k = 1.38*10**-23; # in m2 kg s−2 K−1\n", - "n1 = n_o*exp((-e*E*z)/(k*T));# ion density away \n", - "n2 = n_o*exp((e*E*z)/(k*T));# ion density away −0.02m\n", - "print\"ion density 0.02m away %e ions/mˆ3 \\n\"%n1\n", - "print\"ion density −0.02m away %e ions/mˆ3 \\n\"%n2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.18 pg.no:109" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "diameter before drift 3.032550e-05 m \n", - "\n", - "diameter after drift 5.515025e-03 m \n", - "\n" - ] - } - ], - "source": [ - "#Exa 3.7.18 diameter of cloud after drifting a distance of point 05\n", - "#Example 18# Ch 3 2 clc;\n", - "from math import sqrt\n", - "# given data\n", - "E = 250; #electric field in V/m\n", - "r1 = 0.3*10**-3#intial diameter of cloud in meters \n", - "k = 1.38*10**-23;#in m2 kg s−2 K−1\n", - "T = 293; #in kelvin\n", - "e = 1.6*10**-19;# in couloumb\n", - "z = 0.05;#drift distance in meters\n", - "r = (6*k*T*z)/(e*E);#diameter before drift\n", - "print\"diameter before drift %e m \\n\"%r\n", - "r2 = sqrt (r1**2 + r );#diamter after drifting a distance\n", - "print\"diameter after drift %e m \\n\"%r2 \n", - "# round off value calculated for r and r2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 3.7.19 pg.no:111" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "mean free path of electron in nitrogen 2.221482e-04 m\n", - "ionization potential of nitrogen 28.000000 V\n" - ] - } - ], - "source": [ - "#Exa 3.7.19 a mean free path of electrons in nitrogen and b ionization potential of nitrogen\n", - "#Example 19# Ch 3 \n", - "# given data\n", - "a = 9003;#constant in m−1kPa−1 \n", - "B = 256584;#in V/m.kPa\n", - "p = 0.5;#in kPa\n", - "M = 1/(a*p);#mean free path in meters\n", - "print\"mean free path of electron in nitrogen %e m\"%M\n", - "Vi = B/a; #ionization potential of nitrogen\n", - "print\"ionization potential of nitrogen %f V\"%Vi" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/GundaChaitnaya rani/GundaChaitnaya rani_version_backup/Chapter_3_Ionization_and_Deionization_Processes_in.ipynb b/sample_notebooks/GundaChaitnaya rani/GundaChaitnaya rani_version_backup/Chapter_3_Ionization_and_Deionization_Processes_in.ipynb new file mode 100755 index 00000000..4ab6ea93 --- /dev/null +++ b/sample_notebooks/GundaChaitnaya rani/GundaChaitnaya rani_version_backup/Chapter_3_Ionization_and_Deionization_Processes_in.ipynb @@ -0,0 +1,656 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.1 pg.no:85" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "speed of oxygen molecule 473.791093 m/s\n" + ] + } + ], + "source": [ + "#Exa 3.7.1 speed of air molecules\n", + "# Example 1# Ch 3\n", + "from math import sqrt\n", + "# given data\n", + "R=8314; # gas constant in J/kg . mol .K\n", + "T=300; # temperature 27 deg C, 27+293=300K\n", + "M=32; # oxygen is diatomic\n", + "v = sqrt(3*R*(T/M));\n", + "print \"speed of oxygen molecule %f m/s\" %v\n", + "# Note: Value of R is given wrong in book\n", + "# So answer in the book is wrong" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.1 pg.no:87" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "volume of gas 1.533151e-03 mˆ3 \n", + "\n", + "total translational kinetic energy is 154.848250 J \n", + "\n" + ] + } + ], + "source": [ + "#Exa 3.7.2 total translational KE\n", + "# Example 2# Ch 3\n", + "# given data\n", + "R=8314; # gas constant in J/kg . mol .K\n", + "T=298;#in kelvin\n", + "M=32; # oxygen is diatomic\n", + "m=2*10**-3; # in kg\n", + "p=1.01*10**5; # 1 atm=1.01∗10ˆ5 N/m2\n", + "G = (m*R*T)/(M*p);#volume of gas\n", + "x=(3/2)*p;#no. of molecules per unit volume where x=N∗0.5∗m∗vˆ2 is given as (3/2)∗p)\n", + "print\"volume of gas %e mˆ3 \\n\"%G\n", + "KE = x*G;#total translational kinetic energy\n", + "print\"total translational kinetic energy is %f J \\n\"%KE\n", + "# Note: Value of G is calculated in book is wrong" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.3 pg.no:88" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "no . of molecules 2.753546e+19\n", + "max pressure in chamber 0.117735 N/m2\n" + ] + } + ], + "source": [ + "#Exa 3.7.3 max pressure in chamber\n", + "# Example 3# Ch 3\n", + "from math import pi\n", + "# given data\n", + "R=8314; # gas constant in J/kg . mol .K\n", + "T=300; # temperature 27 deg C, 27+293=300K\n", + "me=0.10; #mean free path in meters\n", + "rm=1.7*10**-10 #molecular radius in angstrom\n", + "M=28 #im moleˆ−1\n", + "m0=4.8*10**-26 #mass of nitrogen molecule\n", + "N = 1/(4*pi*((rm)**2)*me); # no. of molecules in gas\n", + "print\"no . of molecules %e\"%N \n", + "p = ((N*m0)/M)*R*T; # max pressure in chamber in N/ m2\n", + "print\"max pressure in chamber %f N/m2\"%p\n", + "# Note: Calculation in the book is wrong So answer in the book is wrong" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.4 pg.no:88" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "temperature 7.729469e+03 K\n" + ] + } + ], + "source": [ + "#Exa 3.7.4 temperature at which avg KE of He atoms in gas become 1 eV\n", + "# Example 4# Ch 3\n", + "# given data\n", + "v = 1.6*10**-19; # avg kinetic energy in j\n", + "k = 1.38*10**-23 #boltzmann constant in J/K\n", + "T = (2*v)/(3*k);\n", + "print \"temperature %e K\"%T" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.5 pg.no:89" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "volume of 1kg of helium is 11.147071 mˆ3\n" + ] + } + ], + "source": [ + "#Exa 3.7.5 volume of 1 kg of He\n", + "# Example 6# Ch 3\n", + "# given data\n", + "m = 1;#in kg\n", + "M=2.016;#molecular weight of helium\n", + "k =8314# gas constant in J/kg \n", + "p = 1.01*10**5;\n", + "T = 273; # in kelvin\n", + "G = m*k*T/(M*p);#volume of 1kg of helium in mˆ3\n", + "print\"volume of 1kg of helium is %f mˆ3\"%G" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.6 pg.no:92" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "density of ions at distance equal to the mean free path 0.367879n0\n", + "density of ions at distance equal to five times the mean free path 0.006738n0\n" + ] + } + ], + "source": [ + "#Exa 3.7.6 density of ions at dist equal to mfp and five times mfp\n", + "# Example 6# Ch 3\n", + "from math import exp\n", + "# given data\n", + "z1=-1;#ion at a distance equal to mean free path , −x=mfp\n", + "z2=-5;#ion at a distance equal to five times the mean f r e e path , −x=5mfp\n", + "#n0 is the density of ions at the origin\n", + "n1 = exp(z1);#density of ions at distance equal to the mean free path\n", + "n2 = exp(z2);#density of ions at distance equal to five times the mean free path\n", + "print\"density of ions at distance equal to the mean free path %fn0\"%n1\n", + "print\"density of ions at distance equal to five times the mean free path %fn0\"%n2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.7 pg.no:93" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mean square velosity of helium atoms 1304.701955 m/s\n" + ] + } + ], + "source": [ + "#Exa 3.7.7 mean square velocity of He atoms\n", + "# Example 7# Ch 3\n", + "from math import sqrt\n", + "# given data\n", + "N = 178*10**-3 #gas density in kg/mˆ3\n", + "p = 1.01*10**5 # pressure\n", + "v = sqrt((3*p)/N); #mean square velosity of helium atoms\n", + "print\"mean square velosity of helium atoms %f m/s\"%v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.1 pg.no:93" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "energy of free electron 3.790687 eV\n" + ] + } + ], + "source": [ + "#Exa 3.7.8 energy of free electrons\n", + "#Example 8# Ch 3\n", + "# given data\n", + "k =1.38e-21; #boltzmanns constant\n", + "T = 293; # temperature in K\n", + "e = 1.6*10** -19;\n", + "E =(1.5*k*T)/e;\n", + "print\"energy of free electron %f eV\"%E" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.9 pg.no:95" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "no . of atoms/cmˆ3 4.5168e+22\n", + "avg vokume occupied by one atom 2.213957e-23 cmˆ3\n", + "avg seperation between atoms 1.000000e+00 cm\n" + ] + } + ], + "source": [ + "#Exa 3.7.9 avg separation of atoms and avg vol occupied by one atom\n", + "#Example 9# Ch 3\n", + "# given data\n", + "d = 0.075; #density of solid atomic hydrogen in g/cmˆ3\n", + "N_A = 6.0224*10**23; #1g of H consists of NA atoms\n", + "N = N_A*d; # number of atoms/cmˆ3\n", + "print \"no . of atoms/cmˆ3 \",N\n", + "x = 1/N;#avg volume occupied by one atom in cmˆ3\n", + "y = (x)**(1/3);#avg seperation between atoms in cm\n", + "print \"avg vokume occupied by one atom %e cmˆ3\"%x\n", + "print \"avg seperation between atoms %e cm\"%y" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.10 pg.no:96" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "photon enegy 62.250000 eV\n", + "kinetic energy of photoelectron 48.650000 ev\n", + " velosity of photoelectron 4.133874e+06 m/s\n" + ] + } + ], + "source": [ + "#Exa 3.7.10 KE in eV and velocity of phototelectron\n", + "#Example 10# Ch 3\n", + "from math import sqrt\n", + "# given data\n", + "l=200*10**-10;# wavelength in angstrom\n", + "h=4.15*10**-15;#planks constant\n", + "c=3*10**8;#speed of light\n", + "me=9.11*10**-31;\n", + "BE=13.6;#binding energy in eV\n", + "PE=(h*c)/l;# in eV\n", + "print\"photon enegy %f eV\"%PE\n", + "KE = PE-BE;#in eV\n", + "print\"kinetic energy of photoelectron %f ev\"%KE\n", + "ve=sqrt((2*KE*1.6*10**-19)/me);\n", + "print\" velosity of photoelectron %e m/s\"%ve" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.11 pg.no:98" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "absorption coefficient -0.000000 cmˆ−1\n" + ] + } + ], + "source": [ + "#Exa 3.7.11 liquid photon absorption coefficient\n", + "#Example 11# Ch 3\n", + "from math import log\n", + "# given data\n", + "I = 1.;\n", + "I0 = 6.;\n", + "x=20;#in cm\n", + "u = -(1/x)*log(I/I0);\n", + "print\"absorption coefficient %f cmˆ−1\"%u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.12 pg.no:98" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "binding energy of gas 12.450000 eV\n" + ] + } + ], + "source": [ + "#Exa 3.7.12 binding energy of the gas\n", + "#Example 12# Ch 3\n", + "# given data\n", + "c=3*10**8;\n", + "h=4.15*10**-15;\n", + "lmax =1000*10** -10;\n", + "We=(c*h)/lmax;\n", + "print\"binding energy of gas %f eV\"%We" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.14 pg.no:105" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "no of gas molecules 3.527492e+22 atoms/mˆ3\n", + "diameter of argon atom 2.769501e-10 m\n" + ] + } + ], + "source": [ + "#Exa 3.7.14 diameter of the argon atom\n", + "#Example 14# Ch 3\n", + "from math import sqrt,pi\n", + "# given data\n", + "p=1.01*10**5/760;# 1 torr in N/m2\n", + "k=1.38*10**-23;\n", + "T=273; # in Kelvin\n", + "n=85*10**2;#no of collisions per meter\n", + "N=p/(k*T);\n", + "print \"no of gas molecules %e atoms/mˆ3\"%N\n", + "r_a=sqrt(n/(pi*N*1));\n", + "print \"diameter of argon atom %e m\"%r_a" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.15 pg.no:106" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mobility of electrons 9375.000000 mˆ2/sV\n" + ] + } + ], + "source": [ + "#Exa 3.7.15 mobility of electrons\n", + "#Example 15# Ch 3\n", + "# given data\n", + "Ie=3;# current flow in amperes\n", + "A=8*10**-4;#area of the electrodes in mˆ2\n", + "V=20;#voltage across the electrodes\n", + "d=0.8;#spacing between the electrodes in meters\n", + "n_e=1*10**17;#electron density in mˆ−3\n", + "e=1.6*10**-19;\n", + "ke=(Ie*d)/(A*V*n_e*e);\n", + "print\"mobility of electrons %f mˆ2/sV\"%ke" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.17 pg.no:108" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ion density 0.02m away 1.911913e+09 ions/mˆ3 \n", + "\n", + "ion density −0.02m away 5.230363e+12 ions/mˆ3 \n", + "\n" + ] + } + ], + "source": [ + "#Exa 3.7.17 ion density point 02 m away in both directions at 25 deg C amperes\n", + "#Example 17# Ch 3\n", + "from math import exp\n", + "# given data\n", + "E = 5; #electric field in V/m\n", + "n_o = 10**11; #ion density in ions/m3\n", + "T = 293; # in kelvin\n", + "z = 0.02; #distance in meters\n", + "e = 1.6*10**-19; #in couloumb\n", + "k = 1.38*10**-23; # in m2 kg s−2 K−1\n", + "n1 = n_o*exp((-e*E*z)/(k*T));# ion density away \n", + "n2 = n_o*exp((e*E*z)/(k*T));# ion density away −0.02m\n", + "print\"ion density 0.02m away %e ions/mˆ3 \\n\"%n1\n", + "print\"ion density −0.02m away %e ions/mˆ3 \\n\"%n2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.18 pg.no:109" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "diameter before drift 3.032550e-05 m \n", + "\n", + "diameter after drift 5.515025e-03 m \n", + "\n" + ] + } + ], + "source": [ + "#Exa 3.7.18 diameter of cloud after drifting a distance of point 05\n", + "#Example 18# Ch 3 2 clc;\n", + "from math import sqrt\n", + "# given data\n", + "E = 250; #electric field in V/m\n", + "r1 = 0.3*10**-3#intial diameter of cloud in meters \n", + "k = 1.38*10**-23;#in m2 kg s−2 K−1\n", + "T = 293; #in kelvin\n", + "e = 1.6*10**-19;# in couloumb\n", + "z = 0.05;#drift distance in meters\n", + "r = (6*k*T*z)/(e*E);#diameter before drift\n", + "print\"diameter before drift %e m \\n\"%r\n", + "r2 = sqrt (r1**2 + r );#diamter after drifting a distance\n", + "print\"diameter after drift %e m \\n\"%r2 \n", + "# round off value calculated for r and r2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 3.7.19 pg.no:111" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "mean free path of electron in nitrogen 2.221482e-04 m\n", + "ionization potential of nitrogen 28.000000 V\n" + ] + } + ], + "source": [ + "#Exa 3.7.19 a mean free path of electrons in nitrogen and b ionization potential of nitrogen\n", + "#Example 19# Ch 3 \n", + "# given data\n", + "a = 9003;#constant in m−1kPa−1 \n", + "B = 256584;#in V/m.kPa\n", + "p = 0.5;#in kPa\n", + "M = 1/(a*p);#mean free path in meters\n", + "print\"mean free path of electron in nitrogen %e m\"%M\n", + "Vi = B/a; #ionization potential of nitrogen\n", + "print\"ionization potential of nitrogen %f V\"%Vi" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/GundlaKeerthi vani/GundlaKeerthi vani_version_backup/J.B.Gupta_Chapter_6_(1).ipynb b/sample_notebooks/GundlaKeerthi vani/GundlaKeerthi vani_version_backup/J.B.Gupta_Chapter_6_(1).ipynb new file mode 100755 index 00000000..eeabf53b --- /dev/null +++ b/sample_notebooks/GundlaKeerthi vani/GundlaKeerthi vani_version_backup/J.B.Gupta_Chapter_6_(1).ipynb @@ -0,0 +1,196 @@ +{ + "metadata": { + "name": "J.B.Gupta Chapter 6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 6 Extension of Instrument Range" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.1,Page No 165" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nIm = 50*10**-6; #full scale deflection current in A\nRm = 1000; #instrument resistance in \u03a9\nI = 1; #total current to be measured in A\n \n#calculations\nRs = (Rm/float((I/float(Im))-1)); #resistance of ammeter in \u03a9\n \n \n#result\nprint'resistance of ammeter shunt required Rs = %3.7f'%Rs,'\u03a9';\n \n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "resistance of ammeter shunt required Rs = 0.0500025 \u03a9\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.2,Page No 165" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nRm = 1; #instrument resistance in \u03a9\nRse = 4999; #series resistance in \u03a9\nV = 250; #full-scale deflection voltage in V\nRs = 0.002004; #Shunt resistance in \u03a9(Rs =1/float(499))\nI1 = 50; #full-scale defelction current in A\n \n#calculations\nIm = V/float(Rm+Rse); #full-scale deflection current in A\nx = 1/float(Rse);\nI = Im*(1+(Rm/float(x))); #current in A\nN = I1/float(Im); \nRsh = Rm/float(N-1); #shunt resistance in \u03a9\n \n#result\nprint'full-scale defelction current in Im = %3.2f'%Im,'A';\nprint'current range of instrument when used as an ammeter with coil connected across shunt is I = %3.2f'%I,'A';\nprint'Shunt resistance for the instrument to give a full-scale deflection of 50A is Rsh = %3.2e'%Rsh,'\u03a9';\n \n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "full-scale defelction current in Im = 0.05 A\ncurrent range of instrument when used as an ammeter with coil connected across shunt is I = 250.00 A\nShunt resistance for the instrument to give a full-scale deflection of 50A is Rsh = 1.00e-03 \u03a9\n" + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.3,Page No 167" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nRm = 10; #instrument resistance in \u03a9\nIm = 0.05; #instrument current in A\nV = 750; #voltage to be measured in V\nI = 100; #current to be measured in A\n \n#calculations\nR = (V/float(Im))-Rm; #External resistance in \u03a9\nN = I/float(Im); #power of shunt\nRs = Rm/float(N-1); #resistance in \u03a9\n \n \n#result\nprint'external resistance to be connected in sereis to enable the instrument to measure voltage upto 750V is %3.1f'%R,'\u03a9';\nprint'shunt resistance required %3.4f'%Rs,'\u03a9';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "external resistance to be connected in sereis to enable the instrument to measure voltage upto 750V is 14990.0 \u03a9\nshunt resistance required 0.0050 \u03a9\n" + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.4,Page No 167" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nRm = 5; #instrument resistance in \u03a9\nIm = 15*10**-3; #full scale defelection current in A\nI =1; #current to be measured in A\nV = 10; #voltage to be measured in V\n \n#calculations\nN = I/float(Im); #power of shunt\nRs = Rm/float(N-1); #resistance in \u03a9\nR = (V/float(Im))-Rm; #series resistance in \u03a9\n \n \n#result\nprint'resistance to be connected in parallel to enable the instrument to measure current upto 1A is %3.4f'%Rs,'\u03a9';\nprint'shunt resistance required for full-scale defelction with 10v is %3.4f'%R,'\u03a9';\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "resistance to be connected in parallel to enable the instrument to measure current upto 1A is 0.0761 \u03a9\nshunt resistance required for full-scale defelction with 10v is 661.6667 \u03a9\n" + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.5,Page No 167" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nRm = 2; #instrument coil resistance in \u03a9\nV = 250; #full-scale reading in V\nRs = 5000; #series resistance in \u03a9\nRsh = 2*10**-3; #shunt resistance in \u03a9\n \n \n#calculations\nIm = V/float(Rm+Rs); #current flowing through the instrument for full-scale deflection in A\nIs = (Im*Rm)/float(Rsh); #current through shunt resistance in A \nI = Im+Is; #current range of instrument in A\n \n#result\nprint'current flowing through the instrument for full-scale deflection is %3.4f'%(Im*10**3),'mA';\nprint'current through shunt resistance is %3.2f'%Is,'A';\nprint'current range of instrumentis %3.1f'%I,'A'\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "current flowing through the instrument for full-scale deflection is 49.9800 mA\ncurrent through shunt resistance is 49.98 A\ncurrent range of instrumentis 50.0 A\n" + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.6,Page No 168" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n \n#variable declaration\nRsh = 0.02; #shunt resistance in \u03a9\nV = 0.5; #potential difference across the shunt in V\nRm = 1000; #resistance in \u03a9\nI1 = 10; #current in A\nI2 = 75; #current in A\nI = 100;\t\t\t #current in A\nx = 40;\t\t\t #deflection %\n \n#calculations\nIs = V/float(Rsh); #current through shunt in A\nIm = V/float(Rm); #current through ammeter for full-scale defelction in A\nV1 = I1*Rsh; #voltage across shunt for 10A in V\nR1 = V1/float(Im);\t\t\t #resistance for the ammeter for a current of 10 A for full-scale defelction in \u03a9\nV2 = I2*Rsh; #voltage across shunt for 75A in V\nR2 = V2/float(Im);\t\t\t #resistance for the ammeter for a current of 75 A for full-scale defelction in \u03a9\nI3 = I*(100/float(x));\t\t\t #full-scale defelction current when 100 A gives 40% defelction\nV3 = I3*Rsh; #voltage across shunt for 250 A in V\nR3 = V3/float(Im);\t\t\t #resistance for the ammeter for a current of 250 A for full-scale defelction in \u03a9\n\n\n#result\nprint'current through ammeter for full-scale defelction is %3.1f'% (Im*10**3),' A'\nprint'Resistance for the ammeter for a current of 10 A for full-scale defelction is %3.2f'%R1,' \u03a9';\nprint'Resistance for the ammeter for a current of 75 A for full-scale defelction is %3.2f'%R2,' \u03a9';\nprint'Resistance for the ammeter for a current of 250 A for full-scale defelction is %3.2f'%R3,' \u03a9';\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "current through ammeter for full-scale defelction is 0.5 A\nResistance for the ammeter for a current of 10 A for full-scale defelction is 400.00 \u03a9\nResistance for the ammeter for a current of 75 A for full-scale defelction is 3000.00 \u03a9\nResistance for the ammeter for a current of 250 A for full-scale defelction is 10000.00 \u03a9\n" + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.7,Page No 168" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n\n#variable declaration\nB = 0.5;\t\t\t #flux density of the magnetic field in Wb/m**2\nN = 100;\t\t\t #number of turns in coil\nl = 0.04;\t\t #length in m\nr =0.03;\t\t\t #width in m\nTc = 120*10**-6;\t #controlling torque in N-m\nv = 1; \t\t\t #volts per division in V\nn = 100;\t\t\t #number of division on full-scale\nRm = 0;\n\n#calculations\nI = Tc/float(B*N*l*r);\t\t #current for full-scale deflection in A\nV = n*v;\t\t\t #full-scale reading of instrument in V\nR = (V/float(I))-Rm;\t\t\t #External resistance required to be put in series with the coil in \u03a9\n\n#result\nprint'current for full-scale deflection is %3.4f'%I,'A';\nprint'External resistance required to be put in series with the coil is %3.3f'%R,' \u03a9';\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "current for full-scale deflection is 0.0020 A\nExternal resistance required to be put in series with the coil is 50000.000 \u03a9\n" + } + ], + "prompt_number": 48 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6.8,Page No 169" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n\n\n#variable decalaration\nRm = 5;\t\t #coil resistance in \u03a9\nRm1 = 0.00075;\t\t #coil resistance in \u03a9\nIm = 0.015;\t\t #full-scale defelction current in A\nI = 100; \t\t #current to be measured in A\nT1 = 0.004;\t\t #temperature coeficient of copper in \u03a9/\u03a9/\u00b0C\nT2 = 0.00015;\t\t #temperature coeficient of manganin in \u03a9/\u03a9/\u00b0C\nT =10; \t\t #rise in temperature in \u00b0C\n#calculations\nN = I/float(Im);\t\t #multiplying power of shunt\nRs = Rm/float(N-1);\t #resistance of manganin shunt in \u03a9\nRc = Rm*(1+(T1*T));\t #coil resitance with 10\u00b0C in temperature in \u03a9\nRsh = Rm1*(1+(T2*T));\t #shunt resitance with 10\u00b0C in temperature in \u03a9\nIn = (Rsh/float(Rc+Rsh))*100;\t#new instrument current in A\nr = (In/float(Im))*100;\t\t#new instrument reading in A\ne = ((r-I)/float(I))*100;\t\t#percentage error in %\n\n\n#result\nprint'percentage error %3.5f'%e,'%';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "percentage error -3.71583 %\n" + } + ], + "prompt_number": 83 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/GundlaKeerthi vani/J.B.Gupta_Chapter_6_(1).ipynb b/sample_notebooks/GundlaKeerthi vani/J.B.Gupta_Chapter_6_(1).ipynb deleted file mode 100755 index eeabf53b..00000000 --- a/sample_notebooks/GundlaKeerthi vani/J.B.Gupta_Chapter_6_(1).ipynb +++ /dev/null @@ -1,196 +0,0 @@ -{ - "metadata": { - "name": "J.B.Gupta Chapter 6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Chapter 6 Extension of Instrument Range" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.1,Page No 165" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nIm = 50*10**-6; #full scale deflection current in A\nRm = 1000; #instrument resistance in \u03a9\nI = 1; #total current to be measured in A\n \n#calculations\nRs = (Rm/float((I/float(Im))-1)); #resistance of ammeter in \u03a9\n \n \n#result\nprint'resistance of ammeter shunt required Rs = %3.7f'%Rs,'\u03a9';\n \n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "resistance of ammeter shunt required Rs = 0.0500025 \u03a9\n" - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.2,Page No 165" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nRm = 1; #instrument resistance in \u03a9\nRse = 4999; #series resistance in \u03a9\nV = 250; #full-scale deflection voltage in V\nRs = 0.002004; #Shunt resistance in \u03a9(Rs =1/float(499))\nI1 = 50; #full-scale defelction current in A\n \n#calculations\nIm = V/float(Rm+Rse); #full-scale deflection current in A\nx = 1/float(Rse);\nI = Im*(1+(Rm/float(x))); #current in A\nN = I1/float(Im); \nRsh = Rm/float(N-1); #shunt resistance in \u03a9\n \n#result\nprint'full-scale defelction current in Im = %3.2f'%Im,'A';\nprint'current range of instrument when used as an ammeter with coil connected across shunt is I = %3.2f'%I,'A';\nprint'Shunt resistance for the instrument to give a full-scale deflection of 50A is Rsh = %3.2e'%Rsh,'\u03a9';\n \n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "full-scale defelction current in Im = 0.05 A\ncurrent range of instrument when used as an ammeter with coil connected across shunt is I = 250.00 A\nShunt resistance for the instrument to give a full-scale deflection of 50A is Rsh = 1.00e-03 \u03a9\n" - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.3,Page No 167" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nRm = 10; #instrument resistance in \u03a9\nIm = 0.05; #instrument current in A\nV = 750; #voltage to be measured in V\nI = 100; #current to be measured in A\n \n#calculations\nR = (V/float(Im))-Rm; #External resistance in \u03a9\nN = I/float(Im); #power of shunt\nRs = Rm/float(N-1); #resistance in \u03a9\n \n \n#result\nprint'external resistance to be connected in sereis to enable the instrument to measure voltage upto 750V is %3.1f'%R,'\u03a9';\nprint'shunt resistance required %3.4f'%Rs,'\u03a9';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "external resistance to be connected in sereis to enable the instrument to measure voltage upto 750V is 14990.0 \u03a9\nshunt resistance required 0.0050 \u03a9\n" - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.4,Page No 167" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nRm = 5; #instrument resistance in \u03a9\nIm = 15*10**-3; #full scale defelection current in A\nI =1; #current to be measured in A\nV = 10; #voltage to be measured in V\n \n#calculations\nN = I/float(Im); #power of shunt\nRs = Rm/float(N-1); #resistance in \u03a9\nR = (V/float(Im))-Rm; #series resistance in \u03a9\n \n \n#result\nprint'resistance to be connected in parallel to enable the instrument to measure current upto 1A is %3.4f'%Rs,'\u03a9';\nprint'shunt resistance required for full-scale defelction with 10v is %3.4f'%R,'\u03a9';\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "resistance to be connected in parallel to enable the instrument to measure current upto 1A is 0.0761 \u03a9\nshunt resistance required for full-scale defelction with 10v is 661.6667 \u03a9\n" - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.5,Page No 167" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nRm = 2; #instrument coil resistance in \u03a9\nV = 250; #full-scale reading in V\nRs = 5000; #series resistance in \u03a9\nRsh = 2*10**-3; #shunt resistance in \u03a9\n \n \n#calculations\nIm = V/float(Rm+Rs); #current flowing through the instrument for full-scale deflection in A\nIs = (Im*Rm)/float(Rsh); #current through shunt resistance in A \nI = Im+Is; #current range of instrument in A\n \n#result\nprint'current flowing through the instrument for full-scale deflection is %3.4f'%(Im*10**3),'mA';\nprint'current through shunt resistance is %3.2f'%Is,'A';\nprint'current range of instrumentis %3.1f'%I,'A'\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "current flowing through the instrument for full-scale deflection is 49.9800 mA\ncurrent through shunt resistance is 49.98 A\ncurrent range of instrumentis 50.0 A\n" - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.6,Page No 168" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n \n#variable declaration\nRsh = 0.02; #shunt resistance in \u03a9\nV = 0.5; #potential difference across the shunt in V\nRm = 1000; #resistance in \u03a9\nI1 = 10; #current in A\nI2 = 75; #current in A\nI = 100;\t\t\t #current in A\nx = 40;\t\t\t #deflection %\n \n#calculations\nIs = V/float(Rsh); #current through shunt in A\nIm = V/float(Rm); #current through ammeter for full-scale defelction in A\nV1 = I1*Rsh; #voltage across shunt for 10A in V\nR1 = V1/float(Im);\t\t\t #resistance for the ammeter for a current of 10 A for full-scale defelction in \u03a9\nV2 = I2*Rsh; #voltage across shunt for 75A in V\nR2 = V2/float(Im);\t\t\t #resistance for the ammeter for a current of 75 A for full-scale defelction in \u03a9\nI3 = I*(100/float(x));\t\t\t #full-scale defelction current when 100 A gives 40% defelction\nV3 = I3*Rsh; #voltage across shunt for 250 A in V\nR3 = V3/float(Im);\t\t\t #resistance for the ammeter for a current of 250 A for full-scale defelction in \u03a9\n\n\n#result\nprint'current through ammeter for full-scale defelction is %3.1f'% (Im*10**3),' A'\nprint'Resistance for the ammeter for a current of 10 A for full-scale defelction is %3.2f'%R1,' \u03a9';\nprint'Resistance for the ammeter for a current of 75 A for full-scale defelction is %3.2f'%R2,' \u03a9';\nprint'Resistance for the ammeter for a current of 250 A for full-scale defelction is %3.2f'%R3,' \u03a9';\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "current through ammeter for full-scale defelction is 0.5 A\nResistance for the ammeter for a current of 10 A for full-scale defelction is 400.00 \u03a9\nResistance for the ammeter for a current of 75 A for full-scale defelction is 3000.00 \u03a9\nResistance for the ammeter for a current of 250 A for full-scale defelction is 10000.00 \u03a9\n" - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.7,Page No 168" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n\n#variable declaration\nB = 0.5;\t\t\t #flux density of the magnetic field in Wb/m**2\nN = 100;\t\t\t #number of turns in coil\nl = 0.04;\t\t #length in m\nr =0.03;\t\t\t #width in m\nTc = 120*10**-6;\t #controlling torque in N-m\nv = 1; \t\t\t #volts per division in V\nn = 100;\t\t\t #number of division on full-scale\nRm = 0;\n\n#calculations\nI = Tc/float(B*N*l*r);\t\t #current for full-scale deflection in A\nV = n*v;\t\t\t #full-scale reading of instrument in V\nR = (V/float(I))-Rm;\t\t\t #External resistance required to be put in series with the coil in \u03a9\n\n#result\nprint'current for full-scale deflection is %3.4f'%I,'A';\nprint'External resistance required to be put in series with the coil is %3.3f'%R,' \u03a9';\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "current for full-scale deflection is 0.0020 A\nExternal resistance required to be put in series with the coil is 50000.000 \u03a9\n" - } - ], - "prompt_number": 48 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6.8,Page No 169" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n\n\n#variable decalaration\nRm = 5;\t\t #coil resistance in \u03a9\nRm1 = 0.00075;\t\t #coil resistance in \u03a9\nIm = 0.015;\t\t #full-scale defelction current in A\nI = 100; \t\t #current to be measured in A\nT1 = 0.004;\t\t #temperature coeficient of copper in \u03a9/\u03a9/\u00b0C\nT2 = 0.00015;\t\t #temperature coeficient of manganin in \u03a9/\u03a9/\u00b0C\nT =10; \t\t #rise in temperature in \u00b0C\n#calculations\nN = I/float(Im);\t\t #multiplying power of shunt\nRs = Rm/float(N-1);\t #resistance of manganin shunt in \u03a9\nRc = Rm*(1+(T1*T));\t #coil resitance with 10\u00b0C in temperature in \u03a9\nRsh = Rm1*(1+(T2*T));\t #shunt resitance with 10\u00b0C in temperature in \u03a9\nIn = (Rsh/float(Rc+Rsh))*100;\t#new instrument current in A\nr = (In/float(Im))*100;\t\t#new instrument reading in A\ne = ((r-I)/float(I))*100;\t\t#percentage error in %\n\n\n#result\nprint'percentage error %3.5f'%e,'%';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "percentage error -3.71583 %\n" - } - ], - "prompt_number": 83 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "", - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS_.ipynb b/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS_.ipynb deleted file mode 100755 index c3a541b0..00000000 --- a/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS_.ipynb +++ /dev/null @@ -1,223 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example1.1 Page number 10\n", - "#downstream direction as x\n", - "#direction across river as y\n", - "\n", - "from math import sqrt,atan,pi\n", - "\n", - "#variable declaration\n", - "\n", - "Vx= 8 #velocity of stream, km/hour\n", - "Vy=float(20) #velocity of boat,km/hour\n", - "\n", - "V=sqrt(pow(Vx,2)+pow(Vy,2)) #resultant velocity, km/hour\n", - "theta=Vy/Vx\n", - "\n", - "alpha= atan(theta)*180/pi #angle, degrees \n", - "\n", - "print \" The resultant velocity :\",round(V,2),\"km/hour\"\n", - "print round(alpha,2),\"°\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.2 Page number 10\n", - "\n", - "\n", - "#components of force in horizontal and vertical components. \n", - "from math import cos,sin,pi\n", - "#variable declaration\n", - "\n", - "F= 20 #force in wire, KN\n", - "\n", - "#calculations\n", - "Fx= F*cos(60*pi/180) \n", - "Fy= F*sin(60*pi/180)\n", - "\n", - "print round(Fx,2),\"KN\" ,\"(to the left)\"\n", - "print round(Fy,2), \"KN\" ,\"(downward)\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.3 Page number 11\n", - "\n", - " #The plane makes an angle of 20° to the horizontal. Hence the normal to the plane makes an angles of 70° to the horizontal i.e., 20° to the vertical\n", - "from math import cos,sin,pi\n", - "#variable declaration\n", - "W= 10 # black weighing, KN\n", - "\n", - "#calculations\n", - "\n", - "Nor= W*cos(20*pi/180) #Component normal to the plane\n", - "para= W*sin(20*pi/180) #Component parallel to the plane\n", - "\n", - "print \"Component normal to the plane :\",round(Nor,2),\"KN\"\n", - "print \"Component parallel to the plane :\",round(para,2) , \"KN\"\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.4 Page number 11\n", - "\n", - "#Let the magnitude of the smaller force be F. Hence the magnitude of the larger force is 2F\n", - "\n", - "from math import pi,sqrt, acos\n", - "#variable declaration\n", - "R1=260 #resultant of two forces,N\n", - "R2=float(180) #resultant of two forces if larger force is reversed,N\n", - "\n", - "\n", - "\n", - "#calculations\n", - "\n", - "F=sqrt((pow(R1,2)+pow(R2,2))/10)\n", - "F1=F\n", - "F2=2*F\n", - "theta=acos((pow(R1,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*180/pi\n", - "\n", - "print \"F1=\",F1,\"N\"\n", - "print \"F2=\",F2,\"N\"\n", - "print \"theta=\",round(theta,1),\"°\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.5 Page number 12\n", - "\n", - "#Let ?ABC be the triangle of forces drawn to some scale\n", - "#Two forces F1 and F2 are acting at point A\n", - "#angle in degrees '°'\n", - "\n", - "from math import sin,pi\n", - " \n", - "#variabble declaration\n", - "cnv=pi/180\n", - "\n", - "BAC = 20*cnv #Resultant R makes angle with F1 \n", - " \n", - "ABC = 130*cnv \n", - "\n", - "ACB = 30*cnv \n", - "\n", - "R = 500 #resultant force,N\n", - "\n", - "#calculations\n", - "#sinerule\n", - "\n", - "F1=R*sin(ACB)/sin(ABC)\n", - "F2=R*sin(BAC)/sin(ABC)\n", - "\n", - "print \"F1=\",round(F1,2),\"N\"\n", - "print \"F2=\",round(F2,2),\"N\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.6 Page number 12\n", - "\n", - "#Let ABC be the triangle of forces,'theta' be the angle between F1 and F2, and 'alpha' be the angle between resultant and F1 \n", - "\n", - "from math import sin,acos,asin,pi\n", - "\n", - "#variable declaration\n", - "cnv= 180/pi\n", - "F1=float(400) #all forces are in newtons,'N'\n", - "F2=float(260)\n", - "R=float(520)\n", - "\n", - "#calculations\n", - "\n", - "theta=acos((pow(R,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*cnv\n", - "\n", - "alpha=asin(F2*sin(theta*pi/180)/R)*cnv\n", - "\n", - "print\"theta=\",round(theta,2),\"°\"\n", - "print \"alpha=\",round(alpha,2),\"°\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# example 1.7 Page number 13\n", - "\n", - "#The force of 3000 N acts along line AB. Let AB make angle alpha with horizontal.\n", - "\n", - "from math import cos,sin,pi,asin,acos\n", - "\n", - "#variable declaration\n", - "F=3000 #force in newtons,'N'\n", - "BC=80 #length of crank BC, 'mm'\n", - "AB=200 #length of connecting rod AB ,'mm'\n", - "theta=60*pi/180 #angle b/w BC & AC\n", - "\n", - "#calculations\n", - "\n", - "alpha=asin(BC*sin(theta)/200)*180/pi\n", - "\n", - "HC=F*cos(alpha*pi/180) #Horizontal component \n", - "VC= F*sin(alpha*pi/180) #Vertical component \n", - "\n", - "#Components along and normal to crank\n", - "#The force makes angle alpha + 60 with crank.\n", - "alpha2=alpha+60\n", - "CAC=F*cos(alpha2*pi/180) # Component along crank \n", - "CNC= F*sin(alpha2*pi/180) #Component normal to crank \n", - "\n", - "\n", - "print \"horizontal component=\",round(HC,1),\"N\"\n", - "print \"Vertical component = \",round(VC,1),\"N\"\n", - "print \"Component along crank =\",round(CAC,1),\"N\"\n", - "print \"Component normal to crank=\",round(CNC,1),\"N\"" - ] - } - ], - "metadata": { - "anaconda-cloud": {}, - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb b/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb deleted file mode 100755 index 0ded7c3f..00000000 --- a/sample_notebooks/Harshitgarg/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb +++ /dev/null @@ -1,366 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example1.1 Page number 10\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " The resultant velocity : 21.54 km/hour\n", - "68.2 °\n" - ] - } - ], - "source": [ - "#downstream direction as x\n", - "#direction across river as y\n", - "\n", - "from math import sqrt,atan,pi\n", - "\n", - "#variable declaration\n", - "\n", - "Vx= 8 #velocity of stream, km/hour\n", - "Vy=float(20) #velocity of boat,km/hour\n", - "\n", - "V=sqrt(pow(Vx,2)+pow(Vy,2)) #resultant velocity, km/hour\n", - "theta=Vy/Vx\n", - "\n", - "alpha= atan(theta)*180/pi #angle, degrees \n", - "\n", - "print \" The resultant velocity :\",round(V,2),\"km/hour\"\n", - "print round(alpha,2),\"°\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " example 1.2 Page number 10" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "10.0 KN (to the left)\n", - "17.32 KN (downward)\n" - ] - } - ], - "source": [ - "\n", - "\n", - "\n", - "#components of force in horizontal and vertical components. \n", - "from math import cos,sin,pi\n", - "#variable declaration\n", - "\n", - "F= 20 #force in wire, KN\n", - "\n", - "#calculations\n", - "Fx= F*cos(60*pi/180) \n", - "Fy= F*sin(60*pi/180)\n", - "\n", - "print round(Fx,2),\"KN\" ,\"(to the left)\"\n", - "print round(Fy,2), \"KN\" ,\"(downward)\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example 1.3 Page number 11" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Component normal to the plane : 9.4 KN\n", - "Component parallel to the plane : 3.42 KN\n" - ] - } - ], - "source": [ - "\n", - "\n", - " #The plane makes an angle of 20° to the horizontal. Hence the normal to the plane makes an angles of 70° to the horizontal i.e., 20° to the vertical\n", - "from math import cos,sin,pi\n", - "#variable declaration\n", - "W= 10 # black weighing, KN\n", - "\n", - "#calculations\n", - "\n", - "Nor= W*cos(20*pi/180) #Component normal to the plane\n", - "para= W*sin(20*pi/180) #Component parallel to the plane\n", - "\n", - "print \"Component normal to the plane :\",round(Nor,2),\"KN\"\n", - "print \"Component parallel to the plane :\",round(para,2) , \"KN\"\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example 1.4 Page number 11" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "F1= 100.0 N\n", - "F2= 200.0 N\n", - "theta= 63.9 °\n" - ] - } - ], - "source": [ - "\n", - "\n", - "#Let the magnitude of the smaller force be F. Hence the magnitude of the larger force is 2F\n", - "\n", - "from math import pi,sqrt, acos\n", - "#variable declaration\n", - "R1=260 #resultant of two forces,N\n", - "R2=float(180) #resultant of two forces if larger force is reversed,N\n", - "\n", - "\n", - "\n", - "#calculations\n", - "\n", - "F=sqrt((pow(R1,2)+pow(R2,2))/10)\n", - "F1=F\n", - "F2=2*F\n", - "theta=acos((pow(R1,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*180/pi\n", - "\n", - "print \"F1=\",F1,\"N\"\n", - "print \"F2=\",F2,\"N\"\n", - "print \"theta=\",round(theta,1),\"°\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example 1.5 Page number 12" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "F1= 326.35 N\n", - "F2= 223.24 N\n" - ] - } - ], - "source": [ - "\n", - "\n", - "#Let ?ABC be the triangle of forces drawn to some scale\n", - "#Two forces F1 and F2 are acting at point A\n", - "#angle in degrees '°'\n", - "\n", - "from math import sin,pi\n", - " \n", - "#variabble declaration\n", - "cnv=pi/180\n", - "\n", - "BAC = 20*cnv #Resultant R makes angle with F1 \n", - " \n", - "ABC = 130*cnv \n", - "\n", - "ACB = 30*cnv \n", - "\n", - "R = 500 #resultant force,N\n", - "\n", - "#calculations\n", - "#sinerule\n", - "\n", - "F1=R*sin(ACB)/sin(ABC)\n", - "F2=R*sin(BAC)/sin(ABC)\n", - "\n", - "print \"F1=\",round(F1,2),\"N\"\n", - "print \"F2=\",round(F2,2),\"N\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example 1.6 Page number 12" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "theta= 78.13 °\n", - "alpha= 29.29 °\n" - ] - } - ], - "source": [ - "\n", - "\n", - "#Let ABC be the triangle of forces,'theta' be the angle between F1 and F2, and 'alpha' be the angle between resultant and F1 \n", - "\n", - "from math import sin,acos,asin,pi\n", - "\n", - "#variable declaration\n", - "cnv= 180/pi\n", - "F1=float(400) #all forces are in newtons,'N'\n", - "F2=float(260)\n", - "R=float(520)\n", - "\n", - "#calculations\n", - "\n", - "theta=acos((pow(R,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*cnv\n", - "\n", - "alpha=asin(F2*sin(theta*pi/180)/R)*cnv\n", - "\n", - "print\"theta=\",round(theta,2),\"°\"\n", - "print \"alpha=\",round(alpha,2),\"°\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "example 1.7 Page number 13" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "horizontal component= 2814.2 N\n", - "Vertical component = 1039.2 N\n", - "Component along crank = 507.1 N\n", - "Component normal to crank= 2956.8 N\n" - ] - } - ], - "source": [ - "\n", - "\n", - "#The force of 3000 N acts along line AB. Let AB make angle alpha with horizontal.\n", - "\n", - "from math import cos,sin,pi,asin,acos\n", - "\n", - "#variable declaration\n", - "F=3000 #force in newtons,'N'\n", - "BC=80 #length of crank BC, 'mm'\n", - "AB=200 #length of connecting rod AB ,'mm'\n", - "theta=60*pi/180 #angle b/w BC & AC\n", - "\n", - "#calculations\n", - "\n", - "alpha=asin(BC*sin(theta)/200)*180/pi\n", - "\n", - "HC=F*cos(alpha*pi/180) #Horizontal component \n", - "VC= F*sin(alpha*pi/180) #Vertical component \n", - "\n", - "#Components along and normal to crank\n", - "#The force makes angle alpha + 60 with crank.\n", - "alpha2=alpha+60\n", - "CAC=F*cos(alpha2*pi/180) # Component along crank \n", - "CNC= F*sin(alpha2*pi/180) #Component normal to crank \n", - "\n", - "\n", - "print \"horizontal component=\",round(HC,1),\"N\"\n", - "print \"Vertical component = \",round(VC,1),\"N\"\n", - "print \"Component along crank =\",round(CAC,1),\"N\"\n", - "print \"Component normal to crank=\",round(CNC,1),\"N\"" - ] - } - ], - "metadata": { - "anaconda-cloud": {}, - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter1-INTRODUCTIONTOMECHANICSOFSOLIDS.ipynb b/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter1-INTRODUCTIONTOMECHANICSOFSOLIDS.ipynb new file mode 100755 index 00000000..c3a541b0 --- /dev/null +++ b/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter1-INTRODUCTIONTOMECHANICSOFSOLIDS.ipynb @@ -0,0 +1,223 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example1.1 Page number 10\n", + "#downstream direction as x\n", + "#direction across river as y\n", + "\n", + "from math import sqrt,atan,pi\n", + "\n", + "#variable declaration\n", + "\n", + "Vx= 8 #velocity of stream, km/hour\n", + "Vy=float(20) #velocity of boat,km/hour\n", + "\n", + "V=sqrt(pow(Vx,2)+pow(Vy,2)) #resultant velocity, km/hour\n", + "theta=Vy/Vx\n", + "\n", + "alpha= atan(theta)*180/pi #angle, degrees \n", + "\n", + "print \" The resultant velocity :\",round(V,2),\"km/hour\"\n", + "print round(alpha,2),\"°\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.2 Page number 10\n", + "\n", + "\n", + "#components of force in horizontal and vertical components. \n", + "from math import cos,sin,pi\n", + "#variable declaration\n", + "\n", + "F= 20 #force in wire, KN\n", + "\n", + "#calculations\n", + "Fx= F*cos(60*pi/180) \n", + "Fy= F*sin(60*pi/180)\n", + "\n", + "print round(Fx,2),\"KN\" ,\"(to the left)\"\n", + "print round(Fy,2), \"KN\" ,\"(downward)\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.3 Page number 11\n", + "\n", + " #The plane makes an angle of 20° to the horizontal. Hence the normal to the plane makes an angles of 70° to the horizontal i.e., 20° to the vertical\n", + "from math import cos,sin,pi\n", + "#variable declaration\n", + "W= 10 # black weighing, KN\n", + "\n", + "#calculations\n", + "\n", + "Nor= W*cos(20*pi/180) #Component normal to the plane\n", + "para= W*sin(20*pi/180) #Component parallel to the plane\n", + "\n", + "print \"Component normal to the plane :\",round(Nor,2),\"KN\"\n", + "print \"Component parallel to the plane :\",round(para,2) , \"KN\"\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.4 Page number 11\n", + "\n", + "#Let the magnitude of the smaller force be F. Hence the magnitude of the larger force is 2F\n", + "\n", + "from math import pi,sqrt, acos\n", + "#variable declaration\n", + "R1=260 #resultant of two forces,N\n", + "R2=float(180) #resultant of two forces if larger force is reversed,N\n", + "\n", + "\n", + "\n", + "#calculations\n", + "\n", + "F=sqrt((pow(R1,2)+pow(R2,2))/10)\n", + "F1=F\n", + "F2=2*F\n", + "theta=acos((pow(R1,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*180/pi\n", + "\n", + "print \"F1=\",F1,\"N\"\n", + "print \"F2=\",F2,\"N\"\n", + "print \"theta=\",round(theta,1),\"°\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.5 Page number 12\n", + "\n", + "#Let ?ABC be the triangle of forces drawn to some scale\n", + "#Two forces F1 and F2 are acting at point A\n", + "#angle in degrees '°'\n", + "\n", + "from math import sin,pi\n", + " \n", + "#variabble declaration\n", + "cnv=pi/180\n", + "\n", + "BAC = 20*cnv #Resultant R makes angle with F1 \n", + " \n", + "ABC = 130*cnv \n", + "\n", + "ACB = 30*cnv \n", + "\n", + "R = 500 #resultant force,N\n", + "\n", + "#calculations\n", + "#sinerule\n", + "\n", + "F1=R*sin(ACB)/sin(ABC)\n", + "F2=R*sin(BAC)/sin(ABC)\n", + "\n", + "print \"F1=\",round(F1,2),\"N\"\n", + "print \"F2=\",round(F2,2),\"N\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.6 Page number 12\n", + "\n", + "#Let ABC be the triangle of forces,'theta' be the angle between F1 and F2, and 'alpha' be the angle between resultant and F1 \n", + "\n", + "from math import sin,acos,asin,pi\n", + "\n", + "#variable declaration\n", + "cnv= 180/pi\n", + "F1=float(400) #all forces are in newtons,'N'\n", + "F2=float(260)\n", + "R=float(520)\n", + "\n", + "#calculations\n", + "\n", + "theta=acos((pow(R,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*cnv\n", + "\n", + "alpha=asin(F2*sin(theta*pi/180)/R)*cnv\n", + "\n", + "print\"theta=\",round(theta,2),\"°\"\n", + "print \"alpha=\",round(alpha,2),\"°\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# example 1.7 Page number 13\n", + "\n", + "#The force of 3000 N acts along line AB. Let AB make angle alpha with horizontal.\n", + "\n", + "from math import cos,sin,pi,asin,acos\n", + "\n", + "#variable declaration\n", + "F=3000 #force in newtons,'N'\n", + "BC=80 #length of crank BC, 'mm'\n", + "AB=200 #length of connecting rod AB ,'mm'\n", + "theta=60*pi/180 #angle b/w BC & AC\n", + "\n", + "#calculations\n", + "\n", + "alpha=asin(BC*sin(theta)/200)*180/pi\n", + "\n", + "HC=F*cos(alpha*pi/180) #Horizontal component \n", + "VC= F*sin(alpha*pi/180) #Vertical component \n", + "\n", + "#Components along and normal to crank\n", + "#The force makes angle alpha + 60 with crank.\n", + "alpha2=alpha+60\n", + "CAC=F*cos(alpha2*pi/180) # Component along crank \n", + "CNC= F*sin(alpha2*pi/180) #Component normal to crank \n", + "\n", + "\n", + "print \"horizontal component=\",round(HC,1),\"N\"\n", + "print \"Vertical component = \",round(VC,1),\"N\"\n", + "print \"Component along crank =\",round(CAC,1),\"N\"\n", + "print \"Component normal to crank=\",round(CNC,1),\"N\"" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb b/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb new file mode 100755 index 00000000..0ded7c3f --- /dev/null +++ b/sample_notebooks/Harshitgarg/Harshitgarg_version_backup/Chapter_1-INTRODUCTION_TO_MECHANICS_OF_SOLIDS__1.ipynb @@ -0,0 +1,366 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example1.1 Page number 10\n" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " The resultant velocity : 21.54 km/hour\n", + "68.2 °\n" + ] + } + ], + "source": [ + "#downstream direction as x\n", + "#direction across river as y\n", + "\n", + "from math import sqrt,atan,pi\n", + "\n", + "#variable declaration\n", + "\n", + "Vx= 8 #velocity of stream, km/hour\n", + "Vy=float(20) #velocity of boat,km/hour\n", + "\n", + "V=sqrt(pow(Vx,2)+pow(Vy,2)) #resultant velocity, km/hour\n", + "theta=Vy/Vx\n", + "\n", + "alpha= atan(theta)*180/pi #angle, degrees \n", + "\n", + "print \" The resultant velocity :\",round(V,2),\"km/hour\"\n", + "print round(alpha,2),\"°\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " example 1.2 Page number 10" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10.0 KN (to the left)\n", + "17.32 KN (downward)\n" + ] + } + ], + "source": [ + "\n", + "\n", + "\n", + "#components of force in horizontal and vertical components. \n", + "from math import cos,sin,pi\n", + "#variable declaration\n", + "\n", + "F= 20 #force in wire, KN\n", + "\n", + "#calculations\n", + "Fx= F*cos(60*pi/180) \n", + "Fy= F*sin(60*pi/180)\n", + "\n", + "print round(Fx,2),\"KN\" ,\"(to the left)\"\n", + "print round(Fy,2), \"KN\" ,\"(downward)\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example 1.3 Page number 11" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Component normal to the plane : 9.4 KN\n", + "Component parallel to the plane : 3.42 KN\n" + ] + } + ], + "source": [ + "\n", + "\n", + " #The plane makes an angle of 20° to the horizontal. Hence the normal to the plane makes an angles of 70° to the horizontal i.e., 20° to the vertical\n", + "from math import cos,sin,pi\n", + "#variable declaration\n", + "W= 10 # black weighing, KN\n", + "\n", + "#calculations\n", + "\n", + "Nor= W*cos(20*pi/180) #Component normal to the plane\n", + "para= W*sin(20*pi/180) #Component parallel to the plane\n", + "\n", + "print \"Component normal to the plane :\",round(Nor,2),\"KN\"\n", + "print \"Component parallel to the plane :\",round(para,2) , \"KN\"\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example 1.4 Page number 11" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "F1= 100.0 N\n", + "F2= 200.0 N\n", + "theta= 63.9 °\n" + ] + } + ], + "source": [ + "\n", + "\n", + "#Let the magnitude of the smaller force be F. Hence the magnitude of the larger force is 2F\n", + "\n", + "from math import pi,sqrt, acos\n", + "#variable declaration\n", + "R1=260 #resultant of two forces,N\n", + "R2=float(180) #resultant of two forces if larger force is reversed,N\n", + "\n", + "\n", + "\n", + "#calculations\n", + "\n", + "F=sqrt((pow(R1,2)+pow(R2,2))/10)\n", + "F1=F\n", + "F2=2*F\n", + "theta=acos((pow(R1,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*180/pi\n", + "\n", + "print \"F1=\",F1,\"N\"\n", + "print \"F2=\",F2,\"N\"\n", + "print \"theta=\",round(theta,1),\"°\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example 1.5 Page number 12" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "F1= 326.35 N\n", + "F2= 223.24 N\n" + ] + } + ], + "source": [ + "\n", + "\n", + "#Let ?ABC be the triangle of forces drawn to some scale\n", + "#Two forces F1 and F2 are acting at point A\n", + "#angle in degrees '°'\n", + "\n", + "from math import sin,pi\n", + " \n", + "#variabble declaration\n", + "cnv=pi/180\n", + "\n", + "BAC = 20*cnv #Resultant R makes angle with F1 \n", + " \n", + "ABC = 130*cnv \n", + "\n", + "ACB = 30*cnv \n", + "\n", + "R = 500 #resultant force,N\n", + "\n", + "#calculations\n", + "#sinerule\n", + "\n", + "F1=R*sin(ACB)/sin(ABC)\n", + "F2=R*sin(BAC)/sin(ABC)\n", + "\n", + "print \"F1=\",round(F1,2),\"N\"\n", + "print \"F2=\",round(F2,2),\"N\"\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example 1.6 Page number 12" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "theta= 78.13 °\n", + "alpha= 29.29 °\n" + ] + } + ], + "source": [ + "\n", + "\n", + "#Let ABC be the triangle of forces,'theta' be the angle between F1 and F2, and 'alpha' be the angle between resultant and F1 \n", + "\n", + "from math import sin,acos,asin,pi\n", + "\n", + "#variable declaration\n", + "cnv= 180/pi\n", + "F1=float(400) #all forces are in newtons,'N'\n", + "F2=float(260)\n", + "R=float(520)\n", + "\n", + "#calculations\n", + "\n", + "theta=acos((pow(R,2)-pow(F1,2)-pow(F2,2))/(2*F1*F2))*cnv\n", + "\n", + "alpha=asin(F2*sin(theta*pi/180)/R)*cnv\n", + "\n", + "print\"theta=\",round(theta,2),\"°\"\n", + "print \"alpha=\",round(alpha,2),\"°\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "example 1.7 Page number 13" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "horizontal component= 2814.2 N\n", + "Vertical component = 1039.2 N\n", + "Component along crank = 507.1 N\n", + "Component normal to crank= 2956.8 N\n" + ] + } + ], + "source": [ + "\n", + "\n", + "#The force of 3000 N acts along line AB. Let AB make angle alpha with horizontal.\n", + "\n", + "from math import cos,sin,pi,asin,acos\n", + "\n", + "#variable declaration\n", + "F=3000 #force in newtons,'N'\n", + "BC=80 #length of crank BC, 'mm'\n", + "AB=200 #length of connecting rod AB ,'mm'\n", + "theta=60*pi/180 #angle b/w BC & AC\n", + "\n", + "#calculations\n", + "\n", + "alpha=asin(BC*sin(theta)/200)*180/pi\n", + "\n", + "HC=F*cos(alpha*pi/180) #Horizontal component \n", + "VC= F*sin(alpha*pi/180) #Vertical component \n", + "\n", + "#Components along and normal to crank\n", + "#The force makes angle alpha + 60 with crank.\n", + "alpha2=alpha+60\n", + "CAC=F*cos(alpha2*pi/180) # Component along crank \n", + "CNC= F*sin(alpha2*pi/180) #Component normal to crank \n", + "\n", + "\n", + "print \"horizontal component=\",round(HC,1),\"N\"\n", + "print \"Vertical component = \",round(VC,1),\"N\"\n", + "print \"Component along crank =\",round(CAC,1),\"N\"\n", + "print \"Component normal to crank=\",round(CNC,1),\"N\"" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/HeminChheda/HeminChheda_version_backup/chapter1.ipynb b/sample_notebooks/HeminChheda/HeminChheda_version_backup/chapter1.ipynb new file mode 100755 index 00000000..af04eee8 --- /dev/null +++ b/sample_notebooks/HeminChheda/HeminChheda_version_backup/chapter1.ipynb @@ -0,0 +1,281 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Water" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example no:1,Page no:1.7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "W1=219.0 #amount of Mg(HCO3)2 in water in ppm#\n", + "W2=36.0 #amount of Mg2+ in water in ppm#\n", + "W3=18.3 #amount of (HCO3)- in water in ppm#\n", + "W4=1.5 #amount of H+_in water in ppm#\n", + "M1=100/146.0 #multiplication factor of Mg(HCO3)2#\n", + "M2=100/24.0 #multiplication factor of Mg(HCO3)2#\n", + "M3=100/122.0 #multiplication factor of Mg(HCO3)2#\n", + "M4=100/2.0 #multiplication factor of Mg(HCO3)2#\n", + "\n", + "#Calculation\n", + "P1=W1*M1 #in terms of CaCO3#\n", + "P2=W2*M2 #in terms of CaCO3#\n", + "P3=W3*M3 #in terms of CaCO3#\n", + "P4=W4*M4 #in terms of CaCO3#\n", + "L=0.74*((2*P1)+P2+P3+P4) \n", + "\n", + "R=1.0 #water supply rate in m**3/s#\n", + "D=R*60.0*60.0*24.0*L \n", + "K=D*1000.0 #in lit/day#\n", + "T=K/10.0**9 #in tonnes#\n", + "S=1.06*(P2+P4-P3) \n", + "D2=R*60*60*24*S \n", + "A=D2*1000 #in lit/day#\n", + "B=A/10.0**9 #in tonnes#\n", + "J1=90/100.0 #purity of lime#\n", + "J2=95/100.0 #purity of soda#\n", + "C1=500.0 #cost of one tonne lime#\n", + "C2=7000.0 #cost of one tonne soda#\n", + "CL=round(T,1)*C1/J1 \n", + "print\"\\ncost of lime is\",CL,\"Rs\"\n", + "CS=round(B,1)*C2/J2 \n", + "print\"\\ncost of soda is \",CS,\"Rs\"\n", + "C=CL+CS \n", + "\n", + "#Result\n", + "print\"\\ntotal cost is \",round(C) ,\"Rs\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "cost of lime is 19166.6666667 Rs\n", + "\n", + "cost of soda is 141473.684211 Rs\n", + "\n", + "total cost is 160640.0 Rs\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example no:15,Page no:1.25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "W1=40.0 #amount of Ca2+ in water in mg/l#\n", + "W2=24.0 #amount of Mg2+ in water in mg/l#\n", + "W3=8.05 #amount of Na+ in water in mg/l#\n", + "W4=183.0 #amount of (HCO3)- in water in mg/l#\n", + "W5=55.68 #amount of (SO4)2- in water in mg/l#\n", + "W6=6.74 #amount of Cl- in water in mg/l#\n", + "M1=100/40.0 #multiplication factor of Ca2+#\n", + "M2=100/24.0 #multiplication factor of Mg2+#\n", + "M3=100/(23.0*2) #multiplication factor of Na+#\n", + "M4=100/(61.0*2) #multiplication factor of (HCO3)-#\n", + "M5=100/96.0 #multiplication factor of (SO4)2-#\n", + "M6=100/(35.5*2) #multiplication factor of Cl-#\n", + "\n", + "#Calculation\n", + "P1=W1*M1 #in terms of CaCO3#\n", + "P2=W2*M2 #in terms of CaCO3#\n", + "P3=W3*M3 #in terms of CaCO3#\n", + "P4=W4*M4 #in terms of CaCO3#\n", + "P5=W5*M5 #in terms of CaCO3#\n", + "P6=W6*M6 #in terms of CaCO3#\n", + "\n", + "\n", + "#Result\n", + "print\"\\nCalcium alkalinity =\",P1,\"ppm\" \n", + "print\"\\nMagnesium alkalinity =\",P4-P1,\"ppm\"\n", + "print\"\\n total alkalinity = \",P1+P4-P1,\"ppm\"\n", + "print\"\\n total hardness = \",P1+P2,\"ppm\"\n", + "print\"\\nCa temporary hardness = \",P1,\"ppm\"\n", + "print\"\\nMg temporary hardness = \",P4-P1,\"ppm\"\n", + "print\"\\nMg permanant hardness = \",P2-(P4-P1),\"ppm\"\n", + "print\"\\nSalts are:\"\n", + "print\"\\nCa(HCO3)2 salt = \",P1,\"ppm\"\n", + "print\"\\nMg(HCO3)2 salt = \",P4-P1,\"ppm\"\n", + "print\"\\nMgSO4 salt = \",P2-(P4-P1),\"ppm\"\n", + "print\"\\nNaCl salt = \",P6,\"ppm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Calcium alkalinity = 100.0 ppm\n", + "\n", + "Magnesium alkalinity = 50.0 ppm\n", + "\n", + " total alkalinity = 150.0 ppm\n", + "\n", + " total hardness = 200.0 ppm\n", + "\n", + "Ca temporary hardness = 100.0 ppm\n", + "\n", + "Mg temporary hardness = 50.0 ppm\n", + "\n", + "Mg permanant hardness = 50.0 ppm\n", + "\n", + "Salts are:\n", + "\n", + "Ca(HCO3)2 salt = 100.0 ppm\n", + "\n", + "Mg(HCO3)2 salt = 50.0 ppm\n", + "\n", + "MgSO4 salt = 50.0 ppm\n", + "\n", + "NaCl salt = 9.49295774648 ppm\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example no:19,Page no:1.39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "P=4.7 #required HCl in ml using HpH indicator #\n", + "H=10.5 #required HCl im ml using MeOH indicator#\n", + "M=P+H \n", + "N=0.02 #normality of HCl#\n", + "\n", + "print\"\\nSince P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\"\n", + "C=50 #equivalent of CaCO3 in mg for 1ml 1N HCl#\n", + "\n", + "#Calculation\n", + "A=C*(2*P)*N #amount of (CO3)2- alkalinity in mg in 100 ml of water#\n", + "B=A*1000/100 \n", + "D=C*(M-2*P)*N #the amount of (HCO3)- alkalinity in mg in 100 ml of water#\n", + "E=D*1000/100 \n", + "T=B+E \n", + "\n", + "#Result\n", + "print\"\\nTotal alkalinity is \",T,\"mg/l or ppm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Since P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\n", + "\n", + "Total alkalinity is 152.0 mg/l or ppm\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example no:25,Page no:1.56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "W1=160.0 #amount of Ca2+ in ppm#\n", + "W2=88.0 #amount of Mg2+ in ppm#\n", + "W3=72.0 #amount of CO2 in ppm#\n", + "W4=488.0 #amount of (HCO3)- in ppm#\n", + "W5=139.0 #amount of (FeSO4).7H2O in ppm#\n", + "M1=100/40.0 #multiplication factor of Ca2+#\n", + "M2=100/24.0 #multiplication factor of Mg2+#\n", + "M3=100/44.0 #multiplication factor of CO2#\n", + "M4=100/(61.0*2.0) #multiplication factor of (HCO3)-#\n", + "M5=100/278.0 #multiplication factor of (FeSO4).7H2O#\n", + "\n", + "P1=400 #in terms of CaCO3#\n", + "P2=300 #in terms of CaCO3#\n", + "P3=200 #in terms of CaCO3#\n", + "P4=400 #in terms of CaCO3#\n", + "P5=50 #in terms of CaCO3#\n", + "V=100000.0 #volume of water in litres#\n", + "\n", + "\n", + "#Calculation\n", + "L=0.74*(P2+P3+P4+P5)*V #lime required in mg#\n", + "L=L/10.0**6 \n", + "S=1.06*(P1+P2+P5-P4)*V #soda required in mg#\n", + "S=S/10.0**6 \n", + "\n", + "#Result\n", + "print\"Lime required is \",L,\"kg\"\n", + "print\"\\nSoda required is \",S,\"kg\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Lime required is 70.3 kg\n", + "\n", + "Soda required is 37.1 kg\n" + ] + } + ], + "prompt_number": 4 + }, + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/HeminChheda/chapter1.ipynb b/sample_notebooks/HeminChheda/chapter1.ipynb deleted file mode 100755 index af04eee8..00000000 --- a/sample_notebooks/HeminChheda/chapter1.ipynb +++ /dev/null @@ -1,281 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Water" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example no:1,Page no:1.7" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "W1=219.0 #amount of Mg(HCO3)2 in water in ppm#\n", - "W2=36.0 #amount of Mg2+ in water in ppm#\n", - "W3=18.3 #amount of (HCO3)- in water in ppm#\n", - "W4=1.5 #amount of H+_in water in ppm#\n", - "M1=100/146.0 #multiplication factor of Mg(HCO3)2#\n", - "M2=100/24.0 #multiplication factor of Mg(HCO3)2#\n", - "M3=100/122.0 #multiplication factor of Mg(HCO3)2#\n", - "M4=100/2.0 #multiplication factor of Mg(HCO3)2#\n", - "\n", - "#Calculation\n", - "P1=W1*M1 #in terms of CaCO3#\n", - "P2=W2*M2 #in terms of CaCO3#\n", - "P3=W3*M3 #in terms of CaCO3#\n", - "P4=W4*M4 #in terms of CaCO3#\n", - "L=0.74*((2*P1)+P2+P3+P4) \n", - "\n", - "R=1.0 #water supply rate in m**3/s#\n", - "D=R*60.0*60.0*24.0*L \n", - "K=D*1000.0 #in lit/day#\n", - "T=K/10.0**9 #in tonnes#\n", - "S=1.06*(P2+P4-P3) \n", - "D2=R*60*60*24*S \n", - "A=D2*1000 #in lit/day#\n", - "B=A/10.0**9 #in tonnes#\n", - "J1=90/100.0 #purity of lime#\n", - "J2=95/100.0 #purity of soda#\n", - "C1=500.0 #cost of one tonne lime#\n", - "C2=7000.0 #cost of one tonne soda#\n", - "CL=round(T,1)*C1/J1 \n", - "print\"\\ncost of lime is\",CL,\"Rs\"\n", - "CS=round(B,1)*C2/J2 \n", - "print\"\\ncost of soda is \",CS,\"Rs\"\n", - "C=CL+CS \n", - "\n", - "#Result\n", - "print\"\\ntotal cost is \",round(C) ,\"Rs\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "cost of lime is 19166.6666667 Rs\n", - "\n", - "cost of soda is 141473.684211 Rs\n", - "\n", - "total cost is 160640.0 Rs\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example no:15,Page no:1.25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "W1=40.0 #amount of Ca2+ in water in mg/l#\n", - "W2=24.0 #amount of Mg2+ in water in mg/l#\n", - "W3=8.05 #amount of Na+ in water in mg/l#\n", - "W4=183.0 #amount of (HCO3)- in water in mg/l#\n", - "W5=55.68 #amount of (SO4)2- in water in mg/l#\n", - "W6=6.74 #amount of Cl- in water in mg/l#\n", - "M1=100/40.0 #multiplication factor of Ca2+#\n", - "M2=100/24.0 #multiplication factor of Mg2+#\n", - "M3=100/(23.0*2) #multiplication factor of Na+#\n", - "M4=100/(61.0*2) #multiplication factor of (HCO3)-#\n", - "M5=100/96.0 #multiplication factor of (SO4)2-#\n", - "M6=100/(35.5*2) #multiplication factor of Cl-#\n", - "\n", - "#Calculation\n", - "P1=W1*M1 #in terms of CaCO3#\n", - "P2=W2*M2 #in terms of CaCO3#\n", - "P3=W3*M3 #in terms of CaCO3#\n", - "P4=W4*M4 #in terms of CaCO3#\n", - "P5=W5*M5 #in terms of CaCO3#\n", - "P6=W6*M6 #in terms of CaCO3#\n", - "\n", - "\n", - "#Result\n", - "print\"\\nCalcium alkalinity =\",P1,\"ppm\" \n", - "print\"\\nMagnesium alkalinity =\",P4-P1,\"ppm\"\n", - "print\"\\n total alkalinity = \",P1+P4-P1,\"ppm\"\n", - "print\"\\n total hardness = \",P1+P2,\"ppm\"\n", - "print\"\\nCa temporary hardness = \",P1,\"ppm\"\n", - "print\"\\nMg temporary hardness = \",P4-P1,\"ppm\"\n", - "print\"\\nMg permanant hardness = \",P2-(P4-P1),\"ppm\"\n", - "print\"\\nSalts are:\"\n", - "print\"\\nCa(HCO3)2 salt = \",P1,\"ppm\"\n", - "print\"\\nMg(HCO3)2 salt = \",P4-P1,\"ppm\"\n", - "print\"\\nMgSO4 salt = \",P2-(P4-P1),\"ppm\"\n", - "print\"\\nNaCl salt = \",P6,\"ppm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Calcium alkalinity = 100.0 ppm\n", - "\n", - "Magnesium alkalinity = 50.0 ppm\n", - "\n", - " total alkalinity = 150.0 ppm\n", - "\n", - " total hardness = 200.0 ppm\n", - "\n", - "Ca temporary hardness = 100.0 ppm\n", - "\n", - "Mg temporary hardness = 50.0 ppm\n", - "\n", - "Mg permanant hardness = 50.0 ppm\n", - "\n", - "Salts are:\n", - "\n", - "Ca(HCO3)2 salt = 100.0 ppm\n", - "\n", - "Mg(HCO3)2 salt = 50.0 ppm\n", - "\n", - "MgSO4 salt = 50.0 ppm\n", - "\n", - "NaCl salt = 9.49295774648 ppm\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example no:19,Page no:1.39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "P=4.7 #required HCl in ml using HpH indicator #\n", - "H=10.5 #required HCl im ml using MeOH indicator#\n", - "M=P+H \n", - "N=0.02 #normality of HCl#\n", - "\n", - "print\"\\nSince P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\"\n", - "C=50 #equivalent of CaCO3 in mg for 1ml 1N HCl#\n", - "\n", - "#Calculation\n", - "A=C*(2*P)*N #amount of (CO3)2- alkalinity in mg in 100 ml of water#\n", - "B=A*1000/100 \n", - "D=C*(M-2*P)*N #the amount of (HCO3)- alkalinity in mg in 100 ml of water#\n", - "E=D*1000/100 \n", - "T=B+E \n", - "\n", - "#Result\n", - "print\"\\nTotal alkalinity is \",T,\"mg/l or ppm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Since P<0.5*M sample contain (CO3)2- and (HCO3)- alkalinity\n", - "\n", - "Total alkalinity is 152.0 mg/l or ppm\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example no:25,Page no:1.56" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "W1=160.0 #amount of Ca2+ in ppm#\n", - "W2=88.0 #amount of Mg2+ in ppm#\n", - "W3=72.0 #amount of CO2 in ppm#\n", - "W4=488.0 #amount of (HCO3)- in ppm#\n", - "W5=139.0 #amount of (FeSO4).7H2O in ppm#\n", - "M1=100/40.0 #multiplication factor of Ca2+#\n", - "M2=100/24.0 #multiplication factor of Mg2+#\n", - "M3=100/44.0 #multiplication factor of CO2#\n", - "M4=100/(61.0*2.0) #multiplication factor of (HCO3)-#\n", - "M5=100/278.0 #multiplication factor of (FeSO4).7H2O#\n", - "\n", - "P1=400 #in terms of CaCO3#\n", - "P2=300 #in terms of CaCO3#\n", - "P3=200 #in terms of CaCO3#\n", - "P4=400 #in terms of CaCO3#\n", - "P5=50 #in terms of CaCO3#\n", - "V=100000.0 #volume of water in litres#\n", - "\n", - "\n", - "#Calculation\n", - "L=0.74*(P2+P3+P4+P5)*V #lime required in mg#\n", - "L=L/10.0**6 \n", - "S=1.06*(P1+P2+P5-P4)*V #soda required in mg#\n", - "S=S/10.0**6 \n", - "\n", - "#Result\n", - "print\"Lime required is \",L,\"kg\"\n", - "print\"\\nSoda required is \",S,\"kg\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Lime required is 70.3 kg\n", - "\n", - "Soda required is 37.1 kg\n" - ] - } - ], - "prompt_number": 4 - }, - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Hrituraj/Ch-6.ipynb b/sample_notebooks/Hrituraj/Ch-6.ipynb deleted file mode 100755 index 63e7e1c5..00000000 --- a/sample_notebooks/Hrituraj/Ch-6.ipynb +++ /dev/null @@ -1,540 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Ch-6 : Frequency response, bode plots and resonance" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.1 Page No: 476" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "peak value of Vout = 6.00 volts\n", - "phase angle of Vout = 70.00 degrees\n", - "with frequency equal to = 1000.00\n" - ] - } - ], - "source": [ - "from math import pi, cos, sin, atan, sqrt\n", - "# given V_in(t)=2*cos(2000*pi*t+A), A=40*pi/180\n", - "w=2000*pi# #omega\n", - "f=w/(2*pi)# #frequency\n", - "A=40*pi/180# #40 degrees = %0.2f radians\n", - "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", - "H_max=(4000-f)/1000# #magnitude of H(traansfer function)\n", - "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", - "H_phi=pi*f/6000# #phase angle of H\n", - "H=H_max*complex(cos(H_phi),sin(H_phi))\n", - "V_in=2*complex(cos(A),sin(A))# #input voltage phasor\n", - "V_out=H*V_in# #output voltage phasor\n", - "V_out_R=(V_out.real)# #real part\n", - "V_out_I=(V_out.imag)# #imaginary part\n", - "V_out_max=sqrt((V_out_R**2)+(V_out_I**2))# #peak value\n", - "V_out_phi=atan(V_out_I/V_out_R)\n", - "print 'peak value of Vout = %0.2f volts'%V_out_max\n", - "print 'phase angle of Vout = %0.2f degrees'%(V_out_phi*180/pi)\n", - "print 'with frequency equal to = %0.2f'%f" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.2 Page No: 477" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Output voltage is Vout1+Vout2+Vout3 where\n", - "\n", - "FOR Vout1:\n", - "peak value = 12.00 volts\n", - "phase angle = 0.00 degrees\n", - "with frequency = 0.00 hertz\n", - "\n", - "FOR Vout2:\n", - "peak value = 6.00 volts\n", - "phase angle = 30.00 degrees\n", - "with frequency = 1000.00 hertz\n", - "\n", - "FOR Vout3:\n", - "peak value = 2.00 volts\n", - "phase angle = -10.00 degrees\n", - "with frequency = 2000.00 hertz\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "#given V_in(t)=3+2*cos(2000*pi*t)+cos(4000*pi*t-A), A=70*pi/180\n", - "#the three parts of V_in(t) are V_in_1=3, V_in_2=2*cos(2000*pi*t),V_in_3=cos(4000*pi*t-A)\n", - "\n", - "#first component V_1\n", - "V_in_1=3\n", - "f_1=0# #as omega is zero\n", - "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", - "H_1_max=(4000-f_1)/1000# #magnitude of H(traansfer function)\n", - "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", - "H_1_phi=pi*f_1/6000# #phase angle of H\n", - "H_1=H_1_max*complex(cos(H_1_phi),sin(H_1_phi))\n", - "V_out_1=H_1*V_in_1\n", - "V_out_1_R=(V_out_1).real# #real part\n", - "V_out_1_I=(V_out_1).imag# #imaginary part\n", - "V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n", - "V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n", - "\n", - "#second component V_in_2\n", - "V_in_2=2*complex(cos(0),sin(0))# #V_in_2 phasor\n", - "w=2000*pi# #omega\n", - "f_2=w/(2*pi)# #frequency\n", - "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", - "H_2_max=(4000-f_2)/1000# #magnitude of H(traansfer function)\n", - "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", - "H_2_phi=pi*f_2/6000# #phase angle of H\n", - "H_2=H_2_max*complex(cos(H_2_phi),sin(H_2_phi))\n", - "V_out_2=H_2*V_in_2\n", - "V_out_2_R=(V_out_2).real# #real part\n", - "V_out_2_I=(V_out_2).imag# #imaginary part\n", - "V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n", - "V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n", - "\n", - "#third component\n", - "A=-70*pi/180# #-70 degrees = %0.2f radians\n", - "V_in_3=complex(cos(A),sin(A))# #V_in_3 phasor\n", - "w=4000*pi# #omega\n", - "f_3=w/(2*pi)# #frequency\n", - "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", - "H_3_max=(4000-f_3)/1000# #magnitude of H(traansfer function)\n", - "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", - "H_3_phi=pi*f_3/6000# #phase angle of H\n", - "H_3=H_3_max*complex(cos(H_3_phi),sin(H_3_phi))\n", - "V_out_3=H_3*V_in_3\n", - "V_out_3_R=(V_out_3).real# #real part\n", - "V_out_3_I=(V_out_3).imag# #imaginary part\n", - "V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n", - "V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n", - "\n", - "print 'Output voltage is Vout1+Vout2+Vout3 where'\n", - "print ''\n", - "print 'FOR Vout1:'\n", - "print 'peak value = %0.2f volts'%V_out_1_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_1\n", - "print ''\n", - "print 'FOR Vout2:'\n", - "print 'peak value = %0.2f volts'%V_out_2_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_2\n", - "print ''\n", - "print 'FOR Vout3:'\n", - "print 'peak value = %0.2f volts'%V_out_3_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.3 Page No: 477" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", - "Output voltage is Vout1+Vout2+Vout3 where\n", - "\n", - "FOR Vout1:\n", - "peak value = 4.98 volts\n", - "phase angle = -5.71 degrees\n", - "with frequency = 10.00 hertz\n", - "\n", - "FOR Vout2:\n", - "peak value = 3.54 volts\n", - "phase angle = -45.00 degrees\n", - "with frequency = 100.00 hertz\n", - "\n", - "FOR Vout3:\n", - "peak value = 0.50 volts\n", - "phase angle = -84.29 degrees\n", - "with frequency = 1000.00 hertz\n" - ] - } - ], - "source": [ - "R=1000/(2*pi)# #resistance\n", - "C=10*10**-6# #capacitance\n", - "f_B=1/(2*pi*R*C)# #half-power frequency\n", - "#the three parts of V_in are V_1=5*cos(20*pi*t)+5*cos(200*pi*t)+5*cos(2000*pi*t)\n", - "\n", - "#first component V_in_1\n", - "V_in_1=5*complex(cos(0),sin(0))# #V_in_1 phasor\n", - "w_1=20*pi# #omega\n", - "f_1=w_1/(2*pi)# #frequency\n", - "H_1=1/(1+1J*(f_1/f_B))# #transfer function\n", - "V_out_1=H_1*V_in_1\n", - "V_out_1_R=(V_out_1).real# #real part\n", - "V_out_1_I=(V_out_1).imag# #imaginary part\n", - "V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n", - "V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n", - "\n", - "#second component V_in_2\n", - "V_in_2=5*complex(cos(0),sin(0))# #V_in_2 phasor\n", - "w_2=200*pi# #omega\n", - "f_2=w_2/(2*pi)# #frequency\n", - "H_2=1/(1+1J*(f_2/f_B))# #transfer function\n", - "V_out_2=H_2*V_in_2\n", - "V_out_2_R=(V_out_2).real #real part\n", - "V_out_2_I=(V_out_2).imag #imaginary part\n", - "V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n", - "V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n", - "\n", - "#third component V_in_3\n", - "V_in_3=5*complex(cos(0),sin(0))# #V_in_3 phasor\n", - "w_3=2000*pi# #omega\n", - "f_3=w_3/(2*pi)# #frequency\n", - "H_3=1/(1+1J*(f_3/f_B))# #transfer function\n", - "V_out_3=H_3*V_in_3\n", - "V_out_3_R=(V_out_3).real #real part\n", - "V_out_3_I=(V_out_3).imag #imaginary part\n", - "V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n", - "V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n", - "\n", - "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", - "print 'Output voltage is Vout1+Vout2+Vout3 where'\n", - "print ''\n", - "print 'FOR Vout1:'\n", - "print 'peak value = %0.2f volts'%V_out_1_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_1\n", - "print ''\n", - "print 'FOR Vout2:'\n", - "print 'peak value = %0.2f volts'%V_out_2_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_2\n", - "print ''\n", - "print 'FOR Vout3:'\n", - "print 'peak value = %0.2f volts'%V_out_3_max\n", - "print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n", - "print 'with frequency = %0.2f hertz'%f_3\n", - "#we can observe that there is a clear discrimination = %0.2f output signals based on frequencies i.e, lesser the frequency lesser the effect." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.4 Page No: 478" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", - "Break frequency = 1897.37 Hz\n" - ] - } - ], - "source": [ - "H_max=-30# #transfer function magnitude\n", - "f=60\n", - "m=20# #low-frequency asymptote slope rate = %0.2f db/decade\n", - "#f_B must be K higher than f where K is\n", - "K=abs(H_max)/m\n", - "#(base 10)log(f_B/60)=1.5 ==>\n", - "f_B=60*10**1.5\n", - "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", - "print 'Break frequency = %0.2f Hz'%f_B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.5 Page No: 479" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Phasor voltage across Resistance\n", - "peak value = 1.00 volts\n", - "phase angle = 0.00 degrees\n", - "\n", - "Phasor voltage across Inductance\n", - "peak value = 10.00 volts\n", - "phase angle = 90.00 degrees\n", - "\n", - "Phasor voltage across Capacitance\n", - "peak value = 10.00 volts\n", - "phase angle = -90.00 degrees\n" - ] - } - ], - "source": [ - "V_s=1*complex(cos(0),sin(0))\n", - "L=159.2*10**-3\n", - "R=100\n", - "C=0.1592*10**-6\n", - "f_o=1/(2*pi*sqrt(L*C))# #resonant frequency\n", - "Q_s=2*pi*f_o*L/R# #quality factor\n", - "B=f_o/Q_s# #Bandwidth\n", - "#Approximate half-power frequencies are\n", - "f_H=f_o+(B/2)\n", - "f_L=f_o-(B/2)\n", - "#At resonance\n", - "Z_L=1J*2*pi*f_o*L# #impedance of inductance\n", - "Z_C=-1J/(2*pi*f_o*C)# #impedance of capacitance\n", - "Z_s=R+Z_L+Z_C\n", - "I=V_s/Z_s# #phasor current\n", - "#voltages across diffrent elements are\n", - "#for resistance\n", - "V_R=R*I\n", - "V_R_R=(V_R).real #real part\n", - "V_R_I=(V_R).imag #imaginary part\n", - "V_R_max=sqrt((V_R_R**2)+(V_R_I**2))# #peak value\n", - "V_R_phi=atan(V_R_I/V_R_R)# #phase angle\n", - "#for inductance\n", - "V_L=Z_L*I\n", - "V_L_R=(V_L).real #real part\n", - "V_L_I=(V_L).imag #imaginary part\n", - "V_L_max=sqrt((V_L_R**2)+(V_L_I**2))# #peak value\n", - "#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n", - "if ((V_L/1J)==abs(V_L)):\n", - " V_L_phi=pi/2\n", - "elif ((V_L/1J)==-abs(V_L)):\n", - " V_L_phi=-pi/2\n", - "\n", - "\n", - "#for capacitance\n", - "V_C=Z_C*I\n", - "V_C_R=(V_C).real #real part\n", - "V_C_I=(V_C).imag #imaginary part\n", - "V_C_max=sqrt((V_C_R**2)+(V_C_I**2))# #peak value\n", - "#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n", - "if ((V_C/1J)==abs(V_C)) :\n", - " V_C_phi=pi/2\n", - "elif ((V_C/1J)==-abs(V_C)) :\n", - " V_C_phi=-pi/2\n", - "\n", - " \n", - "print 'Phasor voltage across Resistance'\n", - "print 'peak value = %0.2f volts'%V_R_max\n", - "print 'phase angle = %0.2f degrees'%(V_R_phi*180/pi)\n", - "print ''\n", - "print 'Phasor voltage across Inductance'\n", - "print 'peak value = %0.2f volts'%V_L_max\n", - "print 'phase angle = %0.2f degrees'%(V_L_phi*180/pi)\n", - "print ''\n", - "print 'Phasor voltage across Capacitance'\n", - "print 'peak value = %0.2f volts'%V_C_max\n", - "print 'phase angle = %0.2f degrees'%(V_C_phi*180/pi)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.6 Page No: 480" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current phasor across Resistance\n", - "peak value = 0.001 amperes\n", - "phase angle = 0 degrees\n", - "\n", - "Current phasor across Inductance\n", - "peak value = 0.010 amperes\n", - "phase angle = -90.00 degrees\n", - "\n", - "current phasor across capacitance\n", - "peak value = 0.010 amperes\n", - "phase angle = 90.00 degrees\n" - ] - } - ], - "source": [ - "R=10*10**3\n", - "f_o=1*10**6\n", - "B=100*10**3\n", - "I=10**-3*complex(cos(0),sin(0))\n", - "Q_p=f_o/B# #quality factor\n", - "L=R/(2*pi*f_o*Q_p)\n", - "C=Q_p/(2*pi*f_o*R)\n", - "#At resonance\n", - "V_out=I*R\n", - "Z_L=1J*2*pi*f_o*L\n", - "Z_C=-1J/(2*pi*f_o*C)\n", - "\n", - "#across resistance\n", - "I_R=V_out/R\n", - "I_R_R=(I_R).real# #real part\n", - "I_R_I=(I_R).imag# #imaginary part\n", - "I_R_max=sqrt((I_R_R**2)+(I_R_I**2))# #peak value\n", - "I_R_phi=atan(I_R_I/I_R_R)# #phase angle\n", - "\n", - "#across inductance\n", - "I_L=V_out/Z_L\n", - "I_L_R=(I_L).real #real part\n", - "I_L_I=(I_L).imag# #imaginary part\n", - "I_L_max=sqrt((I_L_R**2)+(I_L_I**2))# #peak value\n", - "#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n", - "if ((I_L/1J)==abs(I_L)):\n", - " I_L_phi=pi/2\n", - "elif ((I_L/1J)==-abs(I_L)) :\n", - " I_L_phi=-pi/2\n", - "\n", - "\n", - "#across capacitor\n", - "I_C=V_out/Z_C\n", - "I_C_R=(I_C).real# #real part\n", - "I_C_I=(I_C).imag# #imaginary part\n", - "I_C_max=sqrt((I_C_R**2)+(I_C_I**2))# #peak value\n", - "#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n", - "if ((I_C/1J)==abs(I_C)):\n", - " I_C_phi=pi/2\n", - "elif ((I_C/1J)==-abs(I_C)) :\n", - " I_C_phi=-pi/2\n", - "\n", - "\n", - "print 'Current phasor across Resistance'\n", - "print 'peak value = %0.3f amperes'%I_R_max\n", - "print 'phase angle = %0.f degrees'%(I_R_phi*180/pi)\n", - "print ''\n", - "print 'Current phasor across Inductance'\n", - "print 'peak value = %0.3f amperes'%I_L_max\n", - "print 'phase angle = %0.2f degrees'%(I_L_phi*180/pi)\n", - "print ''\n", - "print 'current phasor across capacitance'\n", - "print 'peak value = %0.3f amperes'%I_C_max\n", - "print 'phase angle = %0.2f degrees'%(I_C_phi*180/pi)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 6.7 Page No: 481" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", - "\n", - "The required second order circuit configuration is\n", - "Inductance = 50.00 KH\n", - "Capacitance = 0.51 mF(micro Farads)\n", - "Resistance = 314.16 ohms\n" - ] - } - ], - "source": [ - "#We need a high-pass filter\n", - "L=50*10**-3\n", - "#for the transfer function to be approximately constant = %0.2f passband area(from graph given = %0.2f the text), we choose\n", - "Q_s=1\n", - "f_o=1*10**3\n", - "C=1/(((2*pi)**2)*f_o**2*L)\n", - "R=2*pi*f_o*L/Q_s\n", - "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", - "print ''\n", - "print 'The required second order circuit configuration is'\n", - "print 'Inductance = %0.2f KH'%(L*10**3)\n", - "print 'Capacitance = %0.2f mF(micro Farads)'%(C*10**6)\n", - "print 'Resistance = %0.2f ohms'%R\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Hrituraj/Hrituraj_version_backup/Ch-6.ipynb b/sample_notebooks/Hrituraj/Hrituraj_version_backup/Ch-6.ipynb new file mode 100755 index 00000000..63e7e1c5 --- /dev/null +++ b/sample_notebooks/Hrituraj/Hrituraj_version_backup/Ch-6.ipynb @@ -0,0 +1,540 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Ch-6 : Frequency response, bode plots and resonance" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.1 Page No: 476" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "peak value of Vout = 6.00 volts\n", + "phase angle of Vout = 70.00 degrees\n", + "with frequency equal to = 1000.00\n" + ] + } + ], + "source": [ + "from math import pi, cos, sin, atan, sqrt\n", + "# given V_in(t)=2*cos(2000*pi*t+A), A=40*pi/180\n", + "w=2000*pi# #omega\n", + "f=w/(2*pi)# #frequency\n", + "A=40*pi/180# #40 degrees = %0.2f radians\n", + "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", + "H_max=(4000-f)/1000# #magnitude of H(traansfer function)\n", + "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", + "H_phi=pi*f/6000# #phase angle of H\n", + "H=H_max*complex(cos(H_phi),sin(H_phi))\n", + "V_in=2*complex(cos(A),sin(A))# #input voltage phasor\n", + "V_out=H*V_in# #output voltage phasor\n", + "V_out_R=(V_out.real)# #real part\n", + "V_out_I=(V_out.imag)# #imaginary part\n", + "V_out_max=sqrt((V_out_R**2)+(V_out_I**2))# #peak value\n", + "V_out_phi=atan(V_out_I/V_out_R)\n", + "print 'peak value of Vout = %0.2f volts'%V_out_max\n", + "print 'phase angle of Vout = %0.2f degrees'%(V_out_phi*180/pi)\n", + "print 'with frequency equal to = %0.2f'%f" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.2 Page No: 477" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Output voltage is Vout1+Vout2+Vout3 where\n", + "\n", + "FOR Vout1:\n", + "peak value = 12.00 volts\n", + "phase angle = 0.00 degrees\n", + "with frequency = 0.00 hertz\n", + "\n", + "FOR Vout2:\n", + "peak value = 6.00 volts\n", + "phase angle = 30.00 degrees\n", + "with frequency = 1000.00 hertz\n", + "\n", + "FOR Vout3:\n", + "peak value = 2.00 volts\n", + "phase angle = -10.00 degrees\n", + "with frequency = 2000.00 hertz\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#given V_in(t)=3+2*cos(2000*pi*t)+cos(4000*pi*t-A), A=70*pi/180\n", + "#the three parts of V_in(t) are V_in_1=3, V_in_2=2*cos(2000*pi*t),V_in_3=cos(4000*pi*t-A)\n", + "\n", + "#first component V_1\n", + "V_in_1=3\n", + "f_1=0# #as omega is zero\n", + "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", + "H_1_max=(4000-f_1)/1000# #magnitude of H(traansfer function)\n", + "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", + "H_1_phi=pi*f_1/6000# #phase angle of H\n", + "H_1=H_1_max*complex(cos(H_1_phi),sin(H_1_phi))\n", + "V_out_1=H_1*V_in_1\n", + "V_out_1_R=(V_out_1).real# #real part\n", + "V_out_1_I=(V_out_1).imag# #imaginary part\n", + "V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n", + "V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n", + "\n", + "#second component V_in_2\n", + "V_in_2=2*complex(cos(0),sin(0))# #V_in_2 phasor\n", + "w=2000*pi# #omega\n", + "f_2=w/(2*pi)# #frequency\n", + "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", + "H_2_max=(4000-f_2)/1000# #magnitude of H(traansfer function)\n", + "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", + "H_2_phi=pi*f_2/6000# #phase angle of H\n", + "H_2=H_2_max*complex(cos(H_2_phi),sin(H_2_phi))\n", + "V_out_2=H_2*V_in_2\n", + "V_out_2_R=(V_out_2).real# #real part\n", + "V_out_2_I=(V_out_2).imag# #imaginary part\n", + "V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n", + "V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n", + "\n", + "#third component\n", + "A=-70*pi/180# #-70 degrees = %0.2f radians\n", + "V_in_3=complex(cos(A),sin(A))# #V_in_3 phasor\n", + "w=4000*pi# #omega\n", + "f_3=w/(2*pi)# #frequency\n", + "#equation of straight line of H_magnitude vs f is x+1000*y-4000=0\n", + "H_3_max=(4000-f_3)/1000# #magnitude of H(traansfer function)\n", + "#equation of straight line of H_phase angle vs f is 6000*y=pi*x (phase angle = %0.2f radians)\n", + "H_3_phi=pi*f_3/6000# #phase angle of H\n", + "H_3=H_3_max*complex(cos(H_3_phi),sin(H_3_phi))\n", + "V_out_3=H_3*V_in_3\n", + "V_out_3_R=(V_out_3).real# #real part\n", + "V_out_3_I=(V_out_3).imag# #imaginary part\n", + "V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n", + "V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n", + "\n", + "print 'Output voltage is Vout1+Vout2+Vout3 where'\n", + "print ''\n", + "print 'FOR Vout1:'\n", + "print 'peak value = %0.2f volts'%V_out_1_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_1\n", + "print ''\n", + "print 'FOR Vout2:'\n", + "print 'peak value = %0.2f volts'%V_out_2_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_2\n", + "print ''\n", + "print 'FOR Vout3:'\n", + "print 'peak value = %0.2f volts'%V_out_3_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.3 Page No: 477" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", + "Output voltage is Vout1+Vout2+Vout3 where\n", + "\n", + "FOR Vout1:\n", + "peak value = 4.98 volts\n", + "phase angle = -5.71 degrees\n", + "with frequency = 10.00 hertz\n", + "\n", + "FOR Vout2:\n", + "peak value = 3.54 volts\n", + "phase angle = -45.00 degrees\n", + "with frequency = 100.00 hertz\n", + "\n", + "FOR Vout3:\n", + "peak value = 0.50 volts\n", + "phase angle = -84.29 degrees\n", + "with frequency = 1000.00 hertz\n" + ] + } + ], + "source": [ + "R=1000/(2*pi)# #resistance\n", + "C=10*10**-6# #capacitance\n", + "f_B=1/(2*pi*R*C)# #half-power frequency\n", + "#the three parts of V_in are V_1=5*cos(20*pi*t)+5*cos(200*pi*t)+5*cos(2000*pi*t)\n", + "\n", + "#first component V_in_1\n", + "V_in_1=5*complex(cos(0),sin(0))# #V_in_1 phasor\n", + "w_1=20*pi# #omega\n", + "f_1=w_1/(2*pi)# #frequency\n", + "H_1=1/(1+1J*(f_1/f_B))# #transfer function\n", + "V_out_1=H_1*V_in_1\n", + "V_out_1_R=(V_out_1).real# #real part\n", + "V_out_1_I=(V_out_1).imag# #imaginary part\n", + "V_out_1_max=sqrt((V_out_1_R**2)+(V_out_1_I**2))# #peak value\n", + "V_out_1_phi=atan(V_out_1_I/V_out_1_R)# #phase angle\n", + "\n", + "#second component V_in_2\n", + "V_in_2=5*complex(cos(0),sin(0))# #V_in_2 phasor\n", + "w_2=200*pi# #omega\n", + "f_2=w_2/(2*pi)# #frequency\n", + "H_2=1/(1+1J*(f_2/f_B))# #transfer function\n", + "V_out_2=H_2*V_in_2\n", + "V_out_2_R=(V_out_2).real #real part\n", + "V_out_2_I=(V_out_2).imag #imaginary part\n", + "V_out_2_max=sqrt((V_out_2_R**2)+(V_out_2_I**2))# #peak value\n", + "V_out_2_phi=atan(V_out_2_I/V_out_2_R)# #phase angle\n", + "\n", + "#third component V_in_3\n", + "V_in_3=5*complex(cos(0),sin(0))# #V_in_3 phasor\n", + "w_3=2000*pi# #omega\n", + "f_3=w_3/(2*pi)# #frequency\n", + "H_3=1/(1+1J*(f_3/f_B))# #transfer function\n", + "V_out_3=H_3*V_in_3\n", + "V_out_3_R=(V_out_3).real #real part\n", + "V_out_3_I=(V_out_3).imag #imaginary part\n", + "V_out_3_max=sqrt((V_out_3_R**2)+(V_out_3_I**2))# #peak value\n", + "V_out_3_phi=atan(V_out_3_I/V_out_3_R)# #phase angle\n", + "\n", + "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", + "print 'Output voltage is Vout1+Vout2+Vout3 where'\n", + "print ''\n", + "print 'FOR Vout1:'\n", + "print 'peak value = %0.2f volts'%V_out_1_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_1_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_1\n", + "print ''\n", + "print 'FOR Vout2:'\n", + "print 'peak value = %0.2f volts'%V_out_2_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_2_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_2\n", + "print ''\n", + "print 'FOR Vout3:'\n", + "print 'peak value = %0.2f volts'%V_out_3_max\n", + "print 'phase angle = %0.2f degrees'%(V_out_3_phi*180/pi)\n", + "print 'with frequency = %0.2f hertz'%f_3\n", + "#we can observe that there is a clear discrimination = %0.2f output signals based on frequencies i.e, lesser the frequency lesser the effect." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.4 Page No: 478" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", + "Break frequency = 1897.37 Hz\n" + ] + } + ], + "source": [ + "H_max=-30# #transfer function magnitude\n", + "f=60\n", + "m=20# #low-frequency asymptote slope rate = %0.2f db/decade\n", + "#f_B must be K higher than f where K is\n", + "K=abs(H_max)/m\n", + "#(base 10)log(f_B/60)=1.5 ==>\n", + "f_B=60*10**1.5\n", + "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", + "print 'Break frequency = %0.2f Hz'%f_B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.5 Page No: 479" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Phasor voltage across Resistance\n", + "peak value = 1.00 volts\n", + "phase angle = 0.00 degrees\n", + "\n", + "Phasor voltage across Inductance\n", + "peak value = 10.00 volts\n", + "phase angle = 90.00 degrees\n", + "\n", + "Phasor voltage across Capacitance\n", + "peak value = 10.00 volts\n", + "phase angle = -90.00 degrees\n" + ] + } + ], + "source": [ + "V_s=1*complex(cos(0),sin(0))\n", + "L=159.2*10**-3\n", + "R=100\n", + "C=0.1592*10**-6\n", + "f_o=1/(2*pi*sqrt(L*C))# #resonant frequency\n", + "Q_s=2*pi*f_o*L/R# #quality factor\n", + "B=f_o/Q_s# #Bandwidth\n", + "#Approximate half-power frequencies are\n", + "f_H=f_o+(B/2)\n", + "f_L=f_o-(B/2)\n", + "#At resonance\n", + "Z_L=1J*2*pi*f_o*L# #impedance of inductance\n", + "Z_C=-1J/(2*pi*f_o*C)# #impedance of capacitance\n", + "Z_s=R+Z_L+Z_C\n", + "I=V_s/Z_s# #phasor current\n", + "#voltages across diffrent elements are\n", + "#for resistance\n", + "V_R=R*I\n", + "V_R_R=(V_R).real #real part\n", + "V_R_I=(V_R).imag #imaginary part\n", + "V_R_max=sqrt((V_R_R**2)+(V_R_I**2))# #peak value\n", + "V_R_phi=atan(V_R_I/V_R_R)# #phase angle\n", + "#for inductance\n", + "V_L=Z_L*I\n", + "V_L_R=(V_L).real #real part\n", + "V_L_I=(V_L).imag #imaginary part\n", + "V_L_max=sqrt((V_L_R**2)+(V_L_I**2))# #peak value\n", + "#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n", + "if ((V_L/1J)==abs(V_L)):\n", + " V_L_phi=pi/2\n", + "elif ((V_L/1J)==-abs(V_L)):\n", + " V_L_phi=-pi/2\n", + "\n", + "\n", + "#for capacitance\n", + "V_C=Z_C*I\n", + "V_C_R=(V_C).real #real part\n", + "V_C_I=(V_C).imag #imaginary part\n", + "V_C_max=sqrt((V_C_R**2)+(V_C_I**2))# #peak value\n", + "#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n", + "if ((V_C/1J)==abs(V_C)) :\n", + " V_C_phi=pi/2\n", + "elif ((V_C/1J)==-abs(V_C)) :\n", + " V_C_phi=-pi/2\n", + "\n", + " \n", + "print 'Phasor voltage across Resistance'\n", + "print 'peak value = %0.2f volts'%V_R_max\n", + "print 'phase angle = %0.2f degrees'%(V_R_phi*180/pi)\n", + "print ''\n", + "print 'Phasor voltage across Inductance'\n", + "print 'peak value = %0.2f volts'%V_L_max\n", + "print 'phase angle = %0.2f degrees'%(V_L_phi*180/pi)\n", + "print ''\n", + "print 'Phasor voltage across Capacitance'\n", + "print 'peak value = %0.2f volts'%V_C_max\n", + "print 'phase angle = %0.2f degrees'%(V_C_phi*180/pi)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.6 Page No: 480" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current phasor across Resistance\n", + "peak value = 0.001 amperes\n", + "phase angle = 0 degrees\n", + "\n", + "Current phasor across Inductance\n", + "peak value = 0.010 amperes\n", + "phase angle = -90.00 degrees\n", + "\n", + "current phasor across capacitance\n", + "peak value = 0.010 amperes\n", + "phase angle = 90.00 degrees\n" + ] + } + ], + "source": [ + "R=10*10**3\n", + "f_o=1*10**6\n", + "B=100*10**3\n", + "I=10**-3*complex(cos(0),sin(0))\n", + "Q_p=f_o/B# #quality factor\n", + "L=R/(2*pi*f_o*Q_p)\n", + "C=Q_p/(2*pi*f_o*R)\n", + "#At resonance\n", + "V_out=I*R\n", + "Z_L=1J*2*pi*f_o*L\n", + "Z_C=-1J/(2*pi*f_o*C)\n", + "\n", + "#across resistance\n", + "I_R=V_out/R\n", + "I_R_R=(I_R).real# #real part\n", + "I_R_I=(I_R).imag# #imaginary part\n", + "I_R_max=sqrt((I_R_R**2)+(I_R_I**2))# #peak value\n", + "I_R_phi=atan(I_R_I/I_R_R)# #phase angle\n", + "\n", + "#across inductance\n", + "I_L=V_out/Z_L\n", + "I_L_R=(I_L).real #real part\n", + "I_L_I=(I_L).imag# #imaginary part\n", + "I_L_max=sqrt((I_L_R**2)+(I_L_I**2))# #peak value\n", + "#Z_L is pure imaginary ==> V_L is pure imaginary which means V_L_phi can be +or- pi/2\n", + "if ((I_L/1J)==abs(I_L)):\n", + " I_L_phi=pi/2\n", + "elif ((I_L/1J)==-abs(I_L)) :\n", + " I_L_phi=-pi/2\n", + "\n", + "\n", + "#across capacitor\n", + "I_C=V_out/Z_C\n", + "I_C_R=(I_C).real# #real part\n", + "I_C_I=(I_C).imag# #imaginary part\n", + "I_C_max=sqrt((I_C_R**2)+(I_C_I**2))# #peak value\n", + "#Z_C is pure imaginary ==> V_C is pure imaginary which means V_C_phi can be +or- pi/2\n", + "if ((I_C/1J)==abs(I_C)):\n", + " I_C_phi=pi/2\n", + "elif ((I_C/1J)==-abs(I_C)) :\n", + " I_C_phi=-pi/2\n", + "\n", + "\n", + "print 'Current phasor across Resistance'\n", + "print 'peak value = %0.3f amperes'%I_R_max\n", + "print 'phase angle = %0.f degrees'%(I_R_phi*180/pi)\n", + "print ''\n", + "print 'Current phasor across Inductance'\n", + "print 'peak value = %0.3f amperes'%I_L_max\n", + "print 'phase angle = %0.2f degrees'%(I_L_phi*180/pi)\n", + "print ''\n", + "print 'current phasor across capacitance'\n", + "print 'peak value = %0.3f amperes'%I_C_max\n", + "print 'phase angle = %0.2f degrees'%(I_C_phi*180/pi)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 6.7 Page No: 481" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\n", + "\n", + "The required second order circuit configuration is\n", + "Inductance = 50.00 KH\n", + "Capacitance = 0.51 mF(micro Farads)\n", + "Resistance = 314.16 ohms\n" + ] + } + ], + "source": [ + "#We need a high-pass filter\n", + "L=50*10**-3\n", + "#for the transfer function to be approximately constant = %0.2f passband area(from graph given = %0.2f the text), we choose\n", + "Q_s=1\n", + "f_o=1*10**3\n", + "C=1/(((2*pi)**2)*f_o**2*L)\n", + "R=2*pi*f_o*L/Q_s\n", + "print \" All the values in the textbook are approximated, hence the values in this code differ from those of Textbook\"\n", + "print ''\n", + "print 'The required second order circuit configuration is'\n", + "print 'Inductance = %0.2f KH'%(L*10**3)\n", + "print 'Capacitance = %0.2f mF(micro Farads)'%(C*10**6)\n", + "print 'Resistance = %0.2f ohms'%R\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Hrituraj/Various_types_of.ipynb b/sample_notebooks/Hrituraj/Various_types_of.ipynb new file mode 100755 index 00000000..d2ca1e19 --- /dev/null +++ b/sample_notebooks/Hrituraj/Various_types_of.ipynb @@ -0,0 +1,318 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:0f69a839d3ec8a6e20f49cef0966e931497f52ea6c7ffcec43b822cf678199cf" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Various types of tarrifs" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.1 page 290" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given Data :\n", + "E=438000.0 #in kWh(Energy consumed per year)\n", + "pf=0.8 #unitless\n", + "cosfi=pf #unitless\n", + "LoadFactor=40.0 #in %\n", + "#tarrif=Rs. 75/year/kw of max demand plus 3 paise per unit per reactive KVA\n", + "h=8760.0 #no. of years in a year\n", + "AvgLoad=E/h #kw\n", + "MaxLoad=AvgLoad/(LoadFactor/100) #in kw\n", + "MaxLoad_KVA=MaxLoad/pf #in KVA\n", + "tanfi=math.tan(math.acos(cosfi)) #unitless\n", + "ReactiveKVAR=h*tanfi*AvgLoad #in KVA\n", + "AnnualBill=75*MaxLoad+(3/100)*E+(1.5/100)*ReactiveKVAR #in Rs.\n", + "CostPerUnit=AnnualBill/E #in Rs.\n", + "CostPerUnit=CostPerUnit*100 #in Paisa\n", + "print \"Cost per unit is %0.2f Paisa\" %CostPerUnit" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cost per unit is 3.27 Paisa\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.2 page 291" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given Data :\n", + "#tarrif=Rs. 275/year/KVA of max demand plus 35 paise per unit\n", + "C1=275.0 #in Rs.year/KVA\n", + "C2=35.0 #in paisa/unit\n", + "LoadFactor=30.0 #in %/year\n", + "LoadFactor=30.0/100 #in fraction\n", + "#Let MaxDemand = x KW\n", + "#Case (i) PF=1\n", + "cosfi=1 #unitless\n", + "AnnualBillBYx=C1/cosfi+(C2/100)*LoadFactor*24*365 #in Rs.(Here 24*365 is for No. of hours in a year)\n", + "AnnualBill=AnnualBillBYx*100/(LoadFactor*24*365) #in paisa/unit\n", + "print \"Cost per unit(at unity power factor) is %0.2f paisa/unit\" %AnnualBill \n", + "#Case (i) PF=0.8\n", + "cosfi=0.8 #unitless\n", + "AnnualBillBYx=C1/cosfi+(C2/100)*LoadFactor*24*365 #in Rs.(Here 24*365 is for No. of hours in a year)\n", + "AnnualBill=AnnualBillBYx*100/(LoadFactor*24*365) #in paisa/unit\n", + "print \"Cost per unit(at 0.8 power factor) is %0.2f paisa/unit\" %AnnualBill" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Cost per unit(at unity power factor) is 45.46 paisa/unit\n", + "Cost per unit(at 0.8 power factor) is 48.08 paisa/unit\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.3 page 292" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given Data :\n", + "FixedLoad=200.0 #in kW\n", + "PF=0.8 #unitless\n", + "cosfi=PF #unitless\n", + "h=10.0 #in hours/day\n", + "d=300.0 #in days\n", + "Time=h*d #in hours\n", + "Energy=FixedLoad*Time #in kwh/year\n", + "# (i) tarrif=Rs. 100/KVA/Annum plus 20 paise per kwh\n", + "C1=100.0 #in Rs.year/KVA\n", + "C2=20.0 #in paisa/kwh\n", + "KVA=FixedLoad/cosfi #in KVA\n", + "AnnualBill=KVA*C1+(C2/100)*Energy #in Rs.\n", + "print \" Case (i) Annual Payment is %0.2f Rs.\" %AnnualBill \n", + "# (ii) tarrif=Rs. 100/KW/Annum plus 20 paise per kwh plus 2 paise/KVARH\n", + "C1=100.0 #in Rs./year/KW\n", + "C2=20.0 #in paisa/kwh\n", + "C3=2.0 #in paisa/KVARH\n", + "tanfi=math.tan(math.acos(cosfi)) #unitless\n", + "ReactiveKVARH=FixedLoad*tanfi*Time #in KVARH\n", + "AnnualBill=C1*FixedLoad+(C2/100)*Energy+(C3/100)*ReactiveKVARH #in Rs.\n", + "print \" Case (ii) Annual Payment is %0.2f Rs.\" %AnnualBill " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Case (i) Annual Payment is 145000.00 Rs.\n", + " Case (ii) Annual Payment is 149000.00 Rs.\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.4 page 292" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given Data :\n", + "Energy=180000.0 #in kwh\n", + "LoadFactor=45.0 #in %/year\n", + "LoadFactor=45.0/100 #in fraction\n", + "#Charges=Rs. 50/KW/Annum plus 8 paise per unit\n", + "C1=50 #in Rs.year/KW\n", + "C2=8 #in paisa/unit\n", + "h=365*24 #no. of hours per year\n", + "AvgLoad=Energy/h #in KW\n", + "MaxLoad=AvgLoad/LoadFactor #in KW\n", + "FixCharges=MaxLoad*C1 #in Rs.\n", + "PlusCharges=(C2/100)*Energy #in rs.\n", + "TotalTarrif=FixCharges+PlusCharges #in Rs.\n", + "print \"Total Annual electricity charges is %0.2f Rs.\" %TotalTarrif" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total Annual electricity charges is 2283.11 Rs.\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.5 page 293" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given Data :\n", + "Energy=25.0*10**6 #in kwh\n", + "MaxDemand=1600.0 #in KW\n", + "#(i) Rs. 70/KW max demand plus 2 paise per kwh\n", + "C1=70.0 #in Rs.year/KW\n", + "C2=2 #in paisa/unit\n", + "AnnualCost=MaxDemand*C1+(C2/100)*Energy #in Rs.\n", + "print \"Case (i) Annual cost of energy is %0.2f Rs.\" %AnnualCost \n", + "#(ii) Annual cost at a flat rate of 5p/kwh\n", + "C=5.0 #in paisa/kwh\n", + "AnnualCost=(C/100)*Energy #in Rs.\n", + "print \"Case (ii) Annual cost of energy is %0.2f Rs.\" %AnnualCost \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Case (i) Annual cost of energy is 112000.00 Rs.\n", + "Case (ii) Annual cost of energy is 1250000.00 Rs.\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.6 page 293" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given Data :\n", + "MaxDemand=20 #in KW\n", + "#(i) Rs. 180/KW/annum max demand plus 15 paise per unit\n", + "#(ii) Flat rate tarrif 40 paise/unit\n", + "C1=180.0 #in Rs.year/KW\n", + "C2=15.0 #in paisa/unit\n", + "#AnnualBill1=C1*MaxDemand+(C2/100)*x x is the energy consumed\n", + "C=40.0 #in paisa/unit\n", + "#AnnualBill2=(C/100)*x x is the energy consumed\n", + "#Puting two bills equal gives :\n", + "x=C1*MaxDemand/((C/100)-(C2/100)) #in kwh\n", + "print \"No. of units to be consumed is %0.2f or in %0.2f kwh \" %(x,x)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No. of units to be consumed is 14400.00 or in 14400.00 kwh \n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 11.7 page 294" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given Data :\n", + "MaxDemand=500.0 #in KW\n", + "LoadFactor=70.0 #in %/year\n", + "LoadFactor=70.0/100 #in fraction\n", + "cosfi=0.8 #unitless\n", + "#(i) Rs. 80/KVA of max demand\n", + "#(ii) Running chargeare 5 paise/kwh\n", + "C1=80.0 #in Rs./KVA\n", + "C2=5.0 #in paisa/kwh\n", + "AvgLoad=MaxDemand*LoadFactor #in KW\n", + "h=365.0*24 #no. of hours per year\n", + "Energy=AvgLoad*h #in kwh\n", + "MaxDemandKVA=MaxDemand/cosfi #in KVA\n", + "AnnualBill=MaxDemandKVA*C1+(C2/100)*Energy #in RS\n", + "print \"Annual bill of consumer is %0.2f Rs.\" %AnnualBill " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Annual bill of consumer is 203300.00 Rs.\n" + ] + } + ], + "prompt_number": 27 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Hrituraj/Various_types_of_tarrifs.ipynb b/sample_notebooks/Hrituraj/Various_types_of_tarrifs.ipynb deleted file mode 100755 index d2ca1e19..00000000 --- a/sample_notebooks/Hrituraj/Various_types_of_tarrifs.ipynb +++ /dev/null @@ -1,318 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:0f69a839d3ec8a6e20f49cef0966e931497f52ea6c7ffcec43b822cf678199cf" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Various types of tarrifs" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.1 page 290" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given Data :\n", - "E=438000.0 #in kWh(Energy consumed per year)\n", - "pf=0.8 #unitless\n", - "cosfi=pf #unitless\n", - "LoadFactor=40.0 #in %\n", - "#tarrif=Rs. 75/year/kw of max demand plus 3 paise per unit per reactive KVA\n", - "h=8760.0 #no. of years in a year\n", - "AvgLoad=E/h #kw\n", - "MaxLoad=AvgLoad/(LoadFactor/100) #in kw\n", - "MaxLoad_KVA=MaxLoad/pf #in KVA\n", - "tanfi=math.tan(math.acos(cosfi)) #unitless\n", - "ReactiveKVAR=h*tanfi*AvgLoad #in KVA\n", - "AnnualBill=75*MaxLoad+(3/100)*E+(1.5/100)*ReactiveKVAR #in Rs.\n", - "CostPerUnit=AnnualBill/E #in Rs.\n", - "CostPerUnit=CostPerUnit*100 #in Paisa\n", - "print \"Cost per unit is %0.2f Paisa\" %CostPerUnit" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Cost per unit is 3.27 Paisa\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.2 page 291" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given Data :\n", - "#tarrif=Rs. 275/year/KVA of max demand plus 35 paise per unit\n", - "C1=275.0 #in Rs.year/KVA\n", - "C2=35.0 #in paisa/unit\n", - "LoadFactor=30.0 #in %/year\n", - "LoadFactor=30.0/100 #in fraction\n", - "#Let MaxDemand = x KW\n", - "#Case (i) PF=1\n", - "cosfi=1 #unitless\n", - "AnnualBillBYx=C1/cosfi+(C2/100)*LoadFactor*24*365 #in Rs.(Here 24*365 is for No. of hours in a year)\n", - "AnnualBill=AnnualBillBYx*100/(LoadFactor*24*365) #in paisa/unit\n", - "print \"Cost per unit(at unity power factor) is %0.2f paisa/unit\" %AnnualBill \n", - "#Case (i) PF=0.8\n", - "cosfi=0.8 #unitless\n", - "AnnualBillBYx=C1/cosfi+(C2/100)*LoadFactor*24*365 #in Rs.(Here 24*365 is for No. of hours in a year)\n", - "AnnualBill=AnnualBillBYx*100/(LoadFactor*24*365) #in paisa/unit\n", - "print \"Cost per unit(at 0.8 power factor) is %0.2f paisa/unit\" %AnnualBill" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Cost per unit(at unity power factor) is 45.46 paisa/unit\n", - "Cost per unit(at 0.8 power factor) is 48.08 paisa/unit\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.3 page 292" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given Data :\n", - "FixedLoad=200.0 #in kW\n", - "PF=0.8 #unitless\n", - "cosfi=PF #unitless\n", - "h=10.0 #in hours/day\n", - "d=300.0 #in days\n", - "Time=h*d #in hours\n", - "Energy=FixedLoad*Time #in kwh/year\n", - "# (i) tarrif=Rs. 100/KVA/Annum plus 20 paise per kwh\n", - "C1=100.0 #in Rs.year/KVA\n", - "C2=20.0 #in paisa/kwh\n", - "KVA=FixedLoad/cosfi #in KVA\n", - "AnnualBill=KVA*C1+(C2/100)*Energy #in Rs.\n", - "print \" Case (i) Annual Payment is %0.2f Rs.\" %AnnualBill \n", - "# (ii) tarrif=Rs. 100/KW/Annum plus 20 paise per kwh plus 2 paise/KVARH\n", - "C1=100.0 #in Rs./year/KW\n", - "C2=20.0 #in paisa/kwh\n", - "C3=2.0 #in paisa/KVARH\n", - "tanfi=math.tan(math.acos(cosfi)) #unitless\n", - "ReactiveKVARH=FixedLoad*tanfi*Time #in KVARH\n", - "AnnualBill=C1*FixedLoad+(C2/100)*Energy+(C3/100)*ReactiveKVARH #in Rs.\n", - "print \" Case (ii) Annual Payment is %0.2f Rs.\" %AnnualBill " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Case (i) Annual Payment is 145000.00 Rs.\n", - " Case (ii) Annual Payment is 149000.00 Rs.\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.4 page 292" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given Data :\n", - "Energy=180000.0 #in kwh\n", - "LoadFactor=45.0 #in %/year\n", - "LoadFactor=45.0/100 #in fraction\n", - "#Charges=Rs. 50/KW/Annum plus 8 paise per unit\n", - "C1=50 #in Rs.year/KW\n", - "C2=8 #in paisa/unit\n", - "h=365*24 #no. of hours per year\n", - "AvgLoad=Energy/h #in KW\n", - "MaxLoad=AvgLoad/LoadFactor #in KW\n", - "FixCharges=MaxLoad*C1 #in Rs.\n", - "PlusCharges=(C2/100)*Energy #in rs.\n", - "TotalTarrif=FixCharges+PlusCharges #in Rs.\n", - "print \"Total Annual electricity charges is %0.2f Rs.\" %TotalTarrif" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total Annual electricity charges is 2283.11 Rs.\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.5 page 293" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given Data :\n", - "Energy=25.0*10**6 #in kwh\n", - "MaxDemand=1600.0 #in KW\n", - "#(i) Rs. 70/KW max demand plus 2 paise per kwh\n", - "C1=70.0 #in Rs.year/KW\n", - "C2=2 #in paisa/unit\n", - "AnnualCost=MaxDemand*C1+(C2/100)*Energy #in Rs.\n", - "print \"Case (i) Annual cost of energy is %0.2f Rs.\" %AnnualCost \n", - "#(ii) Annual cost at a flat rate of 5p/kwh\n", - "C=5.0 #in paisa/kwh\n", - "AnnualCost=(C/100)*Energy #in Rs.\n", - "print \"Case (ii) Annual cost of energy is %0.2f Rs.\" %AnnualCost \n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Case (i) Annual cost of energy is 112000.00 Rs.\n", - "Case (ii) Annual cost of energy is 1250000.00 Rs.\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.6 page 293" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given Data :\n", - "MaxDemand=20 #in KW\n", - "#(i) Rs. 180/KW/annum max demand plus 15 paise per unit\n", - "#(ii) Flat rate tarrif 40 paise/unit\n", - "C1=180.0 #in Rs.year/KW\n", - "C2=15.0 #in paisa/unit\n", - "#AnnualBill1=C1*MaxDemand+(C2/100)*x x is the energy consumed\n", - "C=40.0 #in paisa/unit\n", - "#AnnualBill2=(C/100)*x x is the energy consumed\n", - "#Puting two bills equal gives :\n", - "x=C1*MaxDemand/((C/100)-(C2/100)) #in kwh\n", - "print \"No. of units to be consumed is %0.2f or in %0.2f kwh \" %(x,x)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No. of units to be consumed is 14400.00 or in 14400.00 kwh \n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 11.7 page 294" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given Data :\n", - "MaxDemand=500.0 #in KW\n", - "LoadFactor=70.0 #in %/year\n", - "LoadFactor=70.0/100 #in fraction\n", - "cosfi=0.8 #unitless\n", - "#(i) Rs. 80/KVA of max demand\n", - "#(ii) Running chargeare 5 paise/kwh\n", - "C1=80.0 #in Rs./KVA\n", - "C2=5.0 #in paisa/kwh\n", - "AvgLoad=MaxDemand*LoadFactor #in KW\n", - "h=365.0*24 #no. of hours per year\n", - "Energy=AvgLoad*h #in kwh\n", - "MaxDemandKVA=MaxDemand/cosfi #in KVA\n", - "AnnualBill=MaxDemandKVA*C1+(C2/100)*Energy #in RS\n", - "print \"Annual bill of consumer is %0.2f Rs.\" %AnnualBill " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Annual bill of consumer is 203300.00 Rs.\n" - ] - } - ], - "prompt_number": 27 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL.ipynb b/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL.ipynb new file mode 100755 index 00000000..3369137f --- /dev/null +++ b/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL.ipynb @@ -0,0 +1,234 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 CRYSTAL STRUCTURES" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_4 pgno:22" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1.0\n", + "r=a/2 = 0.5\n", + "Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= 0.523598775598\n", + "Total Volume of the cube ,V=aˆ3 = 1.0\n", + "Fp(S.C)=(v∗100/V)= 52.3598775598\n" + ] + } + ], + "source": [ + "#exa 1.4\n", + "from math import pi\n", + "a=1.\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=a/2.\n", + "print \"r=a/2 = \",r # initializing value of radius of atom for simple cubic .\n", + "v=((4*pi*(r**3))/3)\n", + "print \"Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= \",v # calcuation . \n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(S.C)=(v∗100/V)= \",Fp,# calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_5 pgno:24" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1.0\n", + "Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = 0.433012701892\n", + "Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = 0.680174761588\n", + "Total Volume of the cube ,V=aˆ3 = 1.0\n", + "Fp(B.C.C)=(v∗100/V)= 68.0174761588 %\n" + ] + } + ], + "source": [ + "#exa 1.5\n", + "from math import sqrt\n", + "a=1.\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=(sqrt(3)*(a**2/4))\n", + "print \"Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = \",r # initializing value of radius of atom for BCC.\n", + "v=((4*pi*(r**3))/3)*2\n", + "print \"Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = \",v # calcuation \n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(B.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_6 pgno:25" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1\n", + "Radius of the atom,r=(a/(2∗sqrt(2)))= 0.353553390593\n", + "Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= 0.740480489693\n", + "Total volume of the cube ,V=aˆ3= 2\n", + "Fp(F.C.C)=(v∗100/V)= 37.0240244847 %\n" + ] + } + ], + "source": [ + "#exa 1.6\n", + "a=1\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=(a/(2*sqrt(2)))\n", + "print \"Radius of the atom,r=(a/(2∗sqrt(2)))= \",r # initializing value of radius of atom for FCC .\n", + "v=(((4*pi*(r**3))/3)*4)\n", + "print \"Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= \",v # calcuation \n", + "V=a^3\n", + "print \"Total volume of the cube ,V=aˆ3= \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(F.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_8 pgno:26" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 1\n", + "Radius of the atom , r=(sqrt (3)∗a/8))= 0.216506350946\n", + "v=(((4∗pi∗(rˆ3))/3)∗8) = 0.340087380794\n", + "V=aˆ3= 2\n", + "Fp(Diamond)=(v∗100/V) = 17.0043690397 %\n" + ] + } + ], + "source": [ + "#Exa 1.8 \n", + "a=1\n", + "print \"a= \",a # initializing value of lattice constant(a)=1.\n", + "r=((sqrt(3)*a/8))\n", + "print \"Radius of the atom , r=(sqrt (3)∗a/8))= \",r # initializing value of radius of atom for diamond .\n", + "v=(((4*pi*(r**3))/3)*8)\n", + "print \"v=(((4∗pi∗(rˆ3))/3)∗8) = \",v # calcuation .\n", + "V=a^3\n", + "print \"V=aˆ3= \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(Diamond)=(v∗100/V) = \",Fp,\"%\" # calculation\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1_9 pgno:28" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a = 5e-08 cm\n", + "Radius of the atom,r=(sqrt(3)∗(a/4))= 2.16506350946e-08\n", + "Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= 8.50218451985e-23\n", + "Total Volume of the cube ,V=aˆ3 = 1.25e-22\n", + "Fp(B.C.C)=(v∗100/V) = 68.0174761588 %\n" + ] + } + ], + "source": [ + "#exa 1.9\n", + "a=5*10**-8\n", + "print \"a = \",a,\" cm\" # initializing value of lattice constant .\n", + "r=(sqrt(3)*(a/4))\n", + "print \"Radius of the atom,r=(sqrt(3)∗(a/4))= \",r # initializing value of radius of atom for BCC.\n", + "v=((4*pi*(r**3))/3)*2\n", + "print \"Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= \",v # calcuation .\n", + "V=a**3\n", + "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", + "Fp=(v*100/V)\n", + "print \"Fp(B.C.C)=(v∗100/V) = \",Fp,\"%\" # calculation" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL_STRUCTURES.ipynb b/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL_STRUCTURES.ipynb deleted file mode 100755 index 3369137f..00000000 --- a/sample_notebooks/InnamuriBhavitha/Chapter_1_CRYSTAL_STRUCTURES.ipynb +++ /dev/null @@ -1,234 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 CRYSTAL STRUCTURES" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_4 pgno:22" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1.0\n", - "r=a/2 = 0.5\n", - "Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= 0.523598775598\n", - "Total Volume of the cube ,V=aˆ3 = 1.0\n", - "Fp(S.C)=(v∗100/V)= 52.3598775598\n" - ] - } - ], - "source": [ - "#exa 1.4\n", - "from math import pi\n", - "a=1.\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=a/2.\n", - "print \"r=a/2 = \",r # initializing value of radius of atom for simple cubic .\n", - "v=((4*pi*(r**3))/3)\n", - "print \"Volume of one atom ,v=((4∗%pi∗(rˆ3))/3)= \",v # calcuation . \n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(S.C)=(v∗100/V)= \",Fp,# calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_5 pgno:24" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1.0\n", - "Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = 0.433012701892\n", - "Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = 0.680174761588\n", - "Total Volume of the cube ,V=aˆ3 = 1.0\n", - "Fp(B.C.C)=(v∗100/V)= 68.0174761588 %\n" - ] - } - ], - "source": [ - "#exa 1.5\n", - "from math import sqrt\n", - "a=1.\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=(sqrt(3)*(a**2/4))\n", - "print \"Radius of the atoms,r=(sqrt(3)∗(aˆ2/4)) = \",r # initializing value of radius of atom for BCC.\n", - "v=((4*pi*(r**3))/3)*2\n", - "print \"Volume of two atom,v=((4∗pi∗(rˆ3))/3)∗2 = \",v # calcuation \n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(B.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_6 pgno:25" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1\n", - "Radius of the atom,r=(a/(2∗sqrt(2)))= 0.353553390593\n", - "Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= 0.740480489693\n", - "Total volume of the cube ,V=aˆ3= 2\n", - "Fp(F.C.C)=(v∗100/V)= 37.0240244847 %\n" - ] - } - ], - "source": [ - "#exa 1.6\n", - "a=1\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=(a/(2*sqrt(2)))\n", - "print \"Radius of the atom,r=(a/(2∗sqrt(2)))= \",r # initializing value of radius of atom for FCC .\n", - "v=(((4*pi*(r**3))/3)*4)\n", - "print \"Volume of the four atom,v=(((4∗pi∗(rˆ3))/3)∗4)= \",v # calcuation \n", - "V=a^3\n", - "print \"Total volume of the cube ,V=aˆ3= \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(F.C.C)=(v∗100/V)= \",Fp,\"%\" # calculation\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_8 pgno:26" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 1\n", - "Radius of the atom , r=(sqrt (3)∗a/8))= 0.216506350946\n", - "v=(((4∗pi∗(rˆ3))/3)∗8) = 0.340087380794\n", - "V=aˆ3= 2\n", - "Fp(Diamond)=(v∗100/V) = 17.0043690397 %\n" - ] - } - ], - "source": [ - "#Exa 1.8 \n", - "a=1\n", - "print \"a= \",a # initializing value of lattice constant(a)=1.\n", - "r=((sqrt(3)*a/8))\n", - "print \"Radius of the atom , r=(sqrt (3)∗a/8))= \",r # initializing value of radius of atom for diamond .\n", - "v=(((4*pi*(r**3))/3)*8)\n", - "print \"v=(((4∗pi∗(rˆ3))/3)∗8) = \",v # calcuation .\n", - "V=a^3\n", - "print \"V=aˆ3= \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(Diamond)=(v∗100/V) = \",Fp,\"%\" # calculation\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1_9 pgno:28" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a = 5e-08 cm\n", - "Radius of the atom,r=(sqrt(3)∗(a/4))= 2.16506350946e-08\n", - "Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= 8.50218451985e-23\n", - "Total Volume of the cube ,V=aˆ3 = 1.25e-22\n", - "Fp(B.C.C)=(v∗100/V) = 68.0174761588 %\n" - ] - } - ], - "source": [ - "#exa 1.9\n", - "a=5*10**-8\n", - "print \"a = \",a,\" cm\" # initializing value of lattice constant .\n", - "r=(sqrt(3)*(a/4))\n", - "print \"Radius of the atom,r=(sqrt(3)∗(a/4))= \",r # initializing value of radius of atom for BCC.\n", - "v=((4*pi*(r**3))/3)*2\n", - "print \"Volume of the two atoms ,v=((4∗pi∗(rˆ3))/3)∗2= \",v # calcuation .\n", - "V=a**3\n", - "print \"Total Volume of the cube ,V=aˆ3 = \",V # calcuation .\n", - "Fp=(v*100/V)\n", - "print \"Fp(B.C.C)=(v∗100/V) = \",Fp,\"%\" # calculation" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/JagadeeshwarGoshika/JagadeeshwarGoshika_version_backup/chapter1.ipynb b/sample_notebooks/JagadeeshwarGoshika/JagadeeshwarGoshika_version_backup/chapter1.ipynb new file mode 100755 index 00000000..dd94bb77 --- /dev/null +++ b/sample_notebooks/JagadeeshwarGoshika/JagadeeshwarGoshika_version_backup/chapter1.ipynb @@ -0,0 +1,292 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Fluid properties" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "## Finding Specific weight,Density,Specific Gravity\n", + "##Given\n", + "V = 0.001 ##volume in m^3\n", + "w = 9.6 ##weight in Newton\n", + "g = 9.81 ##gravitational force in m/s^2\n", + "\n", + "##calculation\n", + "spwt = (w/V) ##Specific weight in N/m^3\n", + "rho = (spwt/g) ##density in kg/m^3\n", + "spgr = (rho/1000) ##Specific gravity no units\n", + "\n", + "#Results\n", + "print \"specific weight = \",round(spwt),\"N/m^3\"\n", + "print \"density = \",round(rho),\"kg/m^3\"\n", + "print \"specific gravity = \",round(spgr,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "specific weight = 9600.0 N/m^3\n", + "density = 979.0 kg/m^3\n", + "specific gravity = 0.98\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##Finding of Viscosity\n", + "##Given\n", + "dy=0.025E-3 ##distance in meter\n", + "du=0.5 ##velocity in m/s \n", + "tau=1.471 ##shear stress in N/m^2\n", + "##To Find\n", + "mu=tau*dy/du ##viscosity in Ns/m^2 \n", + "mu1=mu*10 ## Viscosity in poise\n", + "print \"Viscosity =\",mu,\" in Ns/m^2\"\n", + "print \"Viscosity =\",mu1,\" in poise\" \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Viscosity = 7.355e-05 in Ns/m^2\n", + "Viscosity = 0.0007355 in poise\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##Finding of Diameter of water droplet\n", + "##Given\n", + "st=0.716 ##Surface Tension in N/m\n", + "p=0.147E4 ##Pressure in N/m^2\n", + "##To Find \n", + "d=4*st/p ##Diameter in meter \n", + "d1=d*1E2 ##Diameter in centimeter \n", + "d2=d*1E3 ##Diameter in millimeter\n", + "print \"Diameter =\",round(d,5),\"m\"\n", + "print \"Diameter =\",round(d1,5),\"cm\"\n", + "print \"Diameter =\",round(d2,5),\"mm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter = 0.00195 m\n", + "Diameter = 0.19483 cm\n", + "Diameter = 1.9483 mm\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##Finding of Shear Stress\n", + "##Given\n", + "##du/dy = vg\n", + "vg=0.25 ##Velocity gradient in m/sec/meter\n", + "nu=6.30E-4 ##Kinematic viscosity in m^2/sec\n", + "rho=1268.4 ##Mass density in Kg/m^3\n", + "mu=rho*nu ##Dynamic Viscosity\n", + "##To Find\n", + "tau=mu*vg ##Shear stress in N/m^2\n", + "print \"Shear Stress =\",round(tau,3),\"N/m^2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Shear Stress = 0.2 N/m^2\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##Finding of increase of Pressure\n", + "##Given\n", + "k=2.07*1E6 ## Bulk Modulus in kN/m^2\n", + "dv=0.01 ##Change in Volume\n", + "##To Find\n", + "p=k*(dv) ##Change in pressure\n", + "print \"Increase in Pressure =\",p,\"kN/m^2\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Increase in Pressure = 20700.0 kN/m^2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy as np\n", + "##Finding of Cappilary rise\n", + "##Given\n", + "d=0.03*1E-2 ##Diameter in meter\n", + "st=0.0735 ##Surface Tension in N/m\n", + "x=0 ##contact angle in degree\n", + "w=1000*9.81\n", + "##To Find\n", + "h=(4*st)*np.cos(x)/(w*d)\n", + "h1=h*1E2\n", + "print \"Capillary rise =\",round(h,4),\"m\"\n", + "print \"Capillary rise =\",round(h1,4),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Capillary rise = 0.0999 m\n", + "Capillary rise = 9.9898 cm\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##Finding of Kinematic Viscosity\n", + "##Given\n", + "tau=0.2158 ##Shear stress in N/m^2\n", + "vg=0.218 ##Velocity Gradient in sec^-1\n", + "rho=959.5 ##Density in Kg/m^3;\n", + "##To Find \n", + "mu=tau*1/vg\n", + "print \"Dynamic Viscosity =\",round(mu,5),\"Ns/m^2\"\n", + "nu=mu/rho\n", + "print \"Kinematic Viscosity =\",round(nu,5),\"m^2/sec\"\n", + "nu1=nu*1E4\n", + "print \"Kinematic Viscosity =\",round(nu1,5),\"cm^2/sec\"\n", + "nu2=nu1*1E-4\n", + "print \"Kinematic Viscosity =\",round(nu2,5),\"strokes\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Dynamic Viscosity = 0.98991 Ns/m^2\n", + "Kinematic Viscosity = 0.00103 m^2/sec\n", + "Kinematic Viscosity = 10.31692 cm^2/sec\n", + "Kinematic Viscosity = 0.00103 strokes\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/JagadeeshwarGoshika/chapter1.ipynb b/sample_notebooks/JagadeeshwarGoshika/chapter1.ipynb deleted file mode 100755 index dd94bb77..00000000 --- a/sample_notebooks/JagadeeshwarGoshika/chapter1.ipynb +++ /dev/null @@ -1,292 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Fluid properties" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "## Finding Specific weight,Density,Specific Gravity\n", - "##Given\n", - "V = 0.001 ##volume in m^3\n", - "w = 9.6 ##weight in Newton\n", - "g = 9.81 ##gravitational force in m/s^2\n", - "\n", - "##calculation\n", - "spwt = (w/V) ##Specific weight in N/m^3\n", - "rho = (spwt/g) ##density in kg/m^3\n", - "spgr = (rho/1000) ##Specific gravity no units\n", - "\n", - "#Results\n", - "print \"specific weight = \",round(spwt),\"N/m^3\"\n", - "print \"density = \",round(rho),\"kg/m^3\"\n", - "print \"specific gravity = \",round(spgr,2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "specific weight = 9600.0 N/m^3\n", - "density = 979.0 kg/m^3\n", - "specific gravity = 0.98\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##Finding of Viscosity\n", - "##Given\n", - "dy=0.025E-3 ##distance in meter\n", - "du=0.5 ##velocity in m/s \n", - "tau=1.471 ##shear stress in N/m^2\n", - "##To Find\n", - "mu=tau*dy/du ##viscosity in Ns/m^2 \n", - "mu1=mu*10 ## Viscosity in poise\n", - "print \"Viscosity =\",mu,\" in Ns/m^2\"\n", - "print \"Viscosity =\",mu1,\" in poise\" \n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Viscosity = 7.355e-05 in Ns/m^2\n", - "Viscosity = 0.0007355 in poise\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##Finding of Diameter of water droplet\n", - "##Given\n", - "st=0.716 ##Surface Tension in N/m\n", - "p=0.147E4 ##Pressure in N/m^2\n", - "##To Find \n", - "d=4*st/p ##Diameter in meter \n", - "d1=d*1E2 ##Diameter in centimeter \n", - "d2=d*1E3 ##Diameter in millimeter\n", - "print \"Diameter =\",round(d,5),\"m\"\n", - "print \"Diameter =\",round(d1,5),\"cm\"\n", - "print \"Diameter =\",round(d2,5),\"mm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diameter = 0.00195 m\n", - "Diameter = 0.19483 cm\n", - "Diameter = 1.9483 mm\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##Finding of Shear Stress\n", - "##Given\n", - "##du/dy = vg\n", - "vg=0.25 ##Velocity gradient in m/sec/meter\n", - "nu=6.30E-4 ##Kinematic viscosity in m^2/sec\n", - "rho=1268.4 ##Mass density in Kg/m^3\n", - "mu=rho*nu ##Dynamic Viscosity\n", - "##To Find\n", - "tau=mu*vg ##Shear stress in N/m^2\n", - "print \"Shear Stress =\",round(tau,3),\"N/m^2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Shear Stress = 0.2 N/m^2\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##Finding of increase of Pressure\n", - "##Given\n", - "k=2.07*1E6 ## Bulk Modulus in kN/m^2\n", - "dv=0.01 ##Change in Volume\n", - "##To Find\n", - "p=k*(dv) ##Change in pressure\n", - "print \"Increase in Pressure =\",p,\"kN/m^2\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Increase in Pressure = 20700.0 kN/m^2\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import numpy as np\n", - "##Finding of Cappilary rise\n", - "##Given\n", - "d=0.03*1E-2 ##Diameter in meter\n", - "st=0.0735 ##Surface Tension in N/m\n", - "x=0 ##contact angle in degree\n", - "w=1000*9.81\n", - "##To Find\n", - "h=(4*st)*np.cos(x)/(w*d)\n", - "h1=h*1E2\n", - "print \"Capillary rise =\",round(h,4),\"m\"\n", - "print \"Capillary rise =\",round(h1,4),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Capillary rise = 0.0999 m\n", - "Capillary rise = 9.9898 cm\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##Finding of Kinematic Viscosity\n", - "##Given\n", - "tau=0.2158 ##Shear stress in N/m^2\n", - "vg=0.218 ##Velocity Gradient in sec^-1\n", - "rho=959.5 ##Density in Kg/m^3;\n", - "##To Find \n", - "mu=tau*1/vg\n", - "print \"Dynamic Viscosity =\",round(mu,5),\"Ns/m^2\"\n", - "nu=mu/rho\n", - "print \"Kinematic Viscosity =\",round(nu,5),\"m^2/sec\"\n", - "nu1=nu*1E4\n", - "print \"Kinematic Viscosity =\",round(nu1,5),\"cm^2/sec\"\n", - "nu2=nu1*1E-4\n", - "print \"Kinematic Viscosity =\",round(nu2,5),\"strokes\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Dynamic Viscosity = 0.98991 Ns/m^2\n", - "Kinematic Viscosity = 0.00103 m^2/sec\n", - "Kinematic Viscosity = 10.31692 cm^2/sec\n", - "Kinematic Viscosity = 0.00103 strokes\n" - ] - } - ], - "prompt_number": 15 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/JaiMathur/JaiMathur_version_backup/ch2.ipynb b/sample_notebooks/JaiMathur/JaiMathur_version_backup/ch2.ipynb new file mode 100755 index 00000000..eab5eede --- /dev/null +++ b/sample_notebooks/JaiMathur/JaiMathur_version_backup/ch2.ipynb @@ -0,0 +1,309 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:30849a845cb23e6184901c441ceb4a2e2451d5db6a2c0f60dce1b23531e4d077" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : Similarity" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 Page No : 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\n", + "#initialisation of variables\n", + "r= 4.\n", + "l1= 4 \t#units long axis\n", + "l2= 10 \t#units long axis\n", + "\t\n", + "#CALCULATIONS\n", + "sxy= (4/r)\n", + "sxy1= l1**2\n", + "sxy2= l2**2\n", + "\t\n", + "#RESULTS\n", + "print 'x**2+4*y**2 = %.f '%(sxy)\n", + "print ' x**2+4*y**2 = %.f '%(sxy1)\n", + "print ' x**2+4*y**2 = %.f '%(sxy2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x**2+4*y**2 = 1 \n", + " x**2+4*y**2 = 16 \n", + " x**2+4*y**2 = 100 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page No : 29" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialisation of variables\n", + "vo= 10 \t#ft/sec\n", + "a= 0.5 \t#ft**-1\n", + "b= 1 \t#ft\n", + "x= -2 \t#ft\n", + "y= 2 \t#ft\n", + "b1= 2\n", + "a1= 3./5 \t#ft\n", + "\t\n", + "#CALCULATIONS\n", + "Vx= vo/(a*x**2+b)\n", + "Vy= -2*a*b*vo*x*y/(a*x**2+b)**2\n", + "V= math.sqrt(Vx**2+Vy**2)\n", + "fx= -2*a*b**2*vo**2*x/(a*x**2+b)**3\n", + "fy= 2*a*b**2*vo**2*y*(b-a*x**2)/(a*x**2+b)**4\n", + "f= math.sqrt(fx**2+fy**2)\n", + "r= b1**2/a1\n", + "f1= f*r\n", + "\t\n", + "#RESULTS\n", + "print 'Vx = %.2f ft/sec'%(Vx)\n", + "print ' Vy = %.2f ft/sec'%(Vy)\n", + "print ' V = %.2f ft/sec'%(V)\n", + "print ' fx = %.2f ft/sec**2'%(fx)\n", + "print ' fy = %.2f ft/sec**2'%(fy)\n", + "print ' f = %.2f ft/sec**2'%(f)\n", + "print ' r = %.2f in the present case'%(r)\n", + "print ' f1 = %.2f ft/sec**2'%(f1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vx = 3.33 ft/sec\n", + " Vy = 4.44 ft/sec\n", + " V = 5.56 ft/sec\n", + " fx = 7.41 ft/sec**2\n", + " fy = -2.47 ft/sec**2\n", + " f = 7.81 ft/sec**2\n", + " r = 6.67 in the present case\n", + " f1 = 52.05 ft/sec**2\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page No : 36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\n", + "#initialisation of variables\n", + "r= 1./5\n", + "b1= 2 \t#ft\n", + "a1= 3./5 \t#ft\n", + "\t\n", + "#CALCULATIONS\n", + "r= (a1*b1)**2*r\n", + "\t\n", + "#RESULTS\n", + "print 'ratio of resultant forces acting on coorresponding fluid elements = %.3f '%(r)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ratio of resultant forces acting on coorresponding fluid elements = 0.288 \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page No : 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\n", + "#initialisation of variables\n", + "vos= 70. \t#ft/sec\n", + "as1= 78. \t#ft density\n", + "am= 72. \t#ft wind-tunnel\n", + "ls1= 6. \t#ft strut section\n", + "lm= 2. \t#ft length\n", + "um= 386. \t#ft/sec\n", + "us= 372. \t#ft/sec\n", + "dm= 0.4\n", + "\t\n", + "#CALCULATIONS\n", + "vom= vos*as1*ls1*um/(am*lm*us)\n", + "Ds= dm*(am/as1)*(us/um)**2\n", + "\t\n", + "#RESULTS\n", + "print 'Air speed = %.f ft/sec'%(vom)\n", + "print ' Ds = %.3f lbf'%(Ds)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Air speed = 236 ft/sec\n", + " Ds = 0.343 lbf\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page No : 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\t\n", + "#initialisation of variables\n", + "vom= 236. \t#ft/sec\n", + "as1= 0.072 \t#ft\n", + "am = 62.4 \t#ft density of water\n", + "ls1= 2. \t#ft\n", + "lm= 8. \t#ft\n", + "um= 248. \t#ft/sec viscosity\n", + "us= 3.86 \t#ft/sec\n", + "Pm= 0.4/3.3\n", + "\t\n", + "#CALCULATIONS\n", + "voh= vom*as1*ls1*um/(am*lm*us)\n", + "Ds= Pm*(as1/am)*(um/us)**2*(ls1/lm)*(lm-ls1)\n", + "\t\n", + "#RESULTS\n", + "print 'Air speed = %.2f ft/sec'%(voh)\n", + "print ' Drag force = %.3f lbf'%(Ds)\n", + "\n", + "# note : rounding off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Air speed = 4.37 ft/sec\n", + " Drag force = 0.866 lbf\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page No : 51" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\t\n", + "#initialisation of variables\n", + "To1= 540. \t#R temperature\n", + "po3= 12.6 \t#lbf/in**2\n", + "l3= 3. \t#ft\n", + "po1= 14.7 \t#lbf/in**2 pressure\n", + "l1= 1. \t#ft\n", + "vo1= 500. \t#ft/sec velocity\n", + "r= 0.83\n", + "P1= 1. \t#lbf/in**2 turbine blade\n", + "\t\n", + "#CALCULATIONS\n", + "To3= To1*(po3*l3/(po1*l1))**r\n", + "Vo3= vo1*math.sqrt(To3/To1)\n", + "P3= P1*po3*l3/(po1*l1)\n", + "\t\n", + "#RESULTS\n", + "print 'To3 = %.f R'%(To3)\n", + "print ' Vo3 = %.f ft/sec'%(Vo3)\n", + "print ' P3 = %.2f lbf/ft'%(P3)\n", + "\n", + "# note : book answers are not accurate." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "To3 = 1183 R\n", + " Vo3 = 740 ft/sec\n", + " P3 = 2.57 lbf/ft\n" + ] + } + ], + "prompt_number": 4 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/JaiMathur/ch2.ipynb b/sample_notebooks/JaiMathur/ch2.ipynb deleted file mode 100755 index eab5eede..00000000 --- a/sample_notebooks/JaiMathur/ch2.ipynb +++ /dev/null @@ -1,309 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:30849a845cb23e6184901c441ceb4a2e2451d5db6a2c0f60dce1b23531e4d077" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 : Similarity" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 Page No : 23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\t\n", - "#initialisation of variables\n", - "r= 4.\n", - "l1= 4 \t#units long axis\n", - "l2= 10 \t#units long axis\n", - "\t\n", - "#CALCULATIONS\n", - "sxy= (4/r)\n", - "sxy1= l1**2\n", - "sxy2= l2**2\n", - "\t\n", - "#RESULTS\n", - "print 'x**2+4*y**2 = %.f '%(sxy)\n", - "print ' x**2+4*y**2 = %.f '%(sxy1)\n", - "print ' x**2+4*y**2 = %.f '%(sxy2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x**2+4*y**2 = 1 \n", - " x**2+4*y**2 = 16 \n", - " x**2+4*y**2 = 100 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 Page No : 29" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialisation of variables\n", - "vo= 10 \t#ft/sec\n", - "a= 0.5 \t#ft**-1\n", - "b= 1 \t#ft\n", - "x= -2 \t#ft\n", - "y= 2 \t#ft\n", - "b1= 2\n", - "a1= 3./5 \t#ft\n", - "\t\n", - "#CALCULATIONS\n", - "Vx= vo/(a*x**2+b)\n", - "Vy= -2*a*b*vo*x*y/(a*x**2+b)**2\n", - "V= math.sqrt(Vx**2+Vy**2)\n", - "fx= -2*a*b**2*vo**2*x/(a*x**2+b)**3\n", - "fy= 2*a*b**2*vo**2*y*(b-a*x**2)/(a*x**2+b)**4\n", - "f= math.sqrt(fx**2+fy**2)\n", - "r= b1**2/a1\n", - "f1= f*r\n", - "\t\n", - "#RESULTS\n", - "print 'Vx = %.2f ft/sec'%(Vx)\n", - "print ' Vy = %.2f ft/sec'%(Vy)\n", - "print ' V = %.2f ft/sec'%(V)\n", - "print ' fx = %.2f ft/sec**2'%(fx)\n", - "print ' fy = %.2f ft/sec**2'%(fy)\n", - "print ' f = %.2f ft/sec**2'%(f)\n", - "print ' r = %.2f in the present case'%(r)\n", - "print ' f1 = %.2f ft/sec**2'%(f1)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Vx = 3.33 ft/sec\n", - " Vy = 4.44 ft/sec\n", - " V = 5.56 ft/sec\n", - " fx = 7.41 ft/sec**2\n", - " fy = -2.47 ft/sec**2\n", - " f = 7.81 ft/sec**2\n", - " r = 6.67 in the present case\n", - " f1 = 52.05 ft/sec**2\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 Page No : 36" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\t\n", - "#initialisation of variables\n", - "r= 1./5\n", - "b1= 2 \t#ft\n", - "a1= 3./5 \t#ft\n", - "\t\n", - "#CALCULATIONS\n", - "r= (a1*b1)**2*r\n", - "\t\n", - "#RESULTS\n", - "print 'ratio of resultant forces acting on coorresponding fluid elements = %.3f '%(r)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "ratio of resultant forces acting on coorresponding fluid elements = 0.288 \n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5 Page No : 44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\t\n", - "#initialisation of variables\n", - "vos= 70. \t#ft/sec\n", - "as1= 78. \t#ft density\n", - "am= 72. \t#ft wind-tunnel\n", - "ls1= 6. \t#ft strut section\n", - "lm= 2. \t#ft length\n", - "um= 386. \t#ft/sec\n", - "us= 372. \t#ft/sec\n", - "dm= 0.4\n", - "\t\n", - "#CALCULATIONS\n", - "vom= vos*as1*ls1*um/(am*lm*us)\n", - "Ds= dm*(am/as1)*(us/um)**2\n", - "\t\n", - "#RESULTS\n", - "print 'Air speed = %.f ft/sec'%(vom)\n", - "print ' Ds = %.3f lbf'%(Ds)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Air speed = 236 ft/sec\n", - " Ds = 0.343 lbf\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 Page No : 45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\t\n", - "#initialisation of variables\n", - "vom= 236. \t#ft/sec\n", - "as1= 0.072 \t#ft\n", - "am = 62.4 \t#ft density of water\n", - "ls1= 2. \t#ft\n", - "lm= 8. \t#ft\n", - "um= 248. \t#ft/sec viscosity\n", - "us= 3.86 \t#ft/sec\n", - "Pm= 0.4/3.3\n", - "\t\n", - "#CALCULATIONS\n", - "voh= vom*as1*ls1*um/(am*lm*us)\n", - "Ds= Pm*(as1/am)*(um/us)**2*(ls1/lm)*(lm-ls1)\n", - "\t\n", - "#RESULTS\n", - "print 'Air speed = %.2f ft/sec'%(voh)\n", - "print ' Drag force = %.3f lbf'%(Ds)\n", - "\n", - "# note : rounding off error" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Air speed = 4.37 ft/sec\n", - " Drag force = 0.866 lbf\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 Page No : 51" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\t\n", - "#initialisation of variables\n", - "To1= 540. \t#R temperature\n", - "po3= 12.6 \t#lbf/in**2\n", - "l3= 3. \t#ft\n", - "po1= 14.7 \t#lbf/in**2 pressure\n", - "l1= 1. \t#ft\n", - "vo1= 500. \t#ft/sec velocity\n", - "r= 0.83\n", - "P1= 1. \t#lbf/in**2 turbine blade\n", - "\t\n", - "#CALCULATIONS\n", - "To3= To1*(po3*l3/(po1*l1))**r\n", - "Vo3= vo1*math.sqrt(To3/To1)\n", - "P3= P1*po3*l3/(po1*l1)\n", - "\t\n", - "#RESULTS\n", - "print 'To3 = %.f R'%(To3)\n", - "print ' Vo3 = %.f ft/sec'%(Vo3)\n", - "print ' P3 = %.2f lbf/ft'%(P3)\n", - "\n", - "# note : book answers are not accurate." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "To3 = 1183 R\n", - " Vo3 = 740 ft/sec\n", - " P3 = 2.57 lbf/ft\n" - ] - } - ], - "prompt_number": 4 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/JayDadlani/SAMPLE_NB_KI.ipynb b/sample_notebooks/JayDadlani/SAMPLE_NB_KI.ipynb new file mode 100755 index 00000000..7ccc9697 --- /dev/null +++ b/sample_notebooks/JayDadlani/SAMPLE_NB_KI.ipynb @@ -0,0 +1,220 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:58e66a1486b17622aacd34bb93b225c18134442ddc1f2fbedecd0abdd0c9b88e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "A TEXTBOOK OF PHYSICAL CHEMISTRY BY K.I. KAPOOR" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 1 : EQUILIBRIUM BETWEEN PHASES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.5.1 : PAGE NUMBER 10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "T1 = 234.5 # Temperature in K\n", + "P = 1 # Pressure in atm\n", + "rho1 = 14.19 # Density of solid Hg in g/(cm**3)\n", + "rho2 = 13.70 # Density of liquid Hg in g/(cm**3)\n", + "V = 200.59 # volume of liquid and solid in g/mol\n", + "delV = ((V/rho2)-(V/rho1))*(10**-3)# in dm**3/mol\n", + "delTdelP = 0.0051 # K/atm\n", + "R1 = 8.314 # in J\n", + "R2 = 0.082 # in (dm)**3/atm\n", + "delH = ((delV*T1)/(delTdelP))*(R1/R2)*10**-3;#molar heat of fusion in kJ/mol\n", + "print \" delH = \",round(delH,4),\"(KJ)/mol \"\n", + "T2 = 273# in K\n", + "delP = (delH*(R2/R1)*(T2-T1))/(delV*T1)*10**3;#pressure required to raise melting point to T2 in atm\n", + "print \" delP = \",round(delP,4),\"atm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " delH = 2.3571 (KJ)/mol \n", + " delP = 7549.0196 atm\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.5.2 : PAGE NUMBER 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math;\n", + "T1=373.15;#in K\n", + "P=1;#atm\n", + "Vv=1674;#in cm**3/gm\n", + "delPdelT=27.12;#in torr/K\n", + "R1=8.314;#in J\n", + "R2=0.082;#in atm/(dm)**3\n", + "delH=((delPdelT)/760)*T1*((Vv*10**-3)*18)*(R1/R2)\n", + "print \" delH = \",round(delH,4),\" J/mol \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " delH = 40680.2549 J/mol \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.5.3 : PAGE NUMBER 16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math;\n", + "T1=313.75;#in K\n", + "P1=59.1;#in torr\n", + "T2=353.15;#in K\n", + "P2=298.7;#in torr\n", + "R=2.303*8.314;#in J/(K*mol)\n", + "delH=R*math.log10(P2/P1)*((T2*T1)/(T2-T1))\n", + "print \" delH= \",round(delH,4),\" J/mol \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " delH= 37888.375 J/mol \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.5.4 : PAGE NUMBER 16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "T1=325.15;#in K\n", + "T2=338.15;#in K\n", + "P2=760;#in torr\n", + "DelHm_v=10.5;#\n", + "P1=P2/(10**((DelHm_v/2.303)*((T2/T1)-1)));#in torr\n", + "print \" P1= \",round(P1,4),\"torr \"\n", + "P=200;#in torr\n", + "T=T2/(1+((2.303/10.5)*math.log10(P2/P)));#in K\n", + "print \" T =\",round(T,4),\" K \"\n", + "I=math.log10(P2)-(((DelHm_v*T2)/2.303)*(-1/T2));#\n", + "print \" I = \",round(I,4)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " P1= 499.4901 torr \n", + " T = 306.1154 K \n", + " I = 7.4401\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 1.5.5 : PAGE NUMBER 17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math;\n", + "P=760;#in torr\n", + "dP=52;#in torr\n", + "dT=2;#in K\n", + "DelH_RTb=10.5;#Trouton rule\n", + "Tb=(DelH_RTb*P)/(dP/dT)\n", + "print \" Tb = \",round(Tb,4),\" K\"\n", + "R=8.314;#in J/Kmol\n", + "DelH_v=(DelH_RTb*R*Tb)\n", + "print \" DelH_v = \",round(DelH_v,4),\"J/mol \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Tb = 306.9231 K\n", + " DelH_v = 26793.4638 J/mol \n" + ] + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/JayDadlani/SAMPLE_NB_KI_KAPOOR.ipynb b/sample_notebooks/JayDadlani/SAMPLE_NB_KI_KAPOOR.ipynb deleted file mode 100755 index 7ccc9697..00000000 --- a/sample_notebooks/JayDadlani/SAMPLE_NB_KI_KAPOOR.ipynb +++ /dev/null @@ -1,220 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:58e66a1486b17622aacd34bb93b225c18134442ddc1f2fbedecd0abdd0c9b88e" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "A TEXTBOOK OF PHYSICAL CHEMISTRY BY K.I. KAPOOR" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 1 : EQUILIBRIUM BETWEEN PHASES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.5.1 : PAGE NUMBER 10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "T1 = 234.5 # Temperature in K\n", - "P = 1 # Pressure in atm\n", - "rho1 = 14.19 # Density of solid Hg in g/(cm**3)\n", - "rho2 = 13.70 # Density of liquid Hg in g/(cm**3)\n", - "V = 200.59 # volume of liquid and solid in g/mol\n", - "delV = ((V/rho2)-(V/rho1))*(10**-3)# in dm**3/mol\n", - "delTdelP = 0.0051 # K/atm\n", - "R1 = 8.314 # in J\n", - "R2 = 0.082 # in (dm)**3/atm\n", - "delH = ((delV*T1)/(delTdelP))*(R1/R2)*10**-3;#molar heat of fusion in kJ/mol\n", - "print \" delH = \",round(delH,4),\"(KJ)/mol \"\n", - "T2 = 273# in K\n", - "delP = (delH*(R2/R1)*(T2-T1))/(delV*T1)*10**3;#pressure required to raise melting point to T2 in atm\n", - "print \" delP = \",round(delP,4),\"atm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " delH = 2.3571 (KJ)/mol \n", - " delP = 7549.0196 atm\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.5.2 : PAGE NUMBER 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math;\n", - "T1=373.15;#in K\n", - "P=1;#atm\n", - "Vv=1674;#in cm**3/gm\n", - "delPdelT=27.12;#in torr/K\n", - "R1=8.314;#in J\n", - "R2=0.082;#in atm/(dm)**3\n", - "delH=((delPdelT)/760)*T1*((Vv*10**-3)*18)*(R1/R2)\n", - "print \" delH = \",round(delH,4),\" J/mol \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " delH = 40680.2549 J/mol \n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.5.3 : PAGE NUMBER 16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math;\n", - "T1=313.75;#in K\n", - "P1=59.1;#in torr\n", - "T2=353.15;#in K\n", - "P2=298.7;#in torr\n", - "R=2.303*8.314;#in J/(K*mol)\n", - "delH=R*math.log10(P2/P1)*((T2*T1)/(T2-T1))\n", - "print \" delH= \",round(delH,4),\" J/mol \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " delH= 37888.375 J/mol \n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.5.4 : PAGE NUMBER 16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "T1=325.15;#in K\n", - "T2=338.15;#in K\n", - "P2=760;#in torr\n", - "DelHm_v=10.5;#\n", - "P1=P2/(10**((DelHm_v/2.303)*((T2/T1)-1)));#in torr\n", - "print \" P1= \",round(P1,4),\"torr \"\n", - "P=200;#in torr\n", - "T=T2/(1+((2.303/10.5)*math.log10(P2/P)));#in K\n", - "print \" T =\",round(T,4),\" K \"\n", - "I=math.log10(P2)-(((DelHm_v*T2)/2.303)*(-1/T2));#\n", - "print \" I = \",round(I,4)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " P1= 499.4901 torr \n", - " T = 306.1154 K \n", - " I = 7.4401\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 1.5.5 : PAGE NUMBER 17" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math;\n", - "P=760;#in torr\n", - "dP=52;#in torr\n", - "dT=2;#in K\n", - "DelH_RTb=10.5;#Trouton rule\n", - "Tb=(DelH_RTb*P)/(dP/dT)\n", - "print \" Tb = \",round(Tb,4),\" K\"\n", - "R=8.314;#in J/Kmol\n", - "DelH_v=(DelH_RTb*R*Tb)\n", - "print \" DelH_v = \",round(DelH_v,4),\"J/mol \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Tb = 306.9231 K\n", - " DelH_v = 26793.4638 J/mol \n" - ] - } - ], - "prompt_number": 16 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Jaya Sravya/Chapter10.ipynb b/sample_notebooks/Jaya Sravya/Chapter10.ipynb deleted file mode 100755 index c2b2749b..00000000 --- a/sample_notebooks/Jaya Sravya/Chapter10.ipynb +++ /dev/null @@ -1,694 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:7afbb46d48c2bdf700c3dc220becf18da8796860629c8c3b8505b530a4a07b18" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter10:Rotational Mechanics" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E1 - Pg 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 10.1\n", - "#calculation of the number of revolutions made\n", - "#given data\n", - "import math \n", - "wzero=100.*2.*math.pi/60.#initial angular velocity(in rad/s) of the motor\n", - "w=0#final angular velocity(in rad/s) of the motor\n", - "t=15.#time interval(in s)\n", - "\n", - "#calculation\n", - "alpha=(w-wzero)/t#equation of angular motion\n", - "theta=(wzero*t)+(alpha*t*t/2.)#equation of angular motion\n", - "\n", - "print '%s %.2f' %(\"the number of revolutions the motor makes before coming to rest is\",theta/(2*math.pi))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the number of revolutions the motor makes before coming to rest is 12.50\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E1w - Pg 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.1w\n", - "#calculation of the number of revolutions made by the wheel \n", - "\n", - "#given data\n", - "wzero=0#initial angular velocity(in rad/s) of the wheel \n", - "alpha=2.#angular acceleration(in rad/s**2)\n", - "t=10#time(in s) interval\n", - "\n", - "#calculation\n", - "theta=(wzero*t)+(alpha*t*t/2.)#equation of angular motion\n", - "n=round(theta/(2.*math.pi))#number of revolutions\n", - "\n", - "print '%s %.2f' %(\"the number of revolutions made by the wheel is\",n)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the number of revolutions made by the wheel is 16.00\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E2 - Pg 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.2\n", - "#calculation of the time taken by the fan to attain half of the maximum speed\n", - "\n", - "#given data\n", - "wzero=0#initial angular velocity(in rad/s) of the fan\n", - "w=400.*(2.*math.pi/60.)#final angular velocity(in rad/s) of the fan\n", - "t=5#tiem(in s) taken\n", - "\n", - "#calculation\n", - "alpha=(w-wzero)/t#equation of angular motion\n", - "wdash=w/2.#half of maximum speed\n", - "t1=(wdash-wzero)/alpha#equation of angular motion\n", - "\n", - "print '%s %.2f %s' %(\"the time taken by the fan to attain half of the maximum speed is\",t1,\"s\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the time taken by the fan to attain half of the maximum speed is 2.50 s\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E2w - Pg 27" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.2w\n", - "#calculation of the angle rotated during the next second\n", - "\n", - "#given data\n", - "theta=2.5#angular displacement(in rad) of the wheel\n", - "t=1.#time(in s) required\n", - "\n", - "#calculation\n", - "alpha=(theta*2.)/(t*t)#equation of angular motion\n", - "theta1=(alpha*(t+1.)*(t+1.)/2.)#angle rotated during first two seconds\n", - "thetar=theta1-theta#angle rotated during next second\n", - "\n", - "print '%s %.2f %s' %(\"the angle rotated during the next second is\",thetar,\"rad\\n\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the angle rotated during the next second is 7.50 rad\n", - "\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E3 - Pg 28" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#example 10.3\n", - "#calculation of the angular velocity and angular acceleration of the pulley \n", - "\n", - "#given data\n", - "v=20.#linear speed(in cm/s) of the bucket\n", - "r=10.#radius(in cm) of the pulley\n", - "a=4.*10.**2.#linear acceleration(in cm/s**2) of the pulley\n", - "\n", - "#calculation\n", - "w=v/r#formula of angular velocity\n", - "alpha=a/r#formula of angular acceleration\n", - "\n", - "print '%s %.2f %s %s %.2f %s' %(\"the angular velocity of the pulley is\",w,\"rad/s\",\"and angular acceleration of the pulley is\",alpha,\"rad/s**2\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the angular velocity of the pulley is 2.00 rad/s and angular acceleration of the pulley is 40.00 rad/s**2\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E3w - Pg 28" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.3w\n", - "#calculation of the torque required to stop the wheel in one minute\n", - "\n", - "#given data\n", - "wzero=50.*(2.*math.pi/60.)#initial angular velocity(in rad/s) of the wheel\n", - "w=0#final angular velocity(in rad/s) of the wheel\n", - "t=60.#time(in s) taken to stop the wheel\n", - "I=2.#moment of inertia(in kg-m**2) of the wheel\n", - "\n", - "#calculation\n", - "alpha=(w-wzero)/t#equation of angular motion\n", - "tau=I*abs(alpha)#torque\n", - "\n", - "print '%s %.2f %s' %(\"the torque required to stop the wheel in one minute is\",tau,\"N-m\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the torque required to stop the wheel in one minute is 0.17 N-m\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E4w - Pg 30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.4w\n", - "#calculation of the angular velocity of the wheel\n", - "\n", - "#given data\n", - "F=20.#force(in N) of pull applied\n", - "I=.2#moment of inertia(in kg-m**2)\n", - "r=20.*10.**-2.#radius(in m) of the wheel\n", - "t=5.#time(in s) interval\n", - "wzero=0#initial angular velocity(in rad/s) of the wheel \n", - "\n", - "#calculation\n", - "tau=F*r#torque applied to the wheel\n", - "alpha=tau/I#angular acceleration\n", - "w=wzero+(alpha*t)#equation of angular motion\n", - "\n", - "print '%s %.2f %s' %(\"the angular velocity of the wheel after 5 s is\",w,\"rad/s\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the angular velocity of the wheel after 5 s is 100.00 rad/s\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E5 - Pg 30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.5\n", - "#calculation of the moment of inertia of the wheel\n", - "\n", - "#given data\n", - "r=10.*10.**-2.#radius(in m) of the wheel\n", - "F=5.#force(in N) of pulling\n", - "aplha=2.#angular acceleration(in rad/s**2) of the wheel\n", - "\n", - "#calculation\n", - "tau=F*r#net torque\n", - "I=tau/aplha#moment of inertia\n", - "\n", - "print '%s %.2f %s' %(\"the moment of inertia of the wheel is\",I,\"kg-m**2\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the moment of inertia of the wheel is 0.25 kg-m**2\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E7w - Pg 31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.7w\n", - "#calculation of the position of second kid on a balanced seesaw\n", - "\n", - "#given data\n", - "ma=10.#mass(in kg) of kid A\n", - "mb=15.#mass(in kg) of kid B\n", - "l=5.#length(in m) of the seesaw\n", - "la=(l/2.)#distance of A kid from fulcrum as he is sitting at an end\n", - "\n", - "#calculation\n", - "#taking torque about fulcrum...........(mb*g*x) = (ma*g*)\n", - "x=(ma*la)/mb\n", - "\n", - "print '%s %.2f %s' %(\"the second kid should sit at a distance of\",x,\"m from the centre\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the second kid should sit at a distance of 1.67 m from the centre\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E8w - Pg 31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#example 10.8w\n", - "#calculation of the normal force and the frictional force that the floor exerts on the ladder\n", - "\n", - "#given data\n", - "m=10.#mass(in kg) of the ladder\n", - "theta=53.#angle(in degree) made by the ladder against the vertical wall\n", - "g=9.8#gravitational acceleration(in m/s**2) of the earth\n", - "\n", - "#calculation\n", - "#taking horizontal and vertical components\n", - "#N1 = f........................(1)\n", - "#N2 = W........................(2)\n", - "#taking torque about B\n", - "W=m*g\n", - "N2=W#from equation (2)\n", - "f=(W*math.sin(theta)*57.3/2.)/(math.cos(theta)*57.3)#from equation (1)\n", - "\n", - "print '%s %.2f %s' %(\"the normal force that the floor exerts on the ladder is\",N2,\"N\\n\")\n", - "print '%s %.2f %s' %(\"the frictional force that the floor exerts on the ladder is\",f,\"N\\n\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the normal force that the floor exerts on the ladder is 98.00 N\n", - "\n", - "the frictional force that the floor exerts on the ladder is -21.13 N\n", - "\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E9w - Pg 35" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.9w\n", - "#calculation of the contact force exerted by the floor on each leg of ladder\n", - "\n", - "#given data\n", - "theta=60.#angle(in degree) between the two legs\n", - "m=80.#mass(in kg) of the person\n", - "g=9.8#gravitational acceleration(in m/s**2) of the earth\n", - "\n", - "#calculation\n", - "N=m*g/2.\n", - "T=(N*2.*math.tan(90-theta)*57.3)/1.\n", - "\n", - "print '%s %.2f %s' %(\"the contact force exerted by the floor on each leg of ladder\",N,\"N\\n\")\n", - "print '%s %.2f %s' %(\"the tension in the crossbar is\",T,\"N\\n\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the contact force exerted by the floor on each leg of ladder 392.00 N\n", - "\n", - "the tension in the crossbar is -287747.97 N\n", - "\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E12 - Pg 36" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.12\n", - "#calculation of the kinetic energy of the sphere\n", - "\n", - "#given data\n", - "M=200.*10.**-3.#mass(in kg) of the sphere\n", - "vcm=2.*10.**-2.#speed(in m/s) of the sphere\n", - "\n", - "#calculation\n", - "#kinetic energy is K = (Icm*w*w/2) + (M*vcm*vcm/2)\n", - "#taking Icm = (2*M*r*r*w*w/5) and w=vcm/r\n", - "K=(M*vcm*vcm/5.)+(M*vcm*vcm/2.)#kinetic energy\n", - "\n", - "print '%s %.5f %s' %(\"the kinetic energy of the sphere is\",K,\"J\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the kinetic energy of the sphere is 0.00006 J\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E13w - Pg 37" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.13w\n", - "#calculation of the kinetic energy and angular momentum of the disc\n", - "\n", - "#given data\n", - "M=200.*10.**-3.#mass(in kg) of the disc\n", - "r=4.*10.**-2.#radius(in m) of the disc\n", - "w=10.#angular velocity(in rad/s) \n", - "\n", - "#calculation\n", - "I=(M*r*r)/4.#moment of inertia\n", - "K=(I*w*w/2.)#kinetic energy\n", - "L=I*w#angular momentum\n", - "\n", - "print '%s %.2f %s' %(\"the kinetic energy of the disc is\",K,\"J\")\n", - "print '%s %.2f %s' %(\"\\nthe angular momentum of the disc is\",L,\"J-s\\n\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the kinetic energy of the disc is 0.00 J\n", - "\n", - "the angular momentum of the disc is 0.00 J-s\n", - "\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E14w - Pg 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#example 10.14w\n", - "#calculation of the work done by the torque in first two seconds\n", - "#given data\n", - "wzero=20.#initial angular velocity(in rad/s) of the motor\n", - "w=0#final angular velocity(in rad/s) of the motor\n", - "t=4.#time(in s) taken to attain rest position\n", - "I=.20#moment of inertia(in kg-m**2) of the disc about axis of rotation\n", - "t1=2.#time(in s)\n", - "\n", - "#calculation\n", - "alpha=(wzero-w)/t#equation of angular motion in case of deceleration\n", - "tau=I*alpha#torque\n", - "theta=(wzero*t1)-(alpha*t1*t1/2)#equation of angular motion\n", - "W=tau*theta#work done by the torque\n", - "\n", - "print '%s %.2f %s' %(\"the work done by the torque in first two seconds is\",W,\"J\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the work done by the torque in first two seconds is 30.00 J\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E19w - Pg 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#example 10.19w\n", - "#calculation of the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point\n", - "\n", - "#given data\n", - "m=1.2#mass(in kg) of the sphere\n", - "R=10.*10.**-2.#radius(in cm) of the sphere\n", - "sep=50.*10.**-2.#separation(in m) between the two spheres\n", - "\n", - "#calculation\n", - "d=sep/2.#distance of each sphere from centre\n", - "Icm=(2.*m*R*R)/5.#moment of inertia about diameter\n", - "I=Icm+(m*d*d)#by parallel axis theorem,moment of inertia about given axis \n", - "#since second sphere has same moment of inertia\n", - "Isys=2.*I#moment of inertia of the system\n", - "\n", - "print '%s %.2f %s' %(\"the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point is\",Isys,\"kg-m**2\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point is 0.16 kg-m**2\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E22w - Pg 42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#example 10.22w\n", - "#calculation of the number of revolutions made by the wheel per second\n", - "\n", - "#given data\n", - "p=220.*10.**-2.#perimeter(in cm) of the wheel\n", - "v=9.*10.**3./(60.*60.)#linear speed(in m/s) of wheel on the road\n", - "\n", - "#calculation\n", - "r=p/(2.*math.pi)#radius of the wheel\n", - "w=v/r#angular speed\n", - "n=w/(2.*math.pi)#number of revolutions\n", - "\n", - "print '%s %.2f %s' %(\"the number of revolutions made by the wheel per second is\",n,\"rev/s\\n\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the number of revolutions made by the wheel per second is 1.14 rev/s\n", - "\n" - ] - } - ], - "prompt_number": 16 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Jaya Sravya/Jaya Sravya_version_backup/Chapter10.ipynb b/sample_notebooks/Jaya Sravya/Jaya Sravya_version_backup/Chapter10.ipynb new file mode 100755 index 00000000..c2b2749b --- /dev/null +++ b/sample_notebooks/Jaya Sravya/Jaya Sravya_version_backup/Chapter10.ipynb @@ -0,0 +1,694 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:7afbb46d48c2bdf700c3dc220becf18da8796860629c8c3b8505b530a4a07b18" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter10:Rotational Mechanics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E1 - Pg 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 10.1\n", + "#calculation of the number of revolutions made\n", + "#given data\n", + "import math \n", + "wzero=100.*2.*math.pi/60.#initial angular velocity(in rad/s) of the motor\n", + "w=0#final angular velocity(in rad/s) of the motor\n", + "t=15.#time interval(in s)\n", + "\n", + "#calculation\n", + "alpha=(w-wzero)/t#equation of angular motion\n", + "theta=(wzero*t)+(alpha*t*t/2.)#equation of angular motion\n", + "\n", + "print '%s %.2f' %(\"the number of revolutions the motor makes before coming to rest is\",theta/(2*math.pi))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the number of revolutions the motor makes before coming to rest is 12.50\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E1w - Pg 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.1w\n", + "#calculation of the number of revolutions made by the wheel \n", + "\n", + "#given data\n", + "wzero=0#initial angular velocity(in rad/s) of the wheel \n", + "alpha=2.#angular acceleration(in rad/s**2)\n", + "t=10#time(in s) interval\n", + "\n", + "#calculation\n", + "theta=(wzero*t)+(alpha*t*t/2.)#equation of angular motion\n", + "n=round(theta/(2.*math.pi))#number of revolutions\n", + "\n", + "print '%s %.2f' %(\"the number of revolutions made by the wheel is\",n)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the number of revolutions made by the wheel is 16.00\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E2 - Pg 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.2\n", + "#calculation of the time taken by the fan to attain half of the maximum speed\n", + "\n", + "#given data\n", + "wzero=0#initial angular velocity(in rad/s) of the fan\n", + "w=400.*(2.*math.pi/60.)#final angular velocity(in rad/s) of the fan\n", + "t=5#tiem(in s) taken\n", + "\n", + "#calculation\n", + "alpha=(w-wzero)/t#equation of angular motion\n", + "wdash=w/2.#half of maximum speed\n", + "t1=(wdash-wzero)/alpha#equation of angular motion\n", + "\n", + "print '%s %.2f %s' %(\"the time taken by the fan to attain half of the maximum speed is\",t1,\"s\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the time taken by the fan to attain half of the maximum speed is 2.50 s\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E2w - Pg 27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.2w\n", + "#calculation of the angle rotated during the next second\n", + "\n", + "#given data\n", + "theta=2.5#angular displacement(in rad) of the wheel\n", + "t=1.#time(in s) required\n", + "\n", + "#calculation\n", + "alpha=(theta*2.)/(t*t)#equation of angular motion\n", + "theta1=(alpha*(t+1.)*(t+1.)/2.)#angle rotated during first two seconds\n", + "thetar=theta1-theta#angle rotated during next second\n", + "\n", + "print '%s %.2f %s' %(\"the angle rotated during the next second is\",thetar,\"rad\\n\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the angle rotated during the next second is 7.50 rad\n", + "\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E3 - Pg 28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#example 10.3\n", + "#calculation of the angular velocity and angular acceleration of the pulley \n", + "\n", + "#given data\n", + "v=20.#linear speed(in cm/s) of the bucket\n", + "r=10.#radius(in cm) of the pulley\n", + "a=4.*10.**2.#linear acceleration(in cm/s**2) of the pulley\n", + "\n", + "#calculation\n", + "w=v/r#formula of angular velocity\n", + "alpha=a/r#formula of angular acceleration\n", + "\n", + "print '%s %.2f %s %s %.2f %s' %(\"the angular velocity of the pulley is\",w,\"rad/s\",\"and angular acceleration of the pulley is\",alpha,\"rad/s**2\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the angular velocity of the pulley is 2.00 rad/s and angular acceleration of the pulley is 40.00 rad/s**2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E3w - Pg 28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.3w\n", + "#calculation of the torque required to stop the wheel in one minute\n", + "\n", + "#given data\n", + "wzero=50.*(2.*math.pi/60.)#initial angular velocity(in rad/s) of the wheel\n", + "w=0#final angular velocity(in rad/s) of the wheel\n", + "t=60.#time(in s) taken to stop the wheel\n", + "I=2.#moment of inertia(in kg-m**2) of the wheel\n", + "\n", + "#calculation\n", + "alpha=(w-wzero)/t#equation of angular motion\n", + "tau=I*abs(alpha)#torque\n", + "\n", + "print '%s %.2f %s' %(\"the torque required to stop the wheel in one minute is\",tau,\"N-m\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the torque required to stop the wheel in one minute is 0.17 N-m\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E4w - Pg 30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.4w\n", + "#calculation of the angular velocity of the wheel\n", + "\n", + "#given data\n", + "F=20.#force(in N) of pull applied\n", + "I=.2#moment of inertia(in kg-m**2)\n", + "r=20.*10.**-2.#radius(in m) of the wheel\n", + "t=5.#time(in s) interval\n", + "wzero=0#initial angular velocity(in rad/s) of the wheel \n", + "\n", + "#calculation\n", + "tau=F*r#torque applied to the wheel\n", + "alpha=tau/I#angular acceleration\n", + "w=wzero+(alpha*t)#equation of angular motion\n", + "\n", + "print '%s %.2f %s' %(\"the angular velocity of the wheel after 5 s is\",w,\"rad/s\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the angular velocity of the wheel after 5 s is 100.00 rad/s\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E5 - Pg 30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.5\n", + "#calculation of the moment of inertia of the wheel\n", + "\n", + "#given data\n", + "r=10.*10.**-2.#radius(in m) of the wheel\n", + "F=5.#force(in N) of pulling\n", + "aplha=2.#angular acceleration(in rad/s**2) of the wheel\n", + "\n", + "#calculation\n", + "tau=F*r#net torque\n", + "I=tau/aplha#moment of inertia\n", + "\n", + "print '%s %.2f %s' %(\"the moment of inertia of the wheel is\",I,\"kg-m**2\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the moment of inertia of the wheel is 0.25 kg-m**2\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E7w - Pg 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.7w\n", + "#calculation of the position of second kid on a balanced seesaw\n", + "\n", + "#given data\n", + "ma=10.#mass(in kg) of kid A\n", + "mb=15.#mass(in kg) of kid B\n", + "l=5.#length(in m) of the seesaw\n", + "la=(l/2.)#distance of A kid from fulcrum as he is sitting at an end\n", + "\n", + "#calculation\n", + "#taking torque about fulcrum...........(mb*g*x) = (ma*g*)\n", + "x=(ma*la)/mb\n", + "\n", + "print '%s %.2f %s' %(\"the second kid should sit at a distance of\",x,\"m from the centre\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the second kid should sit at a distance of 1.67 m from the centre\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E8w - Pg 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#example 10.8w\n", + "#calculation of the normal force and the frictional force that the floor exerts on the ladder\n", + "\n", + "#given data\n", + "m=10.#mass(in kg) of the ladder\n", + "theta=53.#angle(in degree) made by the ladder against the vertical wall\n", + "g=9.8#gravitational acceleration(in m/s**2) of the earth\n", + "\n", + "#calculation\n", + "#taking horizontal and vertical components\n", + "#N1 = f........................(1)\n", + "#N2 = W........................(2)\n", + "#taking torque about B\n", + "W=m*g\n", + "N2=W#from equation (2)\n", + "f=(W*math.sin(theta)*57.3/2.)/(math.cos(theta)*57.3)#from equation (1)\n", + "\n", + "print '%s %.2f %s' %(\"the normal force that the floor exerts on the ladder is\",N2,\"N\\n\")\n", + "print '%s %.2f %s' %(\"the frictional force that the floor exerts on the ladder is\",f,\"N\\n\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the normal force that the floor exerts on the ladder is 98.00 N\n", + "\n", + "the frictional force that the floor exerts on the ladder is -21.13 N\n", + "\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E9w - Pg 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.9w\n", + "#calculation of the contact force exerted by the floor on each leg of ladder\n", + "\n", + "#given data\n", + "theta=60.#angle(in degree) between the two legs\n", + "m=80.#mass(in kg) of the person\n", + "g=9.8#gravitational acceleration(in m/s**2) of the earth\n", + "\n", + "#calculation\n", + "N=m*g/2.\n", + "T=(N*2.*math.tan(90-theta)*57.3)/1.\n", + "\n", + "print '%s %.2f %s' %(\"the contact force exerted by the floor on each leg of ladder\",N,\"N\\n\")\n", + "print '%s %.2f %s' %(\"the tension in the crossbar is\",T,\"N\\n\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the contact force exerted by the floor on each leg of ladder 392.00 N\n", + "\n", + "the tension in the crossbar is -287747.97 N\n", + "\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E12 - Pg 36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.12\n", + "#calculation of the kinetic energy of the sphere\n", + "\n", + "#given data\n", + "M=200.*10.**-3.#mass(in kg) of the sphere\n", + "vcm=2.*10.**-2.#speed(in m/s) of the sphere\n", + "\n", + "#calculation\n", + "#kinetic energy is K = (Icm*w*w/2) + (M*vcm*vcm/2)\n", + "#taking Icm = (2*M*r*r*w*w/5) and w=vcm/r\n", + "K=(M*vcm*vcm/5.)+(M*vcm*vcm/2.)#kinetic energy\n", + "\n", + "print '%s %.5f %s' %(\"the kinetic energy of the sphere is\",K,\"J\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the kinetic energy of the sphere is 0.00006 J\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E13w - Pg 37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.13w\n", + "#calculation of the kinetic energy and angular momentum of the disc\n", + "\n", + "#given data\n", + "M=200.*10.**-3.#mass(in kg) of the disc\n", + "r=4.*10.**-2.#radius(in m) of the disc\n", + "w=10.#angular velocity(in rad/s) \n", + "\n", + "#calculation\n", + "I=(M*r*r)/4.#moment of inertia\n", + "K=(I*w*w/2.)#kinetic energy\n", + "L=I*w#angular momentum\n", + "\n", + "print '%s %.2f %s' %(\"the kinetic energy of the disc is\",K,\"J\")\n", + "print '%s %.2f %s' %(\"\\nthe angular momentum of the disc is\",L,\"J-s\\n\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the kinetic energy of the disc is 0.00 J\n", + "\n", + "the angular momentum of the disc is 0.00 J-s\n", + "\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E14w - Pg 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#example 10.14w\n", + "#calculation of the work done by the torque in first two seconds\n", + "#given data\n", + "wzero=20.#initial angular velocity(in rad/s) of the motor\n", + "w=0#final angular velocity(in rad/s) of the motor\n", + "t=4.#time(in s) taken to attain rest position\n", + "I=.20#moment of inertia(in kg-m**2) of the disc about axis of rotation\n", + "t1=2.#time(in s)\n", + "\n", + "#calculation\n", + "alpha=(wzero-w)/t#equation of angular motion in case of deceleration\n", + "tau=I*alpha#torque\n", + "theta=(wzero*t1)-(alpha*t1*t1/2)#equation of angular motion\n", + "W=tau*theta#work done by the torque\n", + "\n", + "print '%s %.2f %s' %(\"the work done by the torque in first two seconds is\",W,\"J\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the work done by the torque in first two seconds is 30.00 J\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E19w - Pg 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#example 10.19w\n", + "#calculation of the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point\n", + "\n", + "#given data\n", + "m=1.2#mass(in kg) of the sphere\n", + "R=10.*10.**-2.#radius(in cm) of the sphere\n", + "sep=50.*10.**-2.#separation(in m) between the two spheres\n", + "\n", + "#calculation\n", + "d=sep/2.#distance of each sphere from centre\n", + "Icm=(2.*m*R*R)/5.#moment of inertia about diameter\n", + "I=Icm+(m*d*d)#by parallel axis theorem,moment of inertia about given axis \n", + "#since second sphere has same moment of inertia\n", + "Isys=2.*I#moment of inertia of the system\n", + "\n", + "print '%s %.2f %s' %(\"the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point is\",Isys,\"kg-m**2\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the moment of inertia of the system about the axis perpendicular to the rod passing through its middle point is 0.16 kg-m**2\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E22w - Pg 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#example 10.22w\n", + "#calculation of the number of revolutions made by the wheel per second\n", + "\n", + "#given data\n", + "p=220.*10.**-2.#perimeter(in cm) of the wheel\n", + "v=9.*10.**3./(60.*60.)#linear speed(in m/s) of wheel on the road\n", + "\n", + "#calculation\n", + "r=p/(2.*math.pi)#radius of the wheel\n", + "w=v/r#angular speed\n", + "n=w/(2.*math.pi)#number of revolutions\n", + "\n", + "print '%s %.2f %s' %(\"the number of revolutions made by the wheel per second is\",n,\"rev/s\\n\")\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the number of revolutions made by the wheel per second is 1.14 rev/s\n", + "\n" + ] + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/KARTHIKEYAN S/CHAPTER_1.ipynb b/sample_notebooks/KARTHIKEYAN S/CHAPTER_1.ipynb deleted file mode 100755 index 8f5d99cb..00000000 --- a/sample_notebooks/KARTHIKEYAN S/CHAPTER_1.ipynb +++ /dev/null @@ -1,104 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# CHAPTER 1:Fundmentals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## EXAMPLE 1.1,PAGE NUMBER:3" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Carnot COP= 6.0 (error)\n" - ] - } - ], - "source": [ - "\n", - "import math\n", - "\n", - "#Variable Declaration\n", - "T_0=-5+273;\n", - "T_1=35+273;\n", - "\n", - "#Calculation\n", - "COP=(T_0)/(T_1-T_0);# Coefficient of performance\n", - "print \"Carnot COP=\",round(COP,2),\"(error)\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## EXAMPLE 1.2,PAGE NUMBER:4" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The average specific heat capacity is 4.186 kJ/(kg K)\n" - ] - } - ], - "source": [ - "\n", - "import math\n", - "\n", - "#Variable Declaration\n", - "T_f=80;# Final Temperature in °C\n", - "T_i=0;# Initial Temperature in °C\n", - "h_f=334.91;#The specific enthalpy of water in kJ/kg\n", - "\n", - "#Calculation\n", - "C=h_f/(T_f-T_i);# The average specifi c heat capacity in kJ/(kg K)\n", - "print \"The average specific heat capacity is\",round(C,3),\"kJ/(kg K)\"\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/KARTHIKEYAN S/KARTHIKEYAN S_version_backup/CHAPTER_1.ipynb b/sample_notebooks/KARTHIKEYAN S/KARTHIKEYAN S_version_backup/CHAPTER_1.ipynb new file mode 100755 index 00000000..8f5d99cb --- /dev/null +++ b/sample_notebooks/KARTHIKEYAN S/KARTHIKEYAN S_version_backup/CHAPTER_1.ipynb @@ -0,0 +1,104 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# CHAPTER 1:Fundmentals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## EXAMPLE 1.1,PAGE NUMBER:3" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Carnot COP= 6.0 (error)\n" + ] + } + ], + "source": [ + "\n", + "import math\n", + "\n", + "#Variable Declaration\n", + "T_0=-5+273;\n", + "T_1=35+273;\n", + "\n", + "#Calculation\n", + "COP=(T_0)/(T_1-T_0);# Coefficient of performance\n", + "print \"Carnot COP=\",round(COP,2),\"(error)\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## EXAMPLE 1.2,PAGE NUMBER:4" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The average specific heat capacity is 4.186 kJ/(kg K)\n" + ] + } + ], + "source": [ + "\n", + "import math\n", + "\n", + "#Variable Declaration\n", + "T_f=80;# Final Temperature in °C\n", + "T_i=0;# Initial Temperature in °C\n", + "h_f=334.91;#The specific enthalpy of water in kJ/kg\n", + "\n", + "#Calculation\n", + "C=h_f/(T_f-T_i);# The average specifi c heat capacity in kJ/(kg K)\n", + "print \"The average specific heat capacity is\",round(C,3),\"kJ/(kg K)\"\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/KAVANA B/CHAPTER.ipynb b/sample_notebooks/KAVANA B/CHAPTER.ipynb deleted file mode 100755 index 13237c6c..00000000 --- a/sample_notebooks/KAVANA B/CHAPTER.ipynb +++ /dev/null @@ -1,175 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 2: THERMAL STATIONS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1, Page number 25-26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "M = 15000.0+10.0 #Water evaporated(kg)\n", - "C = 5000.0+5.0 #Coal consumption(kg)\n", - "time = 8.0 #Generation shift time(hours)\n", - "\n", - "#Calculation\n", - "#Case(a)\n", - "M1 = M-15000.0\n", - "C1 = C-5000.0\n", - "M_C = M1/C1\n", - "#Case(b)\n", - "kWh = 0 #Station output at no load\n", - "consumption_noload = 5000+5*kWh #Coal consumption at no load(kg)\n", - "consumption_noload_hr = consumption_noload/time #Coal consumption per hour(kg)\n", - "\n", - "#Result\n", - "print('Case(a): Limiting value of water evaporation , M/C = %.1f kg' %M_C)\n", - "print('Case(b): Coal per hour for running station at no load = %.f kg' %consumption_noload_hr)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Case(a): Limiting value of water evaporation , M/C = 2.0 kg\n", - "Case(b): Coal per hour for running station at no load = 625 kg\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2, Page number 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "amount = 25.0*10**5 #Amount spent in 1 year(Rs)\n", - "value_heat = 5000.0 #Heating value(kcal/kg)\n", - "cost = 500.0 #Cost of coal per ton(Rs)\n", - "n_ther = 0.35 #Thermal efficiency\n", - "n_elec = 0.9 #Electrical efficiency\n", - "\n", - "#Calculation\n", - "n = n_ther*n_elec #Overall efficiency\n", - "consumption = amount+cost*value_heat #Coal consumption i 1 year(kg)\n", - "combustion = consumption*value_heat #Heat of combustion(kcal)\n", - "output = n*combustion #Heat output(kcal)\n", - "kWh = output/860.0 #Annual heat generated(kWh). 1 kWh = 860 kcal\n", - "time = 365*24.0 #Total time in a year(hour)\n", - "load_average = kWh/time #Average load on the power plant(kW)\n", - "\n", - "#Result\n", - "print('Average load on power plant = %.2f kW' %load_average)\n", - "print('\\nNOTE: ERROR: Calculation mistake in the final answer in textbook')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Average load on power plant = 1045.32 kW\n", - "\n", - "NOTE: ERROR: Calculation mistake in the final answer in textbook\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3, Page number 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "consumption = 0.5 #Coal consumption per kWh output(kg)\n", - "cal_value = 5000.0 #Calorific value(kcal/kg)\n", - "n_boiler = 0.8 #Boiler efficiency\n", - "n_elec = 0.9 #Electrical efficiency\n", - "\n", - "#Calculation\n", - "input_heat = consumption*cal_value #Heat input(kcal)\n", - "input_elec = input_heat/860.0 #Equivalent electrical energy(kWh). 1 kWh = 860 kcal\n", - "loss_boiler = input_elec*(1-n_boiler) #Boiler loss(kWh)\n", - "input_steam = input_elec-loss_boiler #Heat input to steam(kWh)\n", - "input_alter = 1/n_elec #Alternator input(kWh)\n", - "loss_alter = input_alter*(1-n_elec) #Alternate loss(kWh)\n", - "loss_turbine = input_steam-input_alter #Loss in turbine(kWh)\n", - "loss_total = loss_boiler+loss_alter+loss_turbine #Total loss(kWh)\n", - "output = 1.0 #Output(kWh)\n", - "Input = output+loss_total #Input(kWh)\n", - "\n", - "#Result\n", - "print('Heat Balance Sheet')\n", - "print('LOSSES: Boiler loss = %.3f kWh' %loss_boiler)\n", - "print(' Alternator loss = %.2f kWh' %loss_alter)\n", - "print(' Turbine loss = %.3f kWh' %loss_turbine)\n", - "print(' Total loss = %.2f kWh' %loss_total)\n", - "print('OUTPUT: %.1f kWh' %output)\n", - "print('INPUT: %.2f kWh' %Input)\n", - "print('\\nNOTE: Changes in the obtained answer from that of textbook is due to precision')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Heat Balance Sheet\n", - "LOSSES: Boiler loss = 0.581 kWh\n", - " Alternator loss = 0.11 kWh\n", - " Turbine loss = 1.214 kWh\n", - " Total loss = 1.91 kWh\n", - "OUTPUT: 1.0 kWh\n", - "INPUT: 2.91 kWh\n", - "\n", - "NOTE: Changes in the obtained answer from that of textbook is due to precision\n" - ] - } - ], - "prompt_number": 1 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/KAVANA B/KAVANA B_version_backup/CHAPTER.ipynb b/sample_notebooks/KAVANA B/KAVANA B_version_backup/CHAPTER.ipynb new file mode 100755 index 00000000..13237c6c --- /dev/null +++ b/sample_notebooks/KAVANA B/KAVANA B_version_backup/CHAPTER.ipynb @@ -0,0 +1,175 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 2: THERMAL STATIONS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1, Page number 25-26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "M = 15000.0+10.0 #Water evaporated(kg)\n", + "C = 5000.0+5.0 #Coal consumption(kg)\n", + "time = 8.0 #Generation shift time(hours)\n", + "\n", + "#Calculation\n", + "#Case(a)\n", + "M1 = M-15000.0\n", + "C1 = C-5000.0\n", + "M_C = M1/C1\n", + "#Case(b)\n", + "kWh = 0 #Station output at no load\n", + "consumption_noload = 5000+5*kWh #Coal consumption at no load(kg)\n", + "consumption_noload_hr = consumption_noload/time #Coal consumption per hour(kg)\n", + "\n", + "#Result\n", + "print('Case(a): Limiting value of water evaporation , M/C = %.1f kg' %M_C)\n", + "print('Case(b): Coal per hour for running station at no load = %.f kg' %consumption_noload_hr)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Case(a): Limiting value of water evaporation , M/C = 2.0 kg\n", + "Case(b): Coal per hour for running station at no load = 625 kg\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2, Page number 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "amount = 25.0*10**5 #Amount spent in 1 year(Rs)\n", + "value_heat = 5000.0 #Heating value(kcal/kg)\n", + "cost = 500.0 #Cost of coal per ton(Rs)\n", + "n_ther = 0.35 #Thermal efficiency\n", + "n_elec = 0.9 #Electrical efficiency\n", + "\n", + "#Calculation\n", + "n = n_ther*n_elec #Overall efficiency\n", + "consumption = amount+cost*value_heat #Coal consumption i 1 year(kg)\n", + "combustion = consumption*value_heat #Heat of combustion(kcal)\n", + "output = n*combustion #Heat output(kcal)\n", + "kWh = output/860.0 #Annual heat generated(kWh). 1 kWh = 860 kcal\n", + "time = 365*24.0 #Total time in a year(hour)\n", + "load_average = kWh/time #Average load on the power plant(kW)\n", + "\n", + "#Result\n", + "print('Average load on power plant = %.2f kW' %load_average)\n", + "print('\\nNOTE: ERROR: Calculation mistake in the final answer in textbook')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average load on power plant = 1045.32 kW\n", + "\n", + "NOTE: ERROR: Calculation mistake in the final answer in textbook\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3, Page number 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "consumption = 0.5 #Coal consumption per kWh output(kg)\n", + "cal_value = 5000.0 #Calorific value(kcal/kg)\n", + "n_boiler = 0.8 #Boiler efficiency\n", + "n_elec = 0.9 #Electrical efficiency\n", + "\n", + "#Calculation\n", + "input_heat = consumption*cal_value #Heat input(kcal)\n", + "input_elec = input_heat/860.0 #Equivalent electrical energy(kWh). 1 kWh = 860 kcal\n", + "loss_boiler = input_elec*(1-n_boiler) #Boiler loss(kWh)\n", + "input_steam = input_elec-loss_boiler #Heat input to steam(kWh)\n", + "input_alter = 1/n_elec #Alternator input(kWh)\n", + "loss_alter = input_alter*(1-n_elec) #Alternate loss(kWh)\n", + "loss_turbine = input_steam-input_alter #Loss in turbine(kWh)\n", + "loss_total = loss_boiler+loss_alter+loss_turbine #Total loss(kWh)\n", + "output = 1.0 #Output(kWh)\n", + "Input = output+loss_total #Input(kWh)\n", + "\n", + "#Result\n", + "print('Heat Balance Sheet')\n", + "print('LOSSES: Boiler loss = %.3f kWh' %loss_boiler)\n", + "print(' Alternator loss = %.2f kWh' %loss_alter)\n", + "print(' Turbine loss = %.3f kWh' %loss_turbine)\n", + "print(' Total loss = %.2f kWh' %loss_total)\n", + "print('OUTPUT: %.1f kWh' %output)\n", + "print('INPUT: %.2f kWh' %Input)\n", + "print('\\nNOTE: Changes in the obtained answer from that of textbook is due to precision')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Heat Balance Sheet\n", + "LOSSES: Boiler loss = 0.581 kWh\n", + " Alternator loss = 0.11 kWh\n", + " Turbine loss = 1.214 kWh\n", + " Total loss = 1.91 kWh\n", + "OUTPUT: 1.0 kWh\n", + "INPUT: 2.91 kWh\n", + "\n", + "NOTE: Changes in the obtained answer from that of textbook is due to precision\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction.ipynb b/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction.ipynb new file mode 100755 index 00000000..5415ad01 --- /dev/null +++ b/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction.ipynb @@ -0,0 +1,345 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:38f9fe4fd8a5c174c9e1dd9b5dc21976f4cdd814f7eb8fcfe0c266e278f9a77b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11 : Impulse and Reaction Turbines" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.1 and Page No:454" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "p02=6; # Inlet pressure in bar\n", + "T02=900; # Inlet temperature in kelvin\n", + "p0fs=1; # Outlet pressure in bar\n", + "eff_isenT=0.85; # insentropic efficiency of turbine\n", + "alpha_2=math.radians(75); # Nozzle outlet angle in degree and conversion to radians\n", + "u=250; # Mean blade velocity in m/s\n", + "Cp=1.15*10**3; # Specific heat in J/ kg K\n", + "r=1.333; # Specific heat ratio\n", + "\n", + "#Calculations\n", + "T0fs=T02/(p02/p0fs)**((r-1)/r); # Isentropic temperature at the exit of the final stage\n", + "Del_Toverall=eff_isenT*(T02-T0fs); # Actual overall temperature drop\n", + "c2=2*u/math.sin (alpha_2); # absolute velocity\n", + "c3= c2*math.cos (alpha_2);# absolute velocity\n", + "c1=c3; # From velocity triangles\n", + "Del_Tstage=(c2**2-c1**2)/(2*Cp); # Stage temperature drop\n", + "n=Del_Toverall/Del_Tstage; # Number of stages\n", + "\n", + "#Results\n", + "print \"Number of stages n =\",round (n,0);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of stages n = 3.0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.2 and Page No:455" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "N=10000; # Speed of gas turbine in rpm\n", + "T01=700+273.15; # Total head temperature at nozzle entry in kelvin\n", + "P01=4.5; #Total head pressure at nozzle entry in bar\n", + "P02=2.6; # Outlet pressure from nozzle in bar\n", + "p3=1.5;# Pressure at trbine outlet annulus in bar\n", + "M=0.5; # Mach number at outlet\n", + "alpha_2=math.radians(70); # outlet nozzle angle in degrees and conversion to radians\n", + "D=64; # Blade mean diameter in cm\n", + "m=22.5; # Mass flow rate in kg/s\n", + "eff_T=0.99; # turbine mechanical efficiency\n", + "Cp=1.147; # Specific heat in kJ/kg K\n", + "r=1.33; # Specific heat ratio\n", + "fl=0.03; # frictional loss\n", + "R=284.6; # characteristic gas constant in J/kg K\n", + "\n", + "#Calculations\n", + "eff_N=1-fl; # Nozzle efficiency\n", + "T_02=(P02/P01)**((r-1)/r)*T01; # Isentropic temperature after expansion\n", + "T02=T01-eff_N*(T01-T_02); # Actual temperature after expansion\n", + "c2=math.sqrt (2*Cp*10**3*(T01-T02)); # Absolute velocity\n", + "u=(3.14*D*10**-2*N)/60; # Mean blade velocity\n", + "# From velocity triangles\n", + "wt2=c2*math.sin( (alpha_2))-u;\n", + "ca=c2*math.cos( (alpha_2));\n", + "beta_2=(math.atan((wt2)/ca));\n", + "T3=T02/(P02/p3)**((r-1)/r); # Assuming rotor losses are negligible\n", + "c3=M*math.sqrt (r*R*T3); # Absolute velocity\n", + "beta_3=(math.atan(u/c3));\n", + "ct2=c2*math.sin((alpha_2));\n", + "P=eff_T*m*(ct2)*u/1000; # Power developed\n", + "\n", + "#Results\n", + "print \"(i).\"\n", + "print \"\\tGas angle at entry = \",round (math.degrees(beta_2),3),\"degree\"\n", + "print \"\\tGas angle at exit = \",round (math.degrees(beta_3),3),\"degree\"\n", + "print \"(ii).\"\n", + "print \"\\tPower developed = \",round(P,3),\"kW (roundoff error)\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i).\n", + "\tGas angle at entry = 41.411 degree\n", + "\tGas angle at exit = 51.609 degree\n", + "(ii).\n", + "\tPower developed = 3680.184 kW (roundoff error)\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.3 and Page No:457" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "alpha_2=math.radians(65); # Nozzle discharge angle in degree and conversion to radians\n", + "c3=300; # Absolute velocity in m/s\n", + "alpha_3=math.radians(30); # in degrees and conversion to radians\n", + "\n", + "#Calculations\n", + "ca2=c3*math.cos (alpha_3); # Axial velocity\n", + "c2=ca2/math.cos(alpha_2); # Absolute velocity\n", + "# ca3=ca2=ca and equal blade angles then\n", + "ca=ca2;\n", + "beta_2=math.atan((c2*math.sin(alpha_2)+c3*math.sin(alpha_3))/(2*ca)); # Blade angle\n", + "beta_3=beta_2; # equal blade angles\n", + "u=c2*math.sin(alpha_2)-ca2*math.tan(beta_2); # Mean blade velocity\n", + "# From velocity triangles\n", + "ct2=c2*math.sin(alpha_2);\n", + "ct3=c3*math.sin(alpha_3);\n", + "WT=u*(ct2+ct3)/1000; # Work done\n", + "sigma=u/c2; # optimum speed ratio\n", + "eff_B=4*(sigma*math.sin(alpha_2)-sigma**2);\n", + "\n", + "#Results\n", + "print \"Blade angle = beta_2= beta_3 = \",round (math.degrees(beta_2),3),\"degree\"\n", + "print \"Power Produced = \",round(WT,3),\"kJ/kg (roundoff error)\"\n", + "print \"Blade efficiency = \",round(eff_B*100,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Blade angle = beta_2= beta_3 = 53.692 degree\n", + "Power Produced = 143.963 kJ/kg (roundoff error)\n", + "Blade efficiency = 76.19 %\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.4 and Page No:458" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "P01=7; # Pressure at inlet in bar\n", + "T01=300+273.15; # Temperature at inlet in kelvin\n", + "P02=3; # Pressure at outlet in bar\n", + "alpha_2=math.radians(70); # Nozzle angle in degree and conversion to radians\n", + "eff_N=0.9; # Isentropic efficiency of nozzle\n", + "WT=75; # Power Produced in kW\n", + "Cp=1.15; # Specific heat in kJ/kg K\n", + "r=1.33; # Specific heat ratio\n", + "\n", + "#Calculations\n", + "T_02=T01*(P02/P01)**((r-1)/r); # Isentropic temperature after expansion\n", + "T02=T01-eff_N*(T01-T_02); # Actual temperature after expansion\n", + "c2=math.sqrt (2*Cp*10**3*(T01-T02)); # Absolute velocity\n", + "# For optimum blade speed ratio\n", + "u=(c2*math.sin (alpha_2)/2); # Mean blade velocity\n", + "beta_2=math.atan((c2*math.sin(alpha_2)-u)/(c2*math.cos(alpha_2))); # Blade angle\n", + "# From velocity triangles\n", + "ct2=c2*math.sin(alpha_2);\n", + "w2=c2*math.cos(alpha_2)/math.cos(beta_2);\n", + "w3=w2; # Equal inlet and outlet angles\n", + "beta_3=54; # in degrees\n", + "ct3=w3*math.sin(beta_3)-u;\n", + "m=(WT*10**3)/(u*(ct2+ct3)); # Gas mass flow rate\n", + "\n", + "#Results\n", + "print \"Blade angle = \",round(math.degrees(beta_2),3),\"degree\"\n", + "print \"Gas Mass Flow Rate = \",round(m,3),\"kg/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Blade angle = 53.948 degree\n", + "Gas Mass Flow Rate = 4.89 kg/s\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.5 and Page No:460" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "P01=4.6; # Total head inlet pressure in bar\n", + "T01=700+273.15; # Total head inlet temperature in kelvin\n", + "P2=1.6; # Static head pressure at mean radius in bar\n", + "Dm_h=10; # Mean blade diameter/blade height\n", + "lc=0.1; # Nozzle losses coefficient\n", + "alpha_2=math.radians(60); # Nozzle outlet angle in degree and conversion to radians\n", + "Cp=1.147; # Specific heat in kJ/kg K\n", + "r=1.33; # Specific heat ratio\n", + "m=20; # Mass flow rate in kg/s\n", + "R=284.6; # characteristic gas constant in J/kg K\n", + "\n", + "#Calculations\n", + "T_2=T01*(P2/P01)**((r-1)/r); # Isentropic temperature after expansion\n", + "T2=(lc*T01+T_2)/(1+lc); # Actual temperature after expansion\n", + "c2=math.sqrt(2*Cp*10**3*(T01-T2)); # Absolute velocity\n", + "# From velocity triangles\n", + "ca=c2*math.cos(alpha_2);\n", + "row=P2*10**5/(R*T2); # Density of gas\n", + "A=m/(ca*row); # Area\n", + "Dm=math.sqrt (A*Dm_h/3.14); # Mean Diameter\n", + "h=Dm/10; # Blade height\n", + "rm=Dm/2; # Mean radius\n", + "# At root\n", + "r_root=(Dm-h)/2;\n", + "#At the tip\n", + "r_tip=(Dm+h)/2;\n", + "# Free vorte flow\n", + "ct_mean=c2*math.sin (alpha_2);\n", + "# At the root\n", + "ct2_root=(ct_mean*rm)/r_root;\n", + "alpha2_root=math.atan(ct2_root/ca);\n", + "c2_root=ct2_root/math.sin (alpha2_root);\n", + "T2_root=T01-c2_root**2/(2*Cp*10**3);\n", + "# At the tip\n", + "ct2_tip=ct_mean*rm/r_tip;\n", + "alpha2_tip = math.atan (ct2_tip/ca);\n", + "c2_tip=ct2_tip/math.sin(alpha2_tip);\n", + "T2_tip=T01-c2_tip**2/(2*Cp*10**3);\n", + "\n", + "#Results\n", + "print \"A the Root\"\n", + "print \"\\tGas Temperature at the root = \",round(T2_root,3),\"K\"\n", + "print \"\\tGas velocity at the root = \",round(c2_root,3),\"m/s\"\n", + "print \"\\tDischarge angle at the root = \",round(math.degrees(alpha2_root),3),\"degree\"\n", + "print \"\\nA the Tip\"\n", + "print \"\\tGas Temperature at the tip = \",round(T2_tip,3),\"K\"\n", + "print \"\\tGas velocity at the tip = \",round(c2_tip,3),\"m/s\"\n", + "print \"\\tDischarge angle at the tip = \",round(math.degrees(alpha2_tip),3),\"degree\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A the Root\n", + "\tGas Temperature at the root = 733.345 K\n", + "\tGas velocity at the root = 741.696 m/s\n", + "\tDischarge angle at the root = 62.543 degree\n", + "\n", + "A the Tip\n", + "\tGas Temperature at the tip = 795.766 K\n", + "\tGas velocity at the tip = 637.902 m/s\n", + "\tDischarge angle at the tip = 57.581 degree\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction_Turbines.ipynb b/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction_Turbines.ipynb deleted file mode 100755 index 5415ad01..00000000 --- a/sample_notebooks/KavinkumarD/Chapter_11__Impulse_and_Reaction_Turbines.ipynb +++ /dev/null @@ -1,345 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:38f9fe4fd8a5c174c9e1dd9b5dc21976f4cdd814f7eb8fcfe0c266e278f9a77b" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11 : Impulse and Reaction Turbines" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.1 and Page No:454" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "p02=6; # Inlet pressure in bar\n", - "T02=900; # Inlet temperature in kelvin\n", - "p0fs=1; # Outlet pressure in bar\n", - "eff_isenT=0.85; # insentropic efficiency of turbine\n", - "alpha_2=math.radians(75); # Nozzle outlet angle in degree and conversion to radians\n", - "u=250; # Mean blade velocity in m/s\n", - "Cp=1.15*10**3; # Specific heat in J/ kg K\n", - "r=1.333; # Specific heat ratio\n", - "\n", - "#Calculations\n", - "T0fs=T02/(p02/p0fs)**((r-1)/r); # Isentropic temperature at the exit of the final stage\n", - "Del_Toverall=eff_isenT*(T02-T0fs); # Actual overall temperature drop\n", - "c2=2*u/math.sin (alpha_2); # absolute velocity\n", - "c3= c2*math.cos (alpha_2);# absolute velocity\n", - "c1=c3; # From velocity triangles\n", - "Del_Tstage=(c2**2-c1**2)/(2*Cp); # Stage temperature drop\n", - "n=Del_Toverall/Del_Tstage; # Number of stages\n", - "\n", - "#Results\n", - "print \"Number of stages n =\",round (n,0);\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Number of stages n = 3.0\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.2 and Page No:455" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "N=10000; # Speed of gas turbine in rpm\n", - "T01=700+273.15; # Total head temperature at nozzle entry in kelvin\n", - "P01=4.5; #Total head pressure at nozzle entry in bar\n", - "P02=2.6; # Outlet pressure from nozzle in bar\n", - "p3=1.5;# Pressure at trbine outlet annulus in bar\n", - "M=0.5; # Mach number at outlet\n", - "alpha_2=math.radians(70); # outlet nozzle angle in degrees and conversion to radians\n", - "D=64; # Blade mean diameter in cm\n", - "m=22.5; # Mass flow rate in kg/s\n", - "eff_T=0.99; # turbine mechanical efficiency\n", - "Cp=1.147; # Specific heat in kJ/kg K\n", - "r=1.33; # Specific heat ratio\n", - "fl=0.03; # frictional loss\n", - "R=284.6; # characteristic gas constant in J/kg K\n", - "\n", - "#Calculations\n", - "eff_N=1-fl; # Nozzle efficiency\n", - "T_02=(P02/P01)**((r-1)/r)*T01; # Isentropic temperature after expansion\n", - "T02=T01-eff_N*(T01-T_02); # Actual temperature after expansion\n", - "c2=math.sqrt (2*Cp*10**3*(T01-T02)); # Absolute velocity\n", - "u=(3.14*D*10**-2*N)/60; # Mean blade velocity\n", - "# From velocity triangles\n", - "wt2=c2*math.sin( (alpha_2))-u;\n", - "ca=c2*math.cos( (alpha_2));\n", - "beta_2=(math.atan((wt2)/ca));\n", - "T3=T02/(P02/p3)**((r-1)/r); # Assuming rotor losses are negligible\n", - "c3=M*math.sqrt (r*R*T3); # Absolute velocity\n", - "beta_3=(math.atan(u/c3));\n", - "ct2=c2*math.sin((alpha_2));\n", - "P=eff_T*m*(ct2)*u/1000; # Power developed\n", - "\n", - "#Results\n", - "print \"(i).\"\n", - "print \"\\tGas angle at entry = \",round (math.degrees(beta_2),3),\"degree\"\n", - "print \"\\tGas angle at exit = \",round (math.degrees(beta_3),3),\"degree\"\n", - "print \"(ii).\"\n", - "print \"\\tPower developed = \",round(P,3),\"kW (roundoff error)\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i).\n", - "\tGas angle at entry = 41.411 degree\n", - "\tGas angle at exit = 51.609 degree\n", - "(ii).\n", - "\tPower developed = 3680.184 kW (roundoff error)\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.3 and Page No:457" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "alpha_2=math.radians(65); # Nozzle discharge angle in degree and conversion to radians\n", - "c3=300; # Absolute velocity in m/s\n", - "alpha_3=math.radians(30); # in degrees and conversion to radians\n", - "\n", - "#Calculations\n", - "ca2=c3*math.cos (alpha_3); # Axial velocity\n", - "c2=ca2/math.cos(alpha_2); # Absolute velocity\n", - "# ca3=ca2=ca and equal blade angles then\n", - "ca=ca2;\n", - "beta_2=math.atan((c2*math.sin(alpha_2)+c3*math.sin(alpha_3))/(2*ca)); # Blade angle\n", - "beta_3=beta_2; # equal blade angles\n", - "u=c2*math.sin(alpha_2)-ca2*math.tan(beta_2); # Mean blade velocity\n", - "# From velocity triangles\n", - "ct2=c2*math.sin(alpha_2);\n", - "ct3=c3*math.sin(alpha_3);\n", - "WT=u*(ct2+ct3)/1000; # Work done\n", - "sigma=u/c2; # optimum speed ratio\n", - "eff_B=4*(sigma*math.sin(alpha_2)-sigma**2);\n", - "\n", - "#Results\n", - "print \"Blade angle = beta_2= beta_3 = \",round (math.degrees(beta_2),3),\"degree\"\n", - "print \"Power Produced = \",round(WT,3),\"kJ/kg (roundoff error)\"\n", - "print \"Blade efficiency = \",round(eff_B*100,2),\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Blade angle = beta_2= beta_3 = 53.692 degree\n", - "Power Produced = 143.963 kJ/kg (roundoff error)\n", - "Blade efficiency = 76.19 %\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.4 and Page No:458" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "P01=7; # Pressure at inlet in bar\n", - "T01=300+273.15; # Temperature at inlet in kelvin\n", - "P02=3; # Pressure at outlet in bar\n", - "alpha_2=math.radians(70); # Nozzle angle in degree and conversion to radians\n", - "eff_N=0.9; # Isentropic efficiency of nozzle\n", - "WT=75; # Power Produced in kW\n", - "Cp=1.15; # Specific heat in kJ/kg K\n", - "r=1.33; # Specific heat ratio\n", - "\n", - "#Calculations\n", - "T_02=T01*(P02/P01)**((r-1)/r); # Isentropic temperature after expansion\n", - "T02=T01-eff_N*(T01-T_02); # Actual temperature after expansion\n", - "c2=math.sqrt (2*Cp*10**3*(T01-T02)); # Absolute velocity\n", - "# For optimum blade speed ratio\n", - "u=(c2*math.sin (alpha_2)/2); # Mean blade velocity\n", - "beta_2=math.atan((c2*math.sin(alpha_2)-u)/(c2*math.cos(alpha_2))); # Blade angle\n", - "# From velocity triangles\n", - "ct2=c2*math.sin(alpha_2);\n", - "w2=c2*math.cos(alpha_2)/math.cos(beta_2);\n", - "w3=w2; # Equal inlet and outlet angles\n", - "beta_3=54; # in degrees\n", - "ct3=w3*math.sin(beta_3)-u;\n", - "m=(WT*10**3)/(u*(ct2+ct3)); # Gas mass flow rate\n", - "\n", - "#Results\n", - "print \"Blade angle = \",round(math.degrees(beta_2),3),\"degree\"\n", - "print \"Gas Mass Flow Rate = \",round(m,3),\"kg/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Blade angle = 53.948 degree\n", - "Gas Mass Flow Rate = 4.89 kg/s\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.5 and Page No:460" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "P01=4.6; # Total head inlet pressure in bar\n", - "T01=700+273.15; # Total head inlet temperature in kelvin\n", - "P2=1.6; # Static head pressure at mean radius in bar\n", - "Dm_h=10; # Mean blade diameter/blade height\n", - "lc=0.1; # Nozzle losses coefficient\n", - "alpha_2=math.radians(60); # Nozzle outlet angle in degree and conversion to radians\n", - "Cp=1.147; # Specific heat in kJ/kg K\n", - "r=1.33; # Specific heat ratio\n", - "m=20; # Mass flow rate in kg/s\n", - "R=284.6; # characteristic gas constant in J/kg K\n", - "\n", - "#Calculations\n", - "T_2=T01*(P2/P01)**((r-1)/r); # Isentropic temperature after expansion\n", - "T2=(lc*T01+T_2)/(1+lc); # Actual temperature after expansion\n", - "c2=math.sqrt(2*Cp*10**3*(T01-T2)); # Absolute velocity\n", - "# From velocity triangles\n", - "ca=c2*math.cos(alpha_2);\n", - "row=P2*10**5/(R*T2); # Density of gas\n", - "A=m/(ca*row); # Area\n", - "Dm=math.sqrt (A*Dm_h/3.14); # Mean Diameter\n", - "h=Dm/10; # Blade height\n", - "rm=Dm/2; # Mean radius\n", - "# At root\n", - "r_root=(Dm-h)/2;\n", - "#At the tip\n", - "r_tip=(Dm+h)/2;\n", - "# Free vorte flow\n", - "ct_mean=c2*math.sin (alpha_2);\n", - "# At the root\n", - "ct2_root=(ct_mean*rm)/r_root;\n", - "alpha2_root=math.atan(ct2_root/ca);\n", - "c2_root=ct2_root/math.sin (alpha2_root);\n", - "T2_root=T01-c2_root**2/(2*Cp*10**3);\n", - "# At the tip\n", - "ct2_tip=ct_mean*rm/r_tip;\n", - "alpha2_tip = math.atan (ct2_tip/ca);\n", - "c2_tip=ct2_tip/math.sin(alpha2_tip);\n", - "T2_tip=T01-c2_tip**2/(2*Cp*10**3);\n", - "\n", - "#Results\n", - "print \"A the Root\"\n", - "print \"\\tGas Temperature at the root = \",round(T2_root,3),\"K\"\n", - "print \"\\tGas velocity at the root = \",round(c2_root,3),\"m/s\"\n", - "print \"\\tDischarge angle at the root = \",round(math.degrees(alpha2_root),3),\"degree\"\n", - "print \"\\nA the Tip\"\n", - "print \"\\tGas Temperature at the tip = \",round(T2_tip,3),\"K\"\n", - "print \"\\tGas velocity at the tip = \",round(c2_tip,3),\"m/s\"\n", - "print \"\\tDischarge angle at the tip = \",round(math.degrees(alpha2_tip),3),\"degree\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "A the Root\n", - "\tGas Temperature at the root = 733.345 K\n", - "\tGas velocity at the root = 741.696 m/s\n", - "\tDischarge angle at the root = 62.543 degree\n", - "\n", - "A the Tip\n", - "\tGas Temperature at the tip = 795.766 K\n", - "\tGas velocity at the tip = 637.902 m/s\n", - "\tDischarge angle at the tip = 57.581 degree\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/KavinkumarD/Chapter_8_FREQUENCY_EFFECTS_IN_AMPLIFIERS.ipynb b/sample_notebooks/KavinkumarD/Chapter_8_FREQUENCY_EFFECTS_IN_AMPLIFIERS.ipynb deleted file mode 100755 index 60448e3c..00000000 --- a/sample_notebooks/KavinkumarD/Chapter_8_FREQUENCY_EFFECTS_IN_AMPLIFIERS.ipynb +++ /dev/null @@ -1,120 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:8ef023228932ba7c44f0f72b79793f31a32f8ea67eae875510cf71ee015fc22c" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8 FREQUENCY EFFECTS IN AMPLIFIERS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 8.6 , Page no:242" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "hie=1000 #\u2126\n", - "hfe=75 #\u2126\n", - "Av=50\n", - "Rl=10000 #k\u2126\n", - "hie2=300 #\u2126\n", - "hfe2=100 #\u2126\n", - "Re=1000 #k\u2126\n", - "\n", - "#CALCULATIONS\n", - "Req=Av*(hie/hfe) #\u2126\n", - "Rc=Req*Rl/(Rl-Req) #k\u2126\n", - "wL=2*3.14*200\n", - "Ce=(hie2+(hfe2+1)*Re)/(wL*Re*hie2)*10**6\n", - "Av1=(hfe*Req)/(hie+(hfe+1)*Re)\n", - "\n", - "#RESULTS\n", - "print\"The value of Req=\",round(Req,3),\"Ohm\";\n", - "print\"The value of Rc=\",round(Rc,3),\"Ohm\";\n", - "print\"The value of Ce=\",round(Ce,3),\"mF\";\n", - "print\"The value of Av=\",round(Av1,3);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of Req= 666.667 Ohm\n", - "The value of Rc= 714.286 Ohm\n", - "The value of Ce= 268.843 mF\n", - "The value of Av= 0.649\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 8.8 , Page no:244" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "hie2=1500 #\u2126\n", - "Rb2=5000 #k\u2126\n", - "Z01=10\n", - "Av=7881.3\n", - "\n", - "#CALCULATIONS\n", - "C2=1*10**-6 \n", - "Zin2=(hie2*Rb2/(hie2+Rb2))\n", - "fl=1/(2*3.14*C2*(Zin2+Z01*10**3))\n", - "\n", - "#RESULTS\n", - "print\"The value of Zin2=\",round(Zin2,3),\"Ohm\";\n", - "print\"The value of fl=\",round(fl,3),\"Hz\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of Zin2= 1153.846 Ohm\n", - "The value of fl= 14.276 Hz\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/KavinkumarD/KavinkumarD_version_backup/Chapter_8_FREQUENCY_EFFECTS_IN.ipynb b/sample_notebooks/KavinkumarD/KavinkumarD_version_backup/Chapter_8_FREQUENCY_EFFECTS_IN.ipynb new file mode 100755 index 00000000..60448e3c --- /dev/null +++ b/sample_notebooks/KavinkumarD/KavinkumarD_version_backup/Chapter_8_FREQUENCY_EFFECTS_IN.ipynb @@ -0,0 +1,120 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:8ef023228932ba7c44f0f72b79793f31a32f8ea67eae875510cf71ee015fc22c" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8 FREQUENCY EFFECTS IN AMPLIFIERS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.6 , Page no:242" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "hie=1000 #\u2126\n", + "hfe=75 #\u2126\n", + "Av=50\n", + "Rl=10000 #k\u2126\n", + "hie2=300 #\u2126\n", + "hfe2=100 #\u2126\n", + "Re=1000 #k\u2126\n", + "\n", + "#CALCULATIONS\n", + "Req=Av*(hie/hfe) #\u2126\n", + "Rc=Req*Rl/(Rl-Req) #k\u2126\n", + "wL=2*3.14*200\n", + "Ce=(hie2+(hfe2+1)*Re)/(wL*Re*hie2)*10**6\n", + "Av1=(hfe*Req)/(hie+(hfe+1)*Re)\n", + "\n", + "#RESULTS\n", + "print\"The value of Req=\",round(Req,3),\"Ohm\";\n", + "print\"The value of Rc=\",round(Rc,3),\"Ohm\";\n", + "print\"The value of Ce=\",round(Ce,3),\"mF\";\n", + "print\"The value of Av=\",round(Av1,3);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of Req= 666.667 Ohm\n", + "The value of Rc= 714.286 Ohm\n", + "The value of Ce= 268.843 mF\n", + "The value of Av= 0.649\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 8.8 , Page no:244" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "hie2=1500 #\u2126\n", + "Rb2=5000 #k\u2126\n", + "Z01=10\n", + "Av=7881.3\n", + "\n", + "#CALCULATIONS\n", + "C2=1*10**-6 \n", + "Zin2=(hie2*Rb2/(hie2+Rb2))\n", + "fl=1/(2*3.14*C2*(Zin2+Z01*10**3))\n", + "\n", + "#RESULTS\n", + "print\"The value of Zin2=\",round(Zin2,3),\"Ohm\";\n", + "print\"The value of fl=\",round(fl,3),\"Hz\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of Zin2= 1153.846 Ohm\n", + "The value of fl= 14.276 Hz\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/KhushbuPattani/KhushbuPattani_version_backup/chapter1.ipynb b/sample_notebooks/KhushbuPattani/KhushbuPattani_version_backup/chapter1.ipynb new file mode 100755 index 00000000..f014e773 --- /dev/null +++ b/sample_notebooks/KhushbuPattani/KhushbuPattani_version_backup/chapter1.ipynb @@ -0,0 +1,53 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Solution of Equation & Curve Fitting" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1, page no. 12" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import numpy\n", + "\n", + "p = 2*(x^3)+x^2-13*x+6\n", + "print \"The roots of above equation are: \", numpy.roots([2,1,-13,6])" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/KhushbuPattani/chapter1.ipynb b/sample_notebooks/KhushbuPattani/chapter1.ipynb deleted file mode 100755 index f014e773..00000000 --- a/sample_notebooks/KhushbuPattani/chapter1.ipynb +++ /dev/null @@ -1,53 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Solution of Equation & Curve Fitting" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1, page no. 12" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "import numpy\n", - "\n", - "p = 2*(x^3)+x^2-13*x+6\n", - "print \"The roots of above equation are: \", numpy.roots([2,1,-13,6])" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/KonasaniSai Dheeraj/sample(chapter.ipynb b/sample_notebooks/KonasaniSai Dheeraj/sample(chapter.ipynb new file mode 100755 index 00000000..cbbd7757 --- /dev/null +++ b/sample_notebooks/KonasaniSai Dheeraj/sample(chapter.ipynb @@ -0,0 +1,236 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 Survey of Units and Dimensions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_1 pgno:10" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Force to accelerate = lbf 3.10810936815\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "gc=32.1739 #lbm ft/lbf s**2\n", + "m=10 #lbm\n", + "a=10 #ft/s**2\n", + "#calculations\n", + "F=m*a/gc\n", + "#results\n", + "print\"Force to accelerate = lbf\",F\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_2 pgno:11" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Force to accelerate = lbf 10.0\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "gc=32.1739 #lbm ft/lbf s^2\n", + "m=10 #lbm\n", + "a=gc #ft/s^2\n", + "#calculations\n", + "F=m*a/gc\n", + "#results\n", + "print\"Force to accelerate = lbf\",F\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_3 pgno:11" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "velocity = mph 60.0\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "v=88 #ft/s\n", + "#calculations\n", + "v2=v*3600./5280.\n", + "#results\n", + "print\"velocity = mph\",v2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_4 pgno:12" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "velocity = mph 60.0\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "v=88 #ft/s\n", + "#calculations\n", + "v2=v*1./5280*3600\n", + "#results\n", + "print\"velocity = mph\",v2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_5 pgno:13" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Force without dimensions = lbm/ft sec 0.0005791302\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "F=5e-9 #lbf/ft^2 hr\n", + "g=32.1739\n", + "#calculations\n", + "F2=F*3600*g\n", + "#results\n", + "print\"Force without dimensions = lbm/ft sec\",F2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1_6 pgno:14" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Density of water in this system = lbf/ft^2 1.93650754183\n", + "\n", + " Specific weight = lbf/ft^2 62.305\n" + ] + } + ], + "source": [ + "#Initialization of variables\n", + "rho=62.305 #lbf/ft^2\n", + "g=32.1739 #ft/s^2\n", + "#calculations\n", + "gam=rho/g\n", + "#results\n", + "print\"Density of water in this system = lbf/ft^2\",gam\n", + "print\"\\n Specific weight = lbf/ft^2\",rho\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/KonasaniSai Dheeraj/sample(chapter_1).ipynb b/sample_notebooks/KonasaniSai Dheeraj/sample(chapter_1).ipynb deleted file mode 100755 index cbbd7757..00000000 --- a/sample_notebooks/KonasaniSai Dheeraj/sample(chapter_1).ipynb +++ /dev/null @@ -1,236 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 Survey of Units and Dimensions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_1 pgno:10" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Force to accelerate = lbf 3.10810936815\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "gc=32.1739 #lbm ft/lbf s**2\n", - "m=10 #lbm\n", - "a=10 #ft/s**2\n", - "#calculations\n", - "F=m*a/gc\n", - "#results\n", - "print\"Force to accelerate = lbf\",F\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_2 pgno:11" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Force to accelerate = lbf 10.0\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "gc=32.1739 #lbm ft/lbf s^2\n", - "m=10 #lbm\n", - "a=gc #ft/s^2\n", - "#calculations\n", - "F=m*a/gc\n", - "#results\n", - "print\"Force to accelerate = lbf\",F\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_3 pgno:11" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "velocity = mph 60.0\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "v=88 #ft/s\n", - "#calculations\n", - "v2=v*3600./5280.\n", - "#results\n", - "print\"velocity = mph\",v2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_4 pgno:12" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "velocity = mph 60.0\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "v=88 #ft/s\n", - "#calculations\n", - "v2=v*1./5280*3600\n", - "#results\n", - "print\"velocity = mph\",v2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_5 pgno:13" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Force without dimensions = lbm/ft sec 0.0005791302\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "F=5e-9 #lbf/ft^2 hr\n", - "g=32.1739\n", - "#calculations\n", - "F2=F*3600*g\n", - "#results\n", - "print\"Force without dimensions = lbm/ft sec\",F2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1_6 pgno:14" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Density of water in this system = lbf/ft^2 1.93650754183\n", - "\n", - " Specific weight = lbf/ft^2 62.305\n" - ] - } - ], - "source": [ - "#Initialization of variables\n", - "rho=62.305 #lbf/ft^2\n", - "g=32.1739 #ft/s^2\n", - "#calculations\n", - "gam=rho/g\n", - "#results\n", - "print\"Density of water in this system = lbf/ft^2\",gam\n", - "print\"\\n Specific weight = lbf/ft^2\",rho\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb b/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb new file mode 100755 index 00000000..58372eed --- /dev/null +++ b/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter.ipynb @@ -0,0 +1,256 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6 : FORMULAE" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6_1 pgno:69" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "expr=8*i-5\n", + "the number is 16\n" + ] + } + ], + "source": [ + " #8 times a number is decreased by 5 the result is 123\n", + "#let x be the number\n", + "\n", + "print'expr=8*i-5'\n", + "x=0;\n", + "for x in range(0,100):\n", + " if((8*x-5)==123):\n", + " print\"the number is \",x\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6_2 pgno:71" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "expr=(2*n+1)+(2*n+3)+(2*n+5)\n", + "n=%i \n", + "12\n", + "\n", + " the numbers are 199 201 203\n" + ] + } + ], + "source": [ + "#sum of 3 consecutive odd no.'s is 81\n", + "\n", + "#let the 3 consecutive odd numbers be 2n+1,2n+3,2n+5\n", + "\n", + "print\"expr=(2*n+1)+(2*n+3)+(2*n+5)\"\n", + "n=0;\n", + "for n in range(0,100):\n", + " if((2*n+1)+(2*n+3)+(2*n+5)==81):\n", + " print\"n=%i \\n\",n \n", + "\n", + "n1=2*n+1;\n", + "n2=2*n+3;\n", + "n3=2*n+5;\n", + "print\"\\n the numbers are \",n1,n2,n3\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6_3 pgno:72" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "p1=(6*x-5)\n", + "p2=(2*x+9)\n", + "p3=p1-p2\n", + "satisfies the equation \n" + ] + } + ], + "source": [ + "import numpy\n", + "print\"p1=(6*x-5)\"\n", + "p1=numpy.array([6, -5])\n", + "print\"p2=(2*x+9)\"\n", + "p2=numpy.array([2, 9])\n", + "print\"p3=p1-p2\"\n", + "p3=p1-p2\n", + "\n", + "x1=numpy.roots(p3)\n", + "left=6*x1-5; #check by substituion \n", + "right=2*x1+9;\n", + "if(left==right):\n", + "\tprint'satisfies the equation '\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6_4 pgno:73" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x is a polynomial function\n", + "by the law of sighs roots are [ 3.]\n" + ] + } + ], + "source": [ + "print\"x is a polynomial function\"\n", + "import numpy\n", + "p1=numpy.array([3/5+1/2, 0])\n", + "p2=numpy.array([5/4, -3])\n", + "#p1=3*x/5+x/2;\n", + "#p2=5*x/4-3;\n", + "p3=p1-p2;\n", + "x=numpy.roots(p3) #by the law of signs\n", + "print\"by the law of sighs roots are\",x\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 6_5 pgno:75" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "p1=4*x-(x-2)/3\n", + "p2=5+(2*x+1)/4\n", + "p3=p1-p2\n", + "satisfies the equation \n" + ] + } + ], + "source": [ + "import numpy\n", + "print\"p1=4*x-(x-2)/3\"\n", + "p1=numpy.array([11/3, 2/3])\n", + "print\"p2=5+(2*x+1)/4\"\n", + "p2=numpy.array([1/2, 21/4])\n", + "print\"p3=p1-p2\"\n", + "p3=p1-p2\n", + "\n", + "x=numpy.roots(p3)\n", + "left=4*x-(x-2)/3; #check by substituion \n", + "right=5+(2*x+1)/4;\n", + "if(left != right):\n", + "\tprint'satisfies the equation '\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter_6).ipynb b/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter_6).ipynb deleted file mode 100755 index 58372eed..00000000 --- a/sample_notebooks/KonasaniSai Dheeraj/sample_(chapter_6).ipynb +++ /dev/null @@ -1,256 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 6 : FORMULAE" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 6_1 pgno:69" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "expr=8*i-5\n", - "the number is 16\n" - ] - } - ], - "source": [ - " #8 times a number is decreased by 5 the result is 123\n", - "#let x be the number\n", - "\n", - "print'expr=8*i-5'\n", - "x=0;\n", - "for x in range(0,100):\n", - " if((8*x-5)==123):\n", - " print\"the number is \",x\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 6_2 pgno:71" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "expr=(2*n+1)+(2*n+3)+(2*n+5)\n", - "n=%i \n", - "12\n", - "\n", - " the numbers are 199 201 203\n" - ] - } - ], - "source": [ - "#sum of 3 consecutive odd no.'s is 81\n", - "\n", - "#let the 3 consecutive odd numbers be 2n+1,2n+3,2n+5\n", - "\n", - "print\"expr=(2*n+1)+(2*n+3)+(2*n+5)\"\n", - "n=0;\n", - "for n in range(0,100):\n", - " if((2*n+1)+(2*n+3)+(2*n+5)==81):\n", - " print\"n=%i \\n\",n \n", - "\n", - "n1=2*n+1;\n", - "n2=2*n+3;\n", - "n3=2*n+5;\n", - "print\"\\n the numbers are \",n1,n2,n3\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 6_3 pgno:72" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "p1=(6*x-5)\n", - "p2=(2*x+9)\n", - "p3=p1-p2\n", - "satisfies the equation \n" - ] - } - ], - "source": [ - "import numpy\n", - "print\"p1=(6*x-5)\"\n", - "p1=numpy.array([6, -5])\n", - "print\"p2=(2*x+9)\"\n", - "p2=numpy.array([2, 9])\n", - "print\"p3=p1-p2\"\n", - "p3=p1-p2\n", - "\n", - "x1=numpy.roots(p3)\n", - "left=6*x1-5; #check by substituion \n", - "right=2*x1+9;\n", - "if(left==right):\n", - "\tprint'satisfies the equation '\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 6_4 pgno:73" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x is a polynomial function\n", - "by the law of sighs roots are [ 3.]\n" - ] - } - ], - "source": [ - "print\"x is a polynomial function\"\n", - "import numpy\n", - "p1=numpy.array([3/5+1/2, 0])\n", - "p2=numpy.array([5/4, -3])\n", - "#p1=3*x/5+x/2;\n", - "#p2=5*x/4-3;\n", - "p3=p1-p2;\n", - "x=numpy.roots(p3) #by the law of signs\n", - "print\"by the law of sighs roots are\",x\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 6_5 pgno:75" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "p1=4*x-(x-2)/3\n", - "p2=5+(2*x+1)/4\n", - "p3=p1-p2\n", - "satisfies the equation \n" - ] - } - ], - "source": [ - "import numpy\n", - "print\"p1=4*x-(x-2)/3\"\n", - "p1=numpy.array([11/3, 2/3])\n", - "print\"p2=5+(2*x+1)/4\"\n", - "p2=numpy.array([1/2, 21/4])\n", - "print\"p3=p1-p2\"\n", - "p3=p1-p2\n", - "\n", - "x=numpy.roots(p3)\n", - "left=4*x-(x-2)/3; #check by substituion \n", - "right=5+(2*x+1)/4;\n", - "if(left != right):\n", - "\tprint'satisfies the equation '\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/LalitKumar/LalitKumar_version_backup/chapter2.ipynb b/sample_notebooks/LalitKumar/LalitKumar_version_backup/chapter2.ipynb new file mode 100755 index 00000000..57657aa7 --- /dev/null +++ b/sample_notebooks/LalitKumar/LalitKumar_version_backup/chapter2.ipynb @@ -0,0 +1,347 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter2 : Atomic model & bonding in solids" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.1, page no-28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#given\n", + "#atomic no. of gold\n", + "Z=79\n", + "#kinetic energy of alpha particle\n", + "E=7.68*1.6*(10)**(-13) #J because [1MeV=1.6*(10)**(-13)]\n", + "e=1.6*10**(-19) #C\n", + "E0=8.854*10**(-12) #F/m\n", + "#the distance of closest approach is given by:\n", + "d0=2*e*Z*e/(4*(math.pi)*E0*E) #m\n", + "print \"The closest approach of alpha particle is %.2ef m\" %d0" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The closest approach of alpha particle is 2.96e-14f m\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.2, page no-29" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "from numpy import *\n", + "#given\n", + "#IN THE RUTHERFORD SCATTERING EXPERIMENT\n", + "#the no of particles scattered at\n", + "theta1=(pi)/2 #radians\n", + "#is\n", + "N90=44 #per minute\n", + "#the number of particles scattered particales N is given by\n", + "#N=C*(1/(sin(theta/2))**4) where C is propotionality constant\n", + "#solving above equation for C\n", + "C=N90*(sin(theta1/2))**4 \n", + "# now to find the no of particles scatering at 75 and 135 degrees\n", + "theta2=75*(pi)/180 #radians\n", + "N75=C*(1/(sin(theta2/2))**4) #per minute\n", + "theta3=135*(pi)/180 #radians\n", + "N135=C*(1/(sin(theta3/2))**4) #per minute\n", + "print \"The no of particles scattered at 75 and 135 degrees are %d per minute and %d per minutes\" %(N75,N135)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The no of particles scattered at 75 and 135 degrees are 80 per minute and 15 per minutes\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.3, page no-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#mass of electron\n", + "m=9.11*10**(-31) #kg\n", + "#charge on an electron\n", + "e=1.6*10**(-19) #C\n", + "#plank's constant\n", + "h=6.62*10**(-34)\n", + "E0=8.85*10**(-12) \n", + "#NO OF ELECTRONS SHELLS IN HYDROZEN ATOm\n", + "n=1\n", + "#atomic number of hydrogen\n", + "Z=1\n", + "#radius of first orbit of hydrogen is given by\n", + "r1=n**2*E0*h**2/((pi)*m*Z*e**2) #m\n", + "print \"The radius of the first orbit of the electron in the hydrogen atom %.2e\"%(r1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radius of the first orbit of the electron in the hydrogen atom 5.29e-11\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.4, page no-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#mass of electron\n", + "m=9.11*10**(-31) #kg\n", + "#charge on an electron\n", + "e=1.6*10**(-19) #C\n", + "#plank's constant\n", + "h=6.62*10**(-34)\n", + "E0=8.85*10**(-12) \n", + "#NO OF ELECTRONS SHELLS IN HYDROZEN ATOm\n", + "n=1\n", + "#atomic number of hydrogen\n", + "Z=1\n", + "#ionization potential energy of hydrogen atom is given by\n", + "E=m*Z**2*e**4/(8*(E0)**2*h**2*n**2) #J\n", + "#energy in eV\n", + "EV=E/e #eV\n", + "print \"The ionization potential for hydrogen atom is %0.2f V\" %(EV)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ionization potential for hydrogen atom is 13.59 V\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.5, page no-34" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.6, page no-36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#uncertainity in the momentum\n", + "deltap=10**-27 #kg ms**-1\n", + "#according to uncertainity principle\n", + "#deltap* deltax >=h/(2*(pi))\n", + "#we know that \n", + "h=6.626*10**-34 #Js\n", + "#here instead of inequality we are using only equality just for notation otherwise it is greater than equal to as mentioned above\n", + "#now deltax is given by\n", + "deltax=h/(2*(pi)*deltap) #m\n", + "print \"The minimum uncertainity is %.2e m\"%(deltax)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum uncertainity is 1.05e-07 m\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.10, page no- 57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#ionization potential of hydrogen\n", + "E1=13.6 #eV\n", + "#when \n", + "n=3\n", + "E3=-E1/n**2 #eV\n", + "#when \n", + "n=5\n", + "E5=-E1/n**2 #eV\n", + "print \"Energy of 3rd and 5th orbits are %0.2f eV and %0.2f eV\"%(E3,E5)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Energy of 3rd and 5th orbits are -1.51 eV and -0.54 eV\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.11, page no-59" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#dipole moment og HF is\n", + "DM=6.375*10**(-30) #Cm\n", + "#intermolecular distance\n", + "r=0.9178*10**(-10) #m\n", + "#charge on an electron\n", + "e=1.67*10**(-19) #C\n", + "#since the HF posses ionic characters\n", + "#so\n", + "#Hf in fully ionic state has dipole moment as\n", + "DM2=r*e #Cm\n", + "#percentage ionic characters\n", + "percentage=DM/DM2*100 #%\n", + "print \"The percentage ionic character is %0.2f approx.\"%(percentage)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The percentage ionic character is 41.59 approx.\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example-2.12, page no-60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "#elctronegativity of In\n", + "EnIn=1.5\n", + "#elctronegativity of As\n", + "EnAs=2.2\n", + "#elctronegativity of Ga\n", + "EnGa=1.8\n", + "#for InAs\n", + "ionic_charater1=(1-exp((-0.25)*(EnAs-EnIn)**2))*100 #in %\n", + "#for GaAs\n", + "ionic_charater2=(1-exp((-0.25)*(EnAs-EnGa)**2))*100 # in %\n", + "print \"Ionic character in InAs and GaAs are %0.1f %% and %0.1f %%\"%(ionic_charater1,ionic_charater2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Ionic character in InAs and GaAs are 11.5 % and 3.9 %\n" + ] + } + ], + "prompt_number": 30 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/LalitKumar/chapter2.ipynb b/sample_notebooks/LalitKumar/chapter2.ipynb deleted file mode 100755 index 57657aa7..00000000 --- a/sample_notebooks/LalitKumar/chapter2.ipynb +++ /dev/null @@ -1,347 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter2 : Atomic model & bonding in solids" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.1, page no-28" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#given\n", - "#atomic no. of gold\n", - "Z=79\n", - "#kinetic energy of alpha particle\n", - "E=7.68*1.6*(10)**(-13) #J because [1MeV=1.6*(10)**(-13)]\n", - "e=1.6*10**(-19) #C\n", - "E0=8.854*10**(-12) #F/m\n", - "#the distance of closest approach is given by:\n", - "d0=2*e*Z*e/(4*(math.pi)*E0*E) #m\n", - "print \"The closest approach of alpha particle is %.2ef m\" %d0" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The closest approach of alpha particle is 2.96e-14f m\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.2, page no-29" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "from numpy import *\n", - "#given\n", - "#IN THE RUTHERFORD SCATTERING EXPERIMENT\n", - "#the no of particles scattered at\n", - "theta1=(pi)/2 #radians\n", - "#is\n", - "N90=44 #per minute\n", - "#the number of particles scattered particales N is given by\n", - "#N=C*(1/(sin(theta/2))**4) where C is propotionality constant\n", - "#solving above equation for C\n", - "C=N90*(sin(theta1/2))**4 \n", - "# now to find the no of particles scatering at 75 and 135 degrees\n", - "theta2=75*(pi)/180 #radians\n", - "N75=C*(1/(sin(theta2/2))**4) #per minute\n", - "theta3=135*(pi)/180 #radians\n", - "N135=C*(1/(sin(theta3/2))**4) #per minute\n", - "print \"The no of particles scattered at 75 and 135 degrees are %d per minute and %d per minutes\" %(N75,N135)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The no of particles scattered at 75 and 135 degrees are 80 per minute and 15 per minutes\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.3, page no-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#mass of electron\n", - "m=9.11*10**(-31) #kg\n", - "#charge on an electron\n", - "e=1.6*10**(-19) #C\n", - "#plank's constant\n", - "h=6.62*10**(-34)\n", - "E0=8.85*10**(-12) \n", - "#NO OF ELECTRONS SHELLS IN HYDROZEN ATOm\n", - "n=1\n", - "#atomic number of hydrogen\n", - "Z=1\n", - "#radius of first orbit of hydrogen is given by\n", - "r1=n**2*E0*h**2/((pi)*m*Z*e**2) #m\n", - "print \"The radius of the first orbit of the electron in the hydrogen atom %.2e\"%(r1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radius of the first orbit of the electron in the hydrogen atom 5.29e-11\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.4, page no-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#mass of electron\n", - "m=9.11*10**(-31) #kg\n", - "#charge on an electron\n", - "e=1.6*10**(-19) #C\n", - "#plank's constant\n", - "h=6.62*10**(-34)\n", - "E0=8.85*10**(-12) \n", - "#NO OF ELECTRONS SHELLS IN HYDROZEN ATOm\n", - "n=1\n", - "#atomic number of hydrogen\n", - "Z=1\n", - "#ionization potential energy of hydrogen atom is given by\n", - "E=m*Z**2*e**4/(8*(E0)**2*h**2*n**2) #J\n", - "#energy in eV\n", - "EV=E/e #eV\n", - "print \"The ionization potential for hydrogen atom is %0.2f V\" %(EV)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ionization potential for hydrogen atom is 13.59 V\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.5, page no-34" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.6, page no-36" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#uncertainity in the momentum\n", - "deltap=10**-27 #kg ms**-1\n", - "#according to uncertainity principle\n", - "#deltap* deltax >=h/(2*(pi))\n", - "#we know that \n", - "h=6.626*10**-34 #Js\n", - "#here instead of inequality we are using only equality just for notation otherwise it is greater than equal to as mentioned above\n", - "#now deltax is given by\n", - "deltax=h/(2*(pi)*deltap) #m\n", - "print \"The minimum uncertainity is %.2e m\"%(deltax)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The minimum uncertainity is 1.05e-07 m\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.10, page no- 57" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#ionization potential of hydrogen\n", - "E1=13.6 #eV\n", - "#when \n", - "n=3\n", - "E3=-E1/n**2 #eV\n", - "#when \n", - "n=5\n", - "E5=-E1/n**2 #eV\n", - "print \"Energy of 3rd and 5th orbits are %0.2f eV and %0.2f eV\"%(E3,E5)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Energy of 3rd and 5th orbits are -1.51 eV and -0.54 eV\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.11, page no-59" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#dipole moment og HF is\n", - "DM=6.375*10**(-30) #Cm\n", - "#intermolecular distance\n", - "r=0.9178*10**(-10) #m\n", - "#charge on an electron\n", - "e=1.67*10**(-19) #C\n", - "#since the HF posses ionic characters\n", - "#so\n", - "#Hf in fully ionic state has dipole moment as\n", - "DM2=r*e #Cm\n", - "#percentage ionic characters\n", - "percentage=DM/DM2*100 #%\n", - "print \"The percentage ionic character is %0.2f approx.\"%(percentage)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The percentage ionic character is 41.59 approx.\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example-2.12, page no-60" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "#elctronegativity of In\n", - "EnIn=1.5\n", - "#elctronegativity of As\n", - "EnAs=2.2\n", - "#elctronegativity of Ga\n", - "EnGa=1.8\n", - "#for InAs\n", - "ionic_charater1=(1-exp((-0.25)*(EnAs-EnIn)**2))*100 #in %\n", - "#for GaAs\n", - "ionic_charater2=(1-exp((-0.25)*(EnAs-EnGa)**2))*100 # in %\n", - "print \"Ionic character in InAs and GaAs are %0.1f %% and %0.1f %%\"%(ionic_charater1,ionic_charater2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Ionic character in InAs and GaAs are 11.5 % and 3.9 %\n" - ] - } - ], - "prompt_number": 30 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/LaxmanSole/LaxmanSole_version_backup/Pinciples_of_electronic_Instrumentation.ipynb b/sample_notebooks/LaxmanSole/LaxmanSole_version_backup/Pinciples_of_electronic_Instrumentation.ipynb new file mode 100755 index 00000000..229d9b52 --- /dev/null +++ b/sample_notebooks/LaxmanSole/LaxmanSole_version_backup/Pinciples_of_electronic_Instrumentation.ipynb @@ -0,0 +1,406 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Basic Concepts" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_1,pg 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# unknown resistance\n", + "\n", + "import math\n", + "#VAriable declaration\n", + "Ir=10*10**-3 #current drawn by resistor\n", + "Vr=100.0 #voltage across resistor\n", + "Rv=40*10**3 #voltmeter resistance\n", + "\n", + "#Calcualtions\n", + "Ru=(Vr/Ir)*(1/(1-(Vr/(Ir*Rv)))) \n", + "\n", + "#Result\n", + "print(\"output resistance:\")\n", + "print(\"Ru=%.2f ohm\"%Ru)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "output resistance:\n", + "Ru=13333.33 ohm\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_2,pg 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# unknown resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Ir=10*10**-3 #current drawn by resistor\n", + "Vr=100.0 #voltage across resistor\n", + "Rv=40*10**3 #voltmeter resistance\n", + "Ra=1.0 #ammeter resistance\n", + "\n", + "#Calculations\n", + "Ru=(Rv/Ir)-Ra\n", + "\n", + "#Result\n", + "print(\"output resistance:\")\n", + "print(\"Ru=%.2f ohm\"%Ru)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "output resistance:\n", + "Ru=3999999.00 ohm\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_3,pg 481" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# find ammeter reading\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Rv=40*10**3 #voltmeter resistance\n", + "Ra=1.0 #ammeter resistance\n", + "Vr=40.0 #voltmeter reading\n", + "Ru=10*10**3 #unknown resistance\n", + "\n", + "#Calculations\n", + "Ir=(Vr*(Rv+Ru))/(Ru*Rv)\n", + "Ir1=(Vr/(Ru+Ra))\n", + "\n", + "#Result\n", + "print(\"ammeter reading case1:\")\n", + "print(\"Ir=%.4f A\"%Ir)\n", + "print(\"\\nammeter reading case2:\")\n", + "print(\"Ir1=%.4f A\"%Ir1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "ammeter reading case1:\n", + "Ir=0.0050 A\n", + "\n", + "ammeter reading case2:\n", + "Ir1=0.0040 A\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_4,pg 482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# unknown resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vs=3.0 #supply voltage\n", + "Vu=2.75 #voltmeter reading\n", + "Rp=10*10**3 #parallel resistance\n", + "\n", + "#Calculations\n", + "Ru=Rp*((Vs/Vu)-1)\n", + "\n", + "#Result\n", + "print(\"unknown resistance:\")\n", + "print(\"Ru=%.2f ohm\"%Ru)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "unknown resistance:\n", + "Ru=909.09 ohm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_5,pg 482" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Find input vlotage\n", + "\n", + "#with input voltage exceding 2Vd,diodes conduct and the voltage divider circuit with diodes can allow only a Vi given by Vi=2Vd\n", + "\n", + "#Result\n", + "print(\"input voltage to amplifier:\")\n", + "print(\"Vi=2Vd\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "input voltage to amplifier:\n", + "Vi=2Vd\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Example1_6,pg 482" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# find shunt resistance\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Rm=1000.0 #meter resistance\n", + "Is=900*10**-6 #shunt current\n", + "Vm=100*10**-3 #drop across meter\n", + "\n", + "#Result\n", + "Rs=Vm/Is\n", + "It=1*10**-3\n", + "#Is=It*(Rm/(Rs+Rm))\n", + "Rs=(Rm*(It-Is))/Is\n", + "\n", + "#Result\n", + "print(\"shunt resistance:\")\n", + "print(\"Rs=%.2f ohm\"%Rs)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "shunt resistance:\n", + "Rs=111.11 ohm\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_7,pg 483" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# find series resistor\n", + "\n", + "import math\n", + "#Variable declaration\n", + "If=100*10**-6 #full scale current\n", + "Rm=1000.0 #meter resistance\n", + "Vf=10.0 #full scale voltage\n", + "\n", + "#Calculations\n", + "Rs=(Vf/If)-Rm\n", + "\n", + "#Result\n", + "print(\"series resistance:\")\n", + "print(\"Rs=%.2f ohm\"%Rs)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "series resistance:\n", + "Rs=99000.00 ohm\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Example1_8,pg 483" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# sensitivity\n", + "\n", + "import math\n", + "#Variable declaration\n", + "If=100*10**-6 # Current\n", + "\n", + "#Calculations\n", + "S=1/If\n", + "\n", + "#Result\n", + "print(\"sensitivity:\")\n", + "print(\"S=%.2f ohm/volt\"%S)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sensitivity:\n", + "S=10000.00 ohm/volt\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example1_9,pg 483" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# error in measurment\n", + "\n", + "import math\n", + "# Variable declaration\n", + "\n", + "#assume that the voltmeter full scale reading is 12V which gives its resistance as 1.2*10^6 ohm \n", + "#which is in parallel with 10*10^6 ohm making as equivalent of Rq given as\n", + "R=1.2*10**6 #voltmeter resistance\n", + "R1=10*10**6 #voltage divider resistance\n", + "Vin=12.0 #input voltage to divider network\n", + "Rs=4*10**6 # series resistance\n", + "\n", + "\n", + "#Calculations\n", + "Rq=(R*R1)/(R+R1)\n", + "Vq=(Rq*Vin)/(Rq+Rs) #voltage across equivalent combination\n", + "Va=(R1*Vin)/(R1+Rs) #actual volatge\n", + "er=(Vq-Va)/Va #error\n", + "\n", + "#Result\n", + "print(\"error in measurement:\")\n", + "print(\"\\ner=%.3f \"%er)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "error in measurement:\n", + "\n", + "er=-0.704 \n" + ] + } + ], + "prompt_number": 14 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/LaxmanSole/Pinciples_of_electronic_Instrumentation_Ch1.ipynb b/sample_notebooks/LaxmanSole/Pinciples_of_electronic_Instrumentation_Ch1.ipynb deleted file mode 100755 index 229d9b52..00000000 --- a/sample_notebooks/LaxmanSole/Pinciples_of_electronic_Instrumentation_Ch1.ipynb +++ /dev/null @@ -1,406 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 : Basic Concepts" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_1,pg 481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# unknown resistance\n", - "\n", - "import math\n", - "#VAriable declaration\n", - "Ir=10*10**-3 #current drawn by resistor\n", - "Vr=100.0 #voltage across resistor\n", - "Rv=40*10**3 #voltmeter resistance\n", - "\n", - "#Calcualtions\n", - "Ru=(Vr/Ir)*(1/(1-(Vr/(Ir*Rv)))) \n", - "\n", - "#Result\n", - "print(\"output resistance:\")\n", - "print(\"Ru=%.2f ohm\"%Ru)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "output resistance:\n", - "Ru=13333.33 ohm\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_2,pg 481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# unknown resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Ir=10*10**-3 #current drawn by resistor\n", - "Vr=100.0 #voltage across resistor\n", - "Rv=40*10**3 #voltmeter resistance\n", - "Ra=1.0 #ammeter resistance\n", - "\n", - "#Calculations\n", - "Ru=(Rv/Ir)-Ra\n", - "\n", - "#Result\n", - "print(\"output resistance:\")\n", - "print(\"Ru=%.2f ohm\"%Ru)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "output resistance:\n", - "Ru=3999999.00 ohm\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_3,pg 481" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# find ammeter reading\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Rv=40*10**3 #voltmeter resistance\n", - "Ra=1.0 #ammeter resistance\n", - "Vr=40.0 #voltmeter reading\n", - "Ru=10*10**3 #unknown resistance\n", - "\n", - "#Calculations\n", - "Ir=(Vr*(Rv+Ru))/(Ru*Rv)\n", - "Ir1=(Vr/(Ru+Ra))\n", - "\n", - "#Result\n", - "print(\"ammeter reading case1:\")\n", - "print(\"Ir=%.4f A\"%Ir)\n", - "print(\"\\nammeter reading case2:\")\n", - "print(\"Ir1=%.4f A\"%Ir1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "ammeter reading case1:\n", - "Ir=0.0050 A\n", - "\n", - "ammeter reading case2:\n", - "Ir1=0.0040 A\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_4,pg 482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# unknown resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vs=3.0 #supply voltage\n", - "Vu=2.75 #voltmeter reading\n", - "Rp=10*10**3 #parallel resistance\n", - "\n", - "#Calculations\n", - "Ru=Rp*((Vs/Vu)-1)\n", - "\n", - "#Result\n", - "print(\"unknown resistance:\")\n", - "print(\"Ru=%.2f ohm\"%Ru)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "unknown resistance:\n", - "Ru=909.09 ohm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_5,pg 482" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Find input vlotage\n", - "\n", - "#with input voltage exceding 2Vd,diodes conduct and the voltage divider circuit with diodes can allow only a Vi given by Vi=2Vd\n", - "\n", - "#Result\n", - "print(\"input voltage to amplifier:\")\n", - "print(\"Vi=2Vd\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "input voltage to amplifier:\n", - "Vi=2Vd\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Example1_6,pg 482" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# find shunt resistance\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Rm=1000.0 #meter resistance\n", - "Is=900*10**-6 #shunt current\n", - "Vm=100*10**-3 #drop across meter\n", - "\n", - "#Result\n", - "Rs=Vm/Is\n", - "It=1*10**-3\n", - "#Is=It*(Rm/(Rs+Rm))\n", - "Rs=(Rm*(It-Is))/Is\n", - "\n", - "#Result\n", - "print(\"shunt resistance:\")\n", - "print(\"Rs=%.2f ohm\"%Rs)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "shunt resistance:\n", - "Rs=111.11 ohm\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_7,pg 483" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# find series resistor\n", - "\n", - "import math\n", - "#Variable declaration\n", - "If=100*10**-6 #full scale current\n", - "Rm=1000.0 #meter resistance\n", - "Vf=10.0 #full scale voltage\n", - "\n", - "#Calculations\n", - "Rs=(Vf/If)-Rm\n", - "\n", - "#Result\n", - "print(\"series resistance:\")\n", - "print(\"Rs=%.2f ohm\"%Rs)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "series resistance:\n", - "Rs=99000.00 ohm\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Example1_8,pg 483" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# sensitivity\n", - "\n", - "import math\n", - "#Variable declaration\n", - "If=100*10**-6 # Current\n", - "\n", - "#Calculations\n", - "S=1/If\n", - "\n", - "#Result\n", - "print(\"sensitivity:\")\n", - "print(\"S=%.2f ohm/volt\"%S)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "sensitivity:\n", - "S=10000.00 ohm/volt\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example1_9,pg 483" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# error in measurment\n", - "\n", - "import math\n", - "# Variable declaration\n", - "\n", - "#assume that the voltmeter full scale reading is 12V which gives its resistance as 1.2*10^6 ohm \n", - "#which is in parallel with 10*10^6 ohm making as equivalent of Rq given as\n", - "R=1.2*10**6 #voltmeter resistance\n", - "R1=10*10**6 #voltage divider resistance\n", - "Vin=12.0 #input voltage to divider network\n", - "Rs=4*10**6 # series resistance\n", - "\n", - "\n", - "#Calculations\n", - "Rq=(R*R1)/(R+R1)\n", - "Vq=(Rq*Vin)/(Rq+Rs) #voltage across equivalent combination\n", - "Va=(R1*Vin)/(R1+Rs) #actual volatge\n", - "er=(Vq-Va)/Va #error\n", - "\n", - "#Result\n", - "print(\"error in measurement:\")\n", - "print(\"\\ner=%.3f \"%er)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "error in measurement:\n", - "\n", - "er=-0.704 \n" - ] - } - ], - "prompt_number": 14 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave.ipynb b/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave.ipynb new file mode 100755 index 00000000..38d38099 --- /dev/null +++ b/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave.ipynb @@ -0,0 +1,299 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7 Wave Guides" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_1 pgno:75" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Critical wavelength = cm\n", + "15.24\n", + "-Guide wavelength = cm 13.3\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "c=3.*(10**8);\n", + "f=3000.*(10**8);\n", + "lo=c/f;\n", + "l=lo*(10**4);\n", + "m=1.;n=0;a=7.62;\n", + "lc=2*a;\n", + "print\"-Critical wavelength = cm\\n\",lc\n", + "lg=sqrt((l*l*lc*lc)/((lc*lc)-(l*l)));\n", + "print\"-Guide wavelength = cm\",round(lg*10)/10\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_2 pgno:76" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Frequency of dominant mode = GHz 5.0\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "a=3;\n", + "lc=2*a;\n", + "Zs=500;n=377;c=3*(10**8);\n", + "lo=sqrt(1-((n/Zs)**2))*lc;\n", + "f=c/lo;\n", + "f1=f/(10**7);\n", + "print\"Frequency of dominant mode = GHz\",round(f1*100)/100\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_3 pgno:78" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i)Cutoff wavelegth = cm\n", + "9.0\n", + "(ii)Guide wavelength = cm\n", + "3.59\n", + "(iii)Phase velocity = * 10**8 m/sec\n", + "3.23\n", + " Group velocity = * 10**8 m/sec\n", + "2.79\n", + "(iv)Characteristic impedance = ohm 406.0\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "a=4.5;b=3.;f=9.*(10**9);c=3.0*(10**8);n=377.\n", + "lo=c/f;\n", + "l=lo*(10**2);\n", + "lc=2*a;\n", + "print\"(i)Cutoff wavelegth = cm\\n\",lc\n", + "lg=l /(sqrt(1-((l/lc)**2)));\n", + "print\"(ii)Guide wavelength = cm\\n\",round(lg*100)/100\n", + "Vp=(lg/l)*c*10**-8;\n", + "print\"(iii)Phase velocity = * 10**8 m/sec\\n\",round(Vp*100)/100\n", + "Vg=(l/lg)*c*10**-8;\n", + "print\" Group velocity = * 10**8 m/sec\\n\",round(Vg*100)/100\n", + "Z=n/(sqrt(1-((l/lc)**2)));\n", + "print\"(iv)Characteristic impedance = ohm\",round(Z)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_4 pgno:79" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total attenuation = db 681.88\n", + "The difference in result is due to erroneous value in textbook\n" + ] + } + ], + "source": [ + "a=1.;c=3.*(10**8);f=(10**9);d=25.;\n", + "lc=2*a;\n", + "lo=c/f;\n", + "l=lo/(10**2);\n", + "att=(54.55/lc)*d;\n", + "print\"Total attenuation = db\",round(att*100)/100\n", + "#the difference in result is due to erroneous value in textbook.\n", + "print (\"The difference in result is due to erroneous value in textbook\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_5 pgno:80" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Phase velocity Vp = * 10**8 m/sec\n", + "4.2\n", + "-Group velocity Vg = * 10**8 m/sec\n", + "2.2\n", + "-Phase constant = radians/m 45.0\n" + ] + } + ], + "source": [ + "from math import sqrt,pi\n", + "c=3.*(10**8);f=3000.*(10**6);a=.0722;\n", + "lo=c/f;\n", + "lc=2*a;\n", + "lg=lo/(sqrt(1-((lo/lc)**2)));\n", + "Vp=(lg/lo)*c*10**-8;\n", + "print\"-Phase velocity Vp = * 10**8 m/sec\\n\",round(Vp*10)/10\n", + "Vg=(lo/lg)*c*10**-8;\n", + "print\"-Group velocity Vg = * 10**8 m/sec\\n\",round(Vg*10)/10\n", + "b=(2*pi)/lg;\n", + "print\"-Phase constant = radians/m\",round(b)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_6 pgno:81" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i)Cutoff frequency for TE11 = GHz\n", + "3.52\n", + "(ii)Cutoff frequency for TE01 = GHz 4.6\n" + ] + } + ], + "source": [ + "\n", + "d=5.;c=3.*(10**8);\n", + "lo=1.706*d;\n", + "f=c/lo;\n", + "ff=f/(10**7);\n", + "print\"(i)Cutoff frequency for TE11 = GHz\\n\",round(ff*100)/100\n", + "l=1.306*d;\n", + "fc=c/l;\n", + "ffc=fc/(10**7);\n", + "print\"(ii)Cutoff frequency for TE01 = GHz\",round(ffc*10)/10\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_7 pgno:82" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Cutoff wavelength = cm\n", + "8.54\n", + "-Guide wavelength = cm\n", + "4.17\n", + "-Characteristic wave impedance = ohm 419.7\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "c=3.*(10**8);f=8.*(10**9);r=2.5;h=1.84;n=377.;\n", + "l=c/f;\n", + "lo=l*(10**2);\n", + "lc=2*pi*r/h;\n", + "print\"-Cutoff wavelength = cm\\n\",round(lc*100)/100\n", + "lp=lo/(sqrt(1-((lo/lc)**2)));\n", + "print\"-Guide wavelength = cm\\n\",round(lp*100)/100\n", + "Zo=n/(sqrt(1-((lo/lc)**2)));\n", + "print\"-Characteristic wave impedance = ohm\",round(Zo*10)/10\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave_Guides.ipynb b/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave_Guides.ipynb deleted file mode 100755 index 38d38099..00000000 --- a/sample_notebooks/ManchukondaGopi Krishna/Chapter_7_Wave_Guides.ipynb +++ /dev/null @@ -1,299 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 7 Wave Guides" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_1 pgno:75" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Critical wavelength = cm\n", - "15.24\n", - "-Guide wavelength = cm 13.3\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "c=3.*(10**8);\n", - "f=3000.*(10**8);\n", - "lo=c/f;\n", - "l=lo*(10**4);\n", - "m=1.;n=0;a=7.62;\n", - "lc=2*a;\n", - "print\"-Critical wavelength = cm\\n\",lc\n", - "lg=sqrt((l*l*lc*lc)/((lc*lc)-(l*l)));\n", - "print\"-Guide wavelength = cm\",round(lg*10)/10\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_2 pgno:76" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Frequency of dominant mode = GHz 5.0\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "a=3;\n", - "lc=2*a;\n", - "Zs=500;n=377;c=3*(10**8);\n", - "lo=sqrt(1-((n/Zs)**2))*lc;\n", - "f=c/lo;\n", - "f1=f/(10**7);\n", - "print\"Frequency of dominant mode = GHz\",round(f1*100)/100\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_3 pgno:78" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i)Cutoff wavelegth = cm\n", - "9.0\n", - "(ii)Guide wavelength = cm\n", - "3.59\n", - "(iii)Phase velocity = * 10**8 m/sec\n", - "3.23\n", - " Group velocity = * 10**8 m/sec\n", - "2.79\n", - "(iv)Characteristic impedance = ohm 406.0\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "a=4.5;b=3.;f=9.*(10**9);c=3.0*(10**8);n=377.\n", - "lo=c/f;\n", - "l=lo*(10**2);\n", - "lc=2*a;\n", - "print\"(i)Cutoff wavelegth = cm\\n\",lc\n", - "lg=l /(sqrt(1-((l/lc)**2)));\n", - "print\"(ii)Guide wavelength = cm\\n\",round(lg*100)/100\n", - "Vp=(lg/l)*c*10**-8;\n", - "print\"(iii)Phase velocity = * 10**8 m/sec\\n\",round(Vp*100)/100\n", - "Vg=(l/lg)*c*10**-8;\n", - "print\" Group velocity = * 10**8 m/sec\\n\",round(Vg*100)/100\n", - "Z=n/(sqrt(1-((l/lc)**2)));\n", - "print\"(iv)Characteristic impedance = ohm\",round(Z)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_4 pgno:79" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total attenuation = db 681.88\n", - "The difference in result is due to erroneous value in textbook\n" - ] - } - ], - "source": [ - "a=1.;c=3.*(10**8);f=(10**9);d=25.;\n", - "lc=2*a;\n", - "lo=c/f;\n", - "l=lo/(10**2);\n", - "att=(54.55/lc)*d;\n", - "print\"Total attenuation = db\",round(att*100)/100\n", - "#the difference in result is due to erroneous value in textbook.\n", - "print (\"The difference in result is due to erroneous value in textbook\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_5 pgno:80" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Phase velocity Vp = * 10**8 m/sec\n", - "4.2\n", - "-Group velocity Vg = * 10**8 m/sec\n", - "2.2\n", - "-Phase constant = radians/m 45.0\n" - ] - } - ], - "source": [ - "from math import sqrt,pi\n", - "c=3.*(10**8);f=3000.*(10**6);a=.0722;\n", - "lo=c/f;\n", - "lc=2*a;\n", - "lg=lo/(sqrt(1-((lo/lc)**2)));\n", - "Vp=(lg/lo)*c*10**-8;\n", - "print\"-Phase velocity Vp = * 10**8 m/sec\\n\",round(Vp*10)/10\n", - "Vg=(lo/lg)*c*10**-8;\n", - "print\"-Group velocity Vg = * 10**8 m/sec\\n\",round(Vg*10)/10\n", - "b=(2*pi)/lg;\n", - "print\"-Phase constant = radians/m\",round(b)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_6 pgno:81" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i)Cutoff frequency for TE11 = GHz\n", - "3.52\n", - "(ii)Cutoff frequency for TE01 = GHz 4.6\n" - ] - } - ], - "source": [ - "\n", - "d=5.;c=3.*(10**8);\n", - "lo=1.706*d;\n", - "f=c/lo;\n", - "ff=f/(10**7);\n", - "print\"(i)Cutoff frequency for TE11 = GHz\\n\",round(ff*100)/100\n", - "l=1.306*d;\n", - "fc=c/l;\n", - "ffc=fc/(10**7);\n", - "print\"(ii)Cutoff frequency for TE01 = GHz\",round(ffc*10)/10\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_7 pgno:82" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Cutoff wavelength = cm\n", - "8.54\n", - "-Guide wavelength = cm\n", - "4.17\n", - "-Characteristic wave impedance = ohm 419.7\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "c=3.*(10**8);f=8.*(10**9);r=2.5;h=1.84;n=377.;\n", - "l=c/f;\n", - "lo=l*(10**2);\n", - "lc=2*pi*r/h;\n", - "print\"-Cutoff wavelength = cm\\n\",round(lc*100)/100\n", - "lp=lo/(sqrt(1-((lo/lc)**2)));\n", - "print\"-Guide wavelength = cm\\n\",round(lp*100)/100\n", - "Zo=n/(sqrt(1-((lo/lc)**2)));\n", - "print\"-Characteristic wave impedance = ohm\",round(Zo*10)/10\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1.ipynb b/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1.ipynb new file mode 100755 index 00000000..a5fe0aae --- /dev/null +++ b/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1.ipynb @@ -0,0 +1,176 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Gravity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1 pgno:10" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Time period of the pendulum is sec 1.00303620705\n" + ] + } + ], + "source": [ + "#INPUT DATA\n", + "L=1;#Length of the bar in m\n", + "l=0.25;#Length of the pemdulum in m\n", + "from math import sqrt\n", + "#CALCULATIONS\n", + "k=sqrt((L**2)/12);#Radius of gyration m\n", + "T=sqrt(((k**2/l)+l)/9.8)*2*3.14;#Time period of pendulum in s\n", + "\n", + "#OUTPUT\n", + "print'Time period of the pendulum is sec',T\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2 pgno:11" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The acceleration due to gravity is m s^-2 9.8002855276\n" + ] + } + ], + "source": [ + "import math\n", + "#INPUT DATA\n", + "T=2.223;#Time taken for 1 oscillation in sec\n", + "L=1.228;#Length of the pendulum in m\n", + "\n", + "#CALCULATIONS\n", + "g=((4*3.14**2*L)/(T**2));#Acceleration due to gravity in m.s^-2\n", + "\n", + "#OUTPUT\n", + "print'The acceleration due to gravity is m s^-2',g\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3 pgno:12" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The time period of pendulum is s\n", + "Distance of another point from centre of gravity on bar with same time period is m 1.79428571429 0.2\n" + ] + } + ], + "source": [ + "#INPUT DATA\n", + "l=1.2;#Length of of bar in m\n", + "from math import sqrt\n", + "#CALCULATIONS\n", + "k=sqrt(l**2/12);#Radius of gyration in m\n", + "T=sqrt(((k**2/(l/2))+(l/2))/9.8)*2*3.14;#Time period of the pendulum in s\n", + "L=((9.8*T**2)/(4*3.14**2));#Length in m\n", + "D=L-(l/2);#Another point where pendulum has same timeperiod in m\n", + "\n", + "#OUTPUT\n", + "print'The time period of pendulum is s\\nDistance of another point from centre of gravity on bar with same time period is m',T,D\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1 pgno:14" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The minimum time period is obtained at cm -28.9035753267\n" + ] + } + ], + "source": [ + "\n", + "#INPUT DATA\n", + "L=1;#Length of pendulum in m\n", + "B=0.05;#Width of pendulum in m\n", + "from math import sqrt\n", + "#CALCULATIONS\n", + "k=sqrt((L**2+B**2)/12);#Radius of gyration in m\n", + "D=((L/2)-k)*100;#distance of point of minimum time period from one end in cm\n", + "\n", + "#OUTPUT\n", + "print'The minimum time period is obtained at cm',D\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1_Gravity.ipynb b/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1_Gravity.ipynb deleted file mode 100755 index a5fe0aae..00000000 --- a/sample_notebooks/ManchukondaLalitha Pujitha/Chpater_1_Gravity.ipynb +++ /dev/null @@ -1,176 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Gravity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1 pgno:10" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time period of the pendulum is sec 1.00303620705\n" - ] - } - ], - "source": [ - "#INPUT DATA\n", - "L=1;#Length of the bar in m\n", - "l=0.25;#Length of the pemdulum in m\n", - "from math import sqrt\n", - "#CALCULATIONS\n", - "k=sqrt((L**2)/12);#Radius of gyration m\n", - "T=sqrt(((k**2/l)+l)/9.8)*2*3.14;#Time period of pendulum in s\n", - "\n", - "#OUTPUT\n", - "print'Time period of the pendulum is sec',T\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2 pgno:11" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The acceleration due to gravity is m s^-2 9.8002855276\n" - ] - } - ], - "source": [ - "import math\n", - "#INPUT DATA\n", - "T=2.223;#Time taken for 1 oscillation in sec\n", - "L=1.228;#Length of the pendulum in m\n", - "\n", - "#CALCULATIONS\n", - "g=((4*3.14**2*L)/(T**2));#Acceleration due to gravity in m.s^-2\n", - "\n", - "#OUTPUT\n", - "print'The acceleration due to gravity is m s^-2',g\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3 pgno:12" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The time period of pendulum is s\n", - "Distance of another point from centre of gravity on bar with same time period is m 1.79428571429 0.2\n" - ] - } - ], - "source": [ - "#INPUT DATA\n", - "l=1.2;#Length of of bar in m\n", - "from math import sqrt\n", - "#CALCULATIONS\n", - "k=sqrt(l**2/12);#Radius of gyration in m\n", - "T=sqrt(((k**2/(l/2))+(l/2))/9.8)*2*3.14;#Time period of the pendulum in s\n", - "L=((9.8*T**2)/(4*3.14**2));#Length in m\n", - "D=L-(l/2);#Another point where pendulum has same timeperiod in m\n", - "\n", - "#OUTPUT\n", - "print'The time period of pendulum is s\\nDistance of another point from centre of gravity on bar with same time period is m',T,D\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1 pgno:14" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The minimum time period is obtained at cm -28.9035753267\n" - ] - } - ], - "source": [ - "\n", - "#INPUT DATA\n", - "L=1;#Length of pendulum in m\n", - "B=0.05;#Width of pendulum in m\n", - "from math import sqrt\n", - "#CALCULATIONS\n", - "k=sqrt((L**2+B**2)/12);#Radius of gyration in m\n", - "D=((L/2)-k)*100;#distance of point of minimum time period from one end in cm\n", - "\n", - "#OUTPUT\n", - "print'The minimum time period is obtained at cm',D\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring.ipynb b/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring.ipynb new file mode 100755 index 00000000..2cb57529 --- /dev/null +++ b/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring.ipynb @@ -0,0 +1,109 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Generalized Configurations and Functional Descriptions of Measuring Instruments" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_1 pgno:22" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ts=0.1\n", + "ps=2.5\n", + "dT=20\n", + "the error in measurement is d percent\n", + "0.007\n" + ] + } + ], + "source": [ + "#Caption_Error in measurement\n", + "#Ex_1 part_2 #page 22\n", + "print (\"ts=0.1\")\n", + "print (\"ps=2.5\")\n", + "print (\"dT=20\")\n", + "\n", + "ts=0.1 #('enter the temperature sensitivity=:')\n", + "ps=2.5 #('enter the pressure sensitivity(in units/MPa)=:')\n", + "dT=20 #('enter the temperature change during pressure measurement=:')\n", + "P=120 #('enter the pressure to be measured (in MPa)=:')\n", + "error=(ts*dT)/(ps*P);\n", + "print'the error in measurement is d percent\\n',round(error,3) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_2 pgno:23" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the error in measurement is d percent\n", + "0.017\n" + ] + } + ], + "source": [ + "#Caption_Error in measurement\n", + "#Ex_2 part_2 #page 23\n", + "\n", + "\n", + "ts=0.5 #('enter the temperature sensitivity=:')\n", + "ps=7.5 #('enter the pressure sensitivity(in units/MPa)=:')\n", + "dT=40 #('enter the temperature change during pressure measurement=:')\n", + "P=160 #('enter the pressure to be measured (in MPa)=:')\n", + "error=(ts*dT)/(ps*P);\n", + "print'the error in measurement is d percent\\n',round(error,3) " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring_Instruments.ipynb b/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring_Instruments.ipynb deleted file mode 100755 index 2cb57529..00000000 --- a/sample_notebooks/ManchukondaMaruthi Naga Vijaya Durga/Chapter_2_Generalized_Configurations_and_Functional_Descriptions_of_Measuring_Instruments.ipynb +++ /dev/null @@ -1,109 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Generalized Configurations and Functional Descriptions of Measuring Instruments" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_1 pgno:22" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ts=0.1\n", - "ps=2.5\n", - "dT=20\n", - "the error in measurement is d percent\n", - "0.007\n" - ] - } - ], - "source": [ - "#Caption_Error in measurement\n", - "#Ex_1 part_2 #page 22\n", - "print (\"ts=0.1\")\n", - "print (\"ps=2.5\")\n", - "print (\"dT=20\")\n", - "\n", - "ts=0.1 #('enter the temperature sensitivity=:')\n", - "ps=2.5 #('enter the pressure sensitivity(in units/MPa)=:')\n", - "dT=20 #('enter the temperature change during pressure measurement=:')\n", - "P=120 #('enter the pressure to be measured (in MPa)=:')\n", - "error=(ts*dT)/(ps*P);\n", - "print'the error in measurement is d percent\\n',round(error,3) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_2 pgno:23" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the error in measurement is d percent\n", - "0.017\n" - ] - } - ], - "source": [ - "#Caption_Error in measurement\n", - "#Ex_2 part_2 #page 23\n", - "\n", - "\n", - "ts=0.5 #('enter the temperature sensitivity=:')\n", - "ps=7.5 #('enter the pressure sensitivity(in units/MPa)=:')\n", - "dT=40 #('enter the temperature change during pressure measurement=:')\n", - "P=160 #('enter the pressure to be measured (in MPa)=:')\n", - "error=(ts*dT)/(ps*P);\n", - "print'the error in measurement is d percent\\n',round(error,3) " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian.ipynb b/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian.ipynb new file mode 100755 index 00000000..212743ac --- /dev/null +++ b/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian.ipynb @@ -0,0 +1,658 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4 Radian Measure" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.1 page.no:96" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Radian measure is 0.314159 rad\n", + "(or)\n", + "Radian measure is (pi/10)rad\n" + ] + } + ], + "source": [ + "#To convert a degree measure to radians\n", + "from math import pi\n", + "\n", + "deg=18 # degree measure\n", + "radian=deg*(pi/180) # radian measure\n", + "print \"Radian measure is %f rad\\n(or)\"%radian\n", + "print \"Radian measure is (pi/%.0f)rad\"%(1/(radian/pi))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.2 page.no:96" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Degree measure is 20 degree\n" + ] + } + ], + "source": [ + "#To convert a radian meeasure to degree\n", + "from math import pi\n", + "\n", + "radian=pi/9 # radian measure\n", + "deg=radian/(pi/180) # degree measure\n", + "print \"Degree measure is %.0f degree\"%deg" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.3 page.no:99" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length of arc intercepted =2.4 cm\n" + ] + } + ], + "source": [ + "#To determine length of the intercepted arc\n", + "r=2. #radius of circle\n", + "theta=1.2 # central angle in radian\n", + "s=r*theta # length of arc\n", + "print \"Length of arc intercepted =%.1f cm\"%s" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.4 page.no:99" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length of arc intercepted = 7.16 ft \n" + ] + } + ], + "source": [ + "#To determine length of the arc intercepted\n", + "from math import pi\n", + "\n", + "r=10 #radius of circle\n", + "theta=41*(pi/180) # central angle in radian\n", + "s=r*theta # length of arc\n", + "print \"Length of arc intercepted = %.2f ft \"%s" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.5 page.no:100" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Measure of central angle = 0.40 rad\n", + " \n", + "Measure of central angle =22.92 degree\n" + ] + } + ], + "source": [ + "#To determine angle in radians and degrees\n", + "from math import pi\n", + "\n", + "r=5. #radius of circle\n", + "s=2. #length of arc\n", + "theta = s/r #central angle in radian\n", + "print \"Measure of central angle = %.2f rad\\n \"%theta\n", + "print \"Measure of central angle =%.2f degree\"%(theta*(180/pi))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.6 page.no:100" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length of the rope =13.4 ft\n" + ] + } + ], + "source": [ + "#To determine the length of the rope\n", + "from math import sqrt,pi,atan,acos\n", + "\n", + "d=8. #distance between places in feet\n", + "r=2. #radius of cylinder in feet\n", + "#from the figure\n", + "DA=d/2\n", + "BE=r\n", + "DE=3 #distance from centre of container to wall\n", + "AE=sqrt(DE**2 + DA**2) # pythagoras theorem\n", + "AB=sqrt(AE**2 - BE**2) # pythagoras theorem\n", + "#all angles below are in radians\n", + "angle_AED = atan((d/2)/DE)\n", + "angle_AEB = acos(BE/AE)\n", + "angle_BEC = pi - (angle_AED + angle_AEB)\n", + "arc_BC = BE*angle_BEC #length of arc BC\n", + "L = 2*(AB + arc_BC) #length of rope\n", + "print \"Length of the rope =%.1f ft\"%L" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.7 page.no:101" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length of belt around pulley = 71.4 cm\n" + ] + } + ], + "source": [ + "#To determine the length of the belt around the pulleys\n", + "from math import pi,sqrt,asin\n", + "\n", + "AE= 5. #radius of first pulley in cm\n", + "BF= 8. #radius of second pulley in cm\n", + "AB=15. #distance between centre of pulleys in cm\n", + "#from the figure\n", + "CF=AE #parallel side of rectangle ACFE\n", + "BC= BF- CF\n", + "AC = sqrt(AB**2 - BC**2) #by pythagoras theorem\n", + "EF=AC# parallel side of rectangle ACFE 14\n", + "angle_EAC = pi/2\n", + "angle_BAC = asin(BC/AB)\n", + "angle_DAE = pi - angle_EAC - angle_BAC\n", + "angle_ABC = angle_DAE #AE and BF are parallel\n", + "angle_GBF= pi - angle_ABC\n", + "arc_DE=AE*angle_ABC # length of arc DE\n", + "arc_FG=BF*angle_GBF # length of arc FG\n", + "L=2*(arc_DE + EF + arc_FG) #length of belt\n", + "print \"Length of belt around pulley = %.1f cm\"%L" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.8 page.no:103" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Area of sector = 1.6∗pi cmˆ2\n", + "(or)\n", + "Area of sector = 5.026548 cmˆ2\n" + ] + } + ], + "source": [ + "#To find the area of sector of circle\n", + "from math import pi\n", + "\n", + "theta= pi/5 # angle in radian\n", + "r=4. #radius in cm\n", + "A=r*r*theta/2 #Area of sector\n", + "print \"Area of sector = %.1f∗pi cmˆ2\\n(or)\"%(A/pi)\n", + "print \"Area of sector = %f cmˆ2\"%A" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.9 page.no:103" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Area of sector =12.51 mˆ2\n" + ] + } + ], + "source": [ + "#To determine area of sector of a circle\n", + "from math import pi\n", + "\n", + "theta= 117*(pi/180) # angle in radian\n", + "r=3.5 #radius in m\n", + "A=r*r*theta/2 #Area of sector\n", + "print \"Area of sector =%.2f mˆ2\"%A" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.10 page.no:104" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Area of sector =27 cmˆ2\n", + "\n", + "Note: Angle subtended by arc = 0.666667 rad\n" + ] + } + ], + "source": [ + "#To determine area of sector of circle\n", + "\n", + "s=6. #arc length in cm\n", + "r=9. #radius in cm\n", + "A=r*s/2 #Area of sector\n", + "print \"Area of sector =%.0f cmˆ2\\n\"%A\n", + "print \"Note: Angle subtended by arc = %f rad\"%(s/r)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.11 page.no:104" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Area enclosed by belt pulley system = 338.71 cmˆ2 \n" + ] + } + ], + "source": [ + "#To determine area insude belt pulley system\n", + "from math import pi,sqrt,asin\n", + "\n", + "AE= 5. #radius of first pulley\n", + "BF= 8. #radius of second pulley\n", + "AB=15. #distance between centre of pulleys\n", + "#from the figure\n", + "CF=AE\n", + "BC= BF- CF\n", + "AC = sqrt(AB**2 - BC**2)\n", + "#from the figure\n", + "angle_EAC = pi/2\n", + "angle_BAC = asin(BC/AB)\n", + "angle_DAE = pi - angle_EAC - angle_BAC\n", + "angle_ABC = angle_DAE #AE and BF are parallel\n", + "angle_GBF= pi - angle_ABC\n", + "area_DAE = AE**2*angle_DAE/2 #area of sector DAE\n", + "area_GBF = BF**2*angle_GBF/2 #area of sector GBF\n", + "area_AEFC = AE*AC #area of rectangle AEFC\n", + "area_ABC = AC*BC/2 #area of triangle ABC\n", + "area_K =2*( area_DAE + area_AEFC + area_ABC +area_GBF)\n", + "print \"Area enclosed by belt pulley system = %.2f cmˆ2 \"%area_K\n", + "#Note: answer differs from book due to approximations by them " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.12 page.no:105" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Required area of segment = 1.408 square units\n" + ] + } + ], + "source": [ + "#To determine area of segment formed by a chord in circle\n", + "from math import acos,sin\n", + "\n", + "radius = 2.\n", + "chord = 3.\n", + "#Use law of cosines\n", + "cos_theta = (radius**2+radius**2-chord**2)/(2*radius*radius)\n", + "theta=acos(cos_theta) #subtended central angle in radians\n", + "area_K=radius**2*(theta-sin(theta))/2\n", + "print \"Required area of segment = %.3f square units\"%area_K" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.13 page.no:106" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Area of intersection of 2 circles =7.66 cm ˆ2 \n" + ] + } + ], + "source": [ + "#To determine area of intersection of 2 circles\n", + "from math import acos\n", + "\n", + "d=7. #distance between centres in cm\n", + "r1= 5. #radius of first circle in cm\n", + "r2= 4. #radius of second circle in cm\n", + "#use law of cosines\n", + "cos_alpha=(d**2+ r1**2 - r2**2 ) /(2*d*r1)\n", + "cos_beeta=(d**2+ r2**2 - r1**2 ) /(2*d*r2)\n", + "#from the geometry of the figure\n", + "#all the angles below are in radians\n", + "alpha= acos(cos_alpha)\n", + "beeta= acos(cos_beeta)\n", + "angle_BAC = alpha\n", + "angle_ABC = beeta\n", + "angle_CAD =2* angle_BAC\n", + "angle_CBD =2* angle_ABC\n", + "#required area = area at segment CD in circle at A and at B\n", + "area_K = r1**2*(angle_CAD-sin(angle_CAD))/2 + r2 **2*(angle_CBD-sin(angle_CBD))/2\n", + "print \"Area of intersection of 2 circles =%.2f cm ˆ2 \"%area_K" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.14 page.no:109" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Angular speed= 2.094395 radian/sec\n", + "\n", + "Linear speed=6.283185m/sec\n", + "\n", + "(or)\n", + "\n", + "Angular speed= 0.666667∗pi radian/sec\n", + " \n", + "Linear speed = 2.000000∗pi m/sec \n" + ] + } + ], + "source": [ + "#To find linear and angular speed of a moving object\n", + "from math import pi\n", + "t=0.5 #time in second\n", + "r= 3 #radius in m of the circle\n", + "theta = pi/3 # central angle in radian\n", + "w = theta/t #angular speed in rad /sec\n", + "v=w*r#linear speed in m/sec\n", + "print \"Angular speed= %f radian/sec\\n\"%w\n", + "print \"Linear speed=%fm/sec\"%v\n", + "print \"\\n(or)\\n\\nAngular speed= %f∗pi radian/sec\\n \"%(w/pi)\n", + "print \"Linear speed = %f∗pi m/sec \"%(v/pi)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.15 page.no:109" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Linear speed = 12.96 ft/sec\n", + "\n", + "Angular speed= 6.48 radian/sec\n" + ] + } + ], + "source": [ + "#To find linear and angular speed of a moving object\n", + "\n", + "t=2.7 #time in second\n", + "r= 2. #radius in ft of the circle\n", + "s=35. #distance in feet\n", + "v=s/t #linear speed in ft/sec\n", + "w=v/r #angular speed in rad /sec\n", + "print \"Linear speed = %.2f ft/sec\\n\"%v\n", + "print \"Angular speed= %.2f radian/sec\"%w" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.16 page.no:109" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "central angle swept = 7.75 radian \n" + ] + } + ], + "source": [ + "#To find the central angle swept by a moving object\n", + "t=3.1 #time in second\n", + "v= 10 #linear speed in m/sec\n", + "r= 4 #radius in m of the circle\n", + "s=v*t # distance in m\n", + "theta = s/r #central angle swept\n", + "print \"central angle swept = %.2f radian \"%theta" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.17 page.no:110" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Angular speed of larger gear=20 rpm \n" + ] + } + ], + "source": [ + "#To find the angular speed of larger gear interlocked with smaller gear\n", + "r1=5 #radius of larger gear\n", + "r2=4 #radius smaller gear\n", + "w2=25 #angular speed of smaller gear\n", + "# Imagine a particle on outer radii of each gear\n", + "#At any time , for every rotation , circular displacement of each particle is same\n", + "# (or) s1=s2 implies v1∗t=v2∗t\n", + "#v1= v2 implies w1∗r1=w2∗r2\n", + "w1=(w2*r2)/r1 #angular speed of larger gear\n", + "print \"Angular speed of larger gear=%.0f rpm \"%w1" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian_Measure.ipynb b/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian_Measure.ipynb deleted file mode 100755 index 212743ac..00000000 --- a/sample_notebooks/MandalaManoj pruthvi/Chapter_4_Radian_Measure.ipynb +++ /dev/null @@ -1,658 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4 Radian Measure" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.1 page.no:96" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Radian measure is 0.314159 rad\n", - "(or)\n", - "Radian measure is (pi/10)rad\n" - ] - } - ], - "source": [ - "#To convert a degree measure to radians\n", - "from math import pi\n", - "\n", - "deg=18 # degree measure\n", - "radian=deg*(pi/180) # radian measure\n", - "print \"Radian measure is %f rad\\n(or)\"%radian\n", - "print \"Radian measure is (pi/%.0f)rad\"%(1/(radian/pi))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.2 page.no:96" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Degree measure is 20 degree\n" - ] - } - ], - "source": [ - "#To convert a radian meeasure to degree\n", - "from math import pi\n", - "\n", - "radian=pi/9 # radian measure\n", - "deg=radian/(pi/180) # degree measure\n", - "print \"Degree measure is %.0f degree\"%deg" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.3 page.no:99" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Length of arc intercepted =2.4 cm\n" - ] - } - ], - "source": [ - "#To determine length of the intercepted arc\n", - "r=2. #radius of circle\n", - "theta=1.2 # central angle in radian\n", - "s=r*theta # length of arc\n", - "print \"Length of arc intercepted =%.1f cm\"%s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.4 page.no:99" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Length of arc intercepted = 7.16 ft \n" - ] - } - ], - "source": [ - "#To determine length of the arc intercepted\n", - "from math import pi\n", - "\n", - "r=10 #radius of circle\n", - "theta=41*(pi/180) # central angle in radian\n", - "s=r*theta # length of arc\n", - "print \"Length of arc intercepted = %.2f ft \"%s" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.5 page.no:100" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Measure of central angle = 0.40 rad\n", - " \n", - "Measure of central angle =22.92 degree\n" - ] - } - ], - "source": [ - "#To determine angle in radians and degrees\n", - "from math import pi\n", - "\n", - "r=5. #radius of circle\n", - "s=2. #length of arc\n", - "theta = s/r #central angle in radian\n", - "print \"Measure of central angle = %.2f rad\\n \"%theta\n", - "print \"Measure of central angle =%.2f degree\"%(theta*(180/pi))" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.6 page.no:100" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Length of the rope =13.4 ft\n" - ] - } - ], - "source": [ - "#To determine the length of the rope\n", - "from math import sqrt,pi,atan,acos\n", - "\n", - "d=8. #distance between places in feet\n", - "r=2. #radius of cylinder in feet\n", - "#from the figure\n", - "DA=d/2\n", - "BE=r\n", - "DE=3 #distance from centre of container to wall\n", - "AE=sqrt(DE**2 + DA**2) # pythagoras theorem\n", - "AB=sqrt(AE**2 - BE**2) # pythagoras theorem\n", - "#all angles below are in radians\n", - "angle_AED = atan((d/2)/DE)\n", - "angle_AEB = acos(BE/AE)\n", - "angle_BEC = pi - (angle_AED + angle_AEB)\n", - "arc_BC = BE*angle_BEC #length of arc BC\n", - "L = 2*(AB + arc_BC) #length of rope\n", - "print \"Length of the rope =%.1f ft\"%L" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.7 page.no:101" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Length of belt around pulley = 71.4 cm\n" - ] - } - ], - "source": [ - "#To determine the length of the belt around the pulleys\n", - "from math import pi,sqrt,asin\n", - "\n", - "AE= 5. #radius of first pulley in cm\n", - "BF= 8. #radius of second pulley in cm\n", - "AB=15. #distance between centre of pulleys in cm\n", - "#from the figure\n", - "CF=AE #parallel side of rectangle ACFE\n", - "BC= BF- CF\n", - "AC = sqrt(AB**2 - BC**2) #by pythagoras theorem\n", - "EF=AC# parallel side of rectangle ACFE 14\n", - "angle_EAC = pi/2\n", - "angle_BAC = asin(BC/AB)\n", - "angle_DAE = pi - angle_EAC - angle_BAC\n", - "angle_ABC = angle_DAE #AE and BF are parallel\n", - "angle_GBF= pi - angle_ABC\n", - "arc_DE=AE*angle_ABC # length of arc DE\n", - "arc_FG=BF*angle_GBF # length of arc FG\n", - "L=2*(arc_DE + EF + arc_FG) #length of belt\n", - "print \"Length of belt around pulley = %.1f cm\"%L" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.8 page.no:103" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of sector = 1.6∗pi cmˆ2\n", - "(or)\n", - "Area of sector = 5.026548 cmˆ2\n" - ] - } - ], - "source": [ - "#To find the area of sector of circle\n", - "from math import pi\n", - "\n", - "theta= pi/5 # angle in radian\n", - "r=4. #radius in cm\n", - "A=r*r*theta/2 #Area of sector\n", - "print \"Area of sector = %.1f∗pi cmˆ2\\n(or)\"%(A/pi)\n", - "print \"Area of sector = %f cmˆ2\"%A" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.9 page.no:103" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of sector =12.51 mˆ2\n" - ] - } - ], - "source": [ - "#To determine area of sector of a circle\n", - "from math import pi\n", - "\n", - "theta= 117*(pi/180) # angle in radian\n", - "r=3.5 #radius in m\n", - "A=r*r*theta/2 #Area of sector\n", - "print \"Area of sector =%.2f mˆ2\"%A" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.10 page.no:104" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of sector =27 cmˆ2\n", - "\n", - "Note: Angle subtended by arc = 0.666667 rad\n" - ] - } - ], - "source": [ - "#To determine area of sector of circle\n", - "\n", - "s=6. #arc length in cm\n", - "r=9. #radius in cm\n", - "A=r*s/2 #Area of sector\n", - "print \"Area of sector =%.0f cmˆ2\\n\"%A\n", - "print \"Note: Angle subtended by arc = %f rad\"%(s/r)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.11 page.no:104" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area enclosed by belt pulley system = 338.71 cmˆ2 \n" - ] - } - ], - "source": [ - "#To determine area insude belt pulley system\n", - "from math import pi,sqrt,asin\n", - "\n", - "AE= 5. #radius of first pulley\n", - "BF= 8. #radius of second pulley\n", - "AB=15. #distance between centre of pulleys\n", - "#from the figure\n", - "CF=AE\n", - "BC= BF- CF\n", - "AC = sqrt(AB**2 - BC**2)\n", - "#from the figure\n", - "angle_EAC = pi/2\n", - "angle_BAC = asin(BC/AB)\n", - "angle_DAE = pi - angle_EAC - angle_BAC\n", - "angle_ABC = angle_DAE #AE and BF are parallel\n", - "angle_GBF= pi - angle_ABC\n", - "area_DAE = AE**2*angle_DAE/2 #area of sector DAE\n", - "area_GBF = BF**2*angle_GBF/2 #area of sector GBF\n", - "area_AEFC = AE*AC #area of rectangle AEFC\n", - "area_ABC = AC*BC/2 #area of triangle ABC\n", - "area_K =2*( area_DAE + area_AEFC + area_ABC +area_GBF)\n", - "print \"Area enclosed by belt pulley system = %.2f cmˆ2 \"%area_K\n", - "#Note: answer differs from book due to approximations by them " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.12 page.no:105" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Required area of segment = 1.408 square units\n" - ] - } - ], - "source": [ - "#To determine area of segment formed by a chord in circle\n", - "from math import acos,sin\n", - "\n", - "radius = 2.\n", - "chord = 3.\n", - "#Use law of cosines\n", - "cos_theta = (radius**2+radius**2-chord**2)/(2*radius*radius)\n", - "theta=acos(cos_theta) #subtended central angle in radians\n", - "area_K=radius**2*(theta-sin(theta))/2\n", - "print \"Required area of segment = %.3f square units\"%area_K" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.13 page.no:106" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Area of intersection of 2 circles =7.66 cm ˆ2 \n" - ] - } - ], - "source": [ - "#To determine area of intersection of 2 circles\n", - "from math import acos\n", - "\n", - "d=7. #distance between centres in cm\n", - "r1= 5. #radius of first circle in cm\n", - "r2= 4. #radius of second circle in cm\n", - "#use law of cosines\n", - "cos_alpha=(d**2+ r1**2 - r2**2 ) /(2*d*r1)\n", - "cos_beeta=(d**2+ r2**2 - r1**2 ) /(2*d*r2)\n", - "#from the geometry of the figure\n", - "#all the angles below are in radians\n", - "alpha= acos(cos_alpha)\n", - "beeta= acos(cos_beeta)\n", - "angle_BAC = alpha\n", - "angle_ABC = beeta\n", - "angle_CAD =2* angle_BAC\n", - "angle_CBD =2* angle_ABC\n", - "#required area = area at segment CD in circle at A and at B\n", - "area_K = r1**2*(angle_CAD-sin(angle_CAD))/2 + r2 **2*(angle_CBD-sin(angle_CBD))/2\n", - "print \"Area of intersection of 2 circles =%.2f cm ˆ2 \"%area_K" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.14 page.no:109" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Angular speed= 2.094395 radian/sec\n", - "\n", - "Linear speed=6.283185m/sec\n", - "\n", - "(or)\n", - "\n", - "Angular speed= 0.666667∗pi radian/sec\n", - " \n", - "Linear speed = 2.000000∗pi m/sec \n" - ] - } - ], - "source": [ - "#To find linear and angular speed of a moving object\n", - "from math import pi\n", - "t=0.5 #time in second\n", - "r= 3 #radius in m of the circle\n", - "theta = pi/3 # central angle in radian\n", - "w = theta/t #angular speed in rad /sec\n", - "v=w*r#linear speed in m/sec\n", - "print \"Angular speed= %f radian/sec\\n\"%w\n", - "print \"Linear speed=%fm/sec\"%v\n", - "print \"\\n(or)\\n\\nAngular speed= %f∗pi radian/sec\\n \"%(w/pi)\n", - "print \"Linear speed = %f∗pi m/sec \"%(v/pi)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.15 page.no:109" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Linear speed = 12.96 ft/sec\n", - "\n", - "Angular speed= 6.48 radian/sec\n" - ] - } - ], - "source": [ - "#To find linear and angular speed of a moving object\n", - "\n", - "t=2.7 #time in second\n", - "r= 2. #radius in ft of the circle\n", - "s=35. #distance in feet\n", - "v=s/t #linear speed in ft/sec\n", - "w=v/r #angular speed in rad /sec\n", - "print \"Linear speed = %.2f ft/sec\\n\"%v\n", - "print \"Angular speed= %.2f radian/sec\"%w" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.16 page.no:109" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "central angle swept = 7.75 radian \n" - ] - } - ], - "source": [ - "#To find the central angle swept by a moving object\n", - "t=3.1 #time in second\n", - "v= 10 #linear speed in m/sec\n", - "r= 4 #radius in m of the circle\n", - "s=v*t # distance in m\n", - "theta = s/r #central angle swept\n", - "print \"central angle swept = %.2f radian \"%theta" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.17 page.no:110" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Angular speed of larger gear=20 rpm \n" - ] - } - ], - "source": [ - "#To find the angular speed of larger gear interlocked with smaller gear\n", - "r1=5 #radius of larger gear\n", - "r2=4 #radius smaller gear\n", - "w2=25 #angular speed of smaller gear\n", - "# Imagine a particle on outer radii of each gear\n", - "#At any time , for every rotation , circular displacement of each particle is same\n", - "# (or) s1=s2 implies v1∗t=v2∗t\n", - "#v1= v2 implies w1∗r1=w2∗r2\n", - "w1=(w2*r2)/r1 #angular speed of larger gear\n", - "print \"Angular speed of larger gear=%.0f rpm \"%w1" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical.ipynb b/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical.ipynb new file mode 100755 index 00000000..fb6cc7a3 --- /dev/null +++ b/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical.ipynb @@ -0,0 +1,430 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:e126fa636efa72af4b20cd3702da45f085d125811e3d4b6de05ba5fde96d2c77" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2:Light propagation in optical ber" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 , Page no:30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "ncore=1.46; #refractive index of core\n", + "nclad=1; #refractive index of cladding\n", + "c=3e5; #velocity of light in Km/s\n", + "L=1; #length of path in Km\n", + "\n", + "#CALCULATIONS\n", + "NA=math.sqrt(ncore**2-nclad**2); #Numerical aperture\n", + "delt_tau_by_L=(NA**2)/(2*c*ncore); #multipath pulse broadening in s/Km\n", + "delt_tau=delt_tau_by_L*L; #bandwidth distance product Hz\n", + "BL=(1/delt_tau)*L; #bandwidth distance product Hz\n", + "#case-2\n", + "ncore1=1.465; #refractive index of core\n", + "nclad1=1.45; #refractive index of cladding\n", + "NA1=math.sqrt(ncore1**2-nclad1**2); #Numerical aperture\n", + "delt_tau_by_L1=(NA1**2)/(2*c*ncore1); #multipath pulse broadening in s/m\n", + "BL1=(1/delt_tau_by_L1)*L; #bandwidth distance product Hz\n", + "\n", + "#RESULTS\n", + "print\"Numerical aperture=\",round(NA,5); #The answers vary due to round off error\n", + "print\"\\nMultipath pulse broadening=\",round(delt_tau_by_L*1e9,5),\"ns/Km\"; #The answer provided in the textbook is wrong//multiplication by 1e9 to convert s/Km to ns/Km \n", + "print\"\\nBandwidth distance product=\",round(BL*1e-6,5),\"GHz \"; #The answer provided in the textbook is wrong//multiplication by 1e-6 to convert Hz to MHz\n", + "print\"\\n\\nNumerical aperture=\",round(NA1,5);\n", + "print\"\\nMultipath pulse broadening=\",round(delt_tau_by_L1*1e9,5),\"ns/Km\"; #The answer provided in the textbook is wrong//multiplication by 1e9 to convert s/Km to ns/Km \n", + "print\"\\nBandwidth distance product=\",round(BL1*1e-9,5),\"GHz \"; #The answer provided in the textbook is wrong//multiplication by 1e-6 to convert Hz to GHz" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerical aperture= 1.06377\n", + "\n", + "Multipath pulse broadening= 1291.78082 ns/Km\n", + "\n", + "Bandwidth distance product= 0.77413 GHz \n", + "\n", + "\n", + "Numerical aperture= 0.20911\n", + "\n", + "Multipath pulse broadening= 49.74403 ns/Km\n", + "\n", + "Bandwidth distance product= 0.0201 GHz \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 , Page no:30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "lamda1=0.7; #wavelength in um\n", + "lamda2=1.3; #wavelength in um\n", + "lamda3=2; #wavelength in um\n", + "\n", + "#CALCULATIONS\n", + "f_lambda1=(303.33*(lamda1**-1)-233.33); #equation for lambda1\n", + "f_lambda2=(303.33*(lamda2**-1)-233.33); #equation for lambda2\n", + "f_lambda3=(303.33*(lamda3**-1)-233.33); #equation for lambda3\n", + "\n", + "#RESULTS\n", + "print\"Material dispersion at Lambda 0.7um=\",round(f_lambda1,5);\n", + "print\"\\nMaterial dispersion at Lambda 1.3um=\",round(f_lambda2,5); #The answers vary due to round off error\n", + "print\"\\nMaterial dispersion at Lambda 2um=\",round(f_lambda3,5); #The answers vary due to round off error\n", + "print\"\\nIts is a standard silica fiber\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Material dispersion at Lambda 0.7um= 199.99857\n", + "\n", + "Material dispersion at Lambda 1.3um= 0.00077\n", + "\n", + "Material dispersion at Lambda 2um= -81.665\n", + "\n", + "Its is a standard silica fiber\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 , Page no:32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "ncore=1.505; #refractive index of core\n", + "nclad=1.502; #refractive index of cladding\n", + "V=2.4; #v no. for single mode \n", + "lambda1=1300e-9; #operating wavelength in m\n", + "\n", + "#CALCULATIONS\n", + "NA=math.sqrt(ncore**2-nclad**2); #numerical aperture\n", + "a=V*(lambda1)/(2*3.14*NA); #dimension of fiber core in m\n", + "\n", + "#RESULTS\n", + "print\"The numarical aperture =\",round(NA,5);\n", + "print\"\\n Dimension of fiber core =\",round(a*1e6,5),\"um\"; #multiplication by 1e6 to convert unit from m to um" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The numarical aperture = 0.09498\n", + "\n", + " Dimension of fiber core = 5.23079 um\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 , Page no:33" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "V=2; #v no. for single mode \n", + "a=4; #radius of fiber in um\n", + "\n", + "#CALCULATIONS\n", + "w=a*(0.65+1.619*V**(-3/2)+2.87*V**-6); #effective mode radius in um\n", + "\n", + "#RESULTS\n", + "print\"Effective mode radius =\",round(w,5),\"um\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Effective mode radius = 5.06899 um\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 , Page no:34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "m=0; #for dominant mode\n", + "v=0; #for dominant mode\n", + "n1=1.5; #refractive index of core\n", + "delta=0.01; #core clad index difference\n", + "a=5; #fiber radius in um\n", + "lambda1=1.3; #wavelength of operation in um\n", + "\n", + "#CALCULATIONS\n", + "k0=(2*3.14/lambda1); #constant in /m\n", + "beta=math.sqrt((k0**2)*(n1**2)-(2*k0*n1*math.sqrt(2*delta)/a)); #propagation constant in rad/um\n", + "\n", + "#RESULTS\n", + "print\"Propagation constant=\",round(beta,5),\"rad/um\"; #The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Propagation constant= 7.21781 rad/um\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 , Page no:34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "M=1000; #modes supported\n", + "lambda1=1.3; #operating wavelength in um\n", + "n1=1.5; #refractive index of core\n", + "n2=1.48; #refractive index of cladding\n", + "\n", + "#CALCULATIONS\n", + "V=math.sqrt(2*M); #normalised frequency V no.\n", + "NA=math.sqrt(n1**2-n2**2); #numerical apperture\n", + "R=lambda1*V/(2*3.14*NA); #radius of fiber in um\n", + "\n", + "#RESULTS\n", + "print\"Core Radius=\",round(R,5),\"um\"; #The answer provided in the textbook is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Core Radius= 37.92063 um\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 , Page no:35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "lambda1=1.3; #wavelength of operation in um\n", + "n1=1.5; #refractive index of core\n", + "n2=1.48; #refractive index of cladding\n", + "k0=2*3.14/lambda1; #constant in /m\n", + "\n", + "#CALCULATIONS\n", + "#case-1\n", + "b=0.5; #normalized propagation constant\n", + "k0=2*3.14/lambda1; #constant\n", + "beta=k0*math.sqrt(n2**2+b*(n1**2-n2**2)); #propagation constant\n", + "\n", + "#case-2\n", + "#given \n", + "lambda1=1.3; #wavelength of operation in um\n", + "n1=1.5; #refractive index of core\n", + "n2=1.48; #refractive index of cladding\n", + "k0=2*3.14/lambda1; #constant in /m\n", + "b=0.5; #normalized propagation constant\n", + "k0=2*3.14/lambda1; #constant\n", + "b1=(((n1+n2)/2)**2-n2**2)/(n1**2-n2**2); #normalized propagation constant\n", + "\n", + "#case-3\n", + "#given \n", + "lambda1=1.3; #wavelength of operation in um\n", + "n1=1.5; #refractive index of core\n", + "n21=1.0; #refractive index of cladding\n", + "k0=2*3.14/lambda1; #constant in /m\n", + "b=0.5; #normalized propagation constant\n", + "k0=2*3.14/lambda1; #constant\n", + "beta1=k0*math.sqrt(n21**2+b*(n1**2-n21**2)); #propagation constant\n", + "\n", + "#RESULTS\n", + "print\"Propagation constant=\",round(beta,5),\"rad/um\"; #The answers vary due to round off error\n", + "print\"\\nPropagation constant=\",round(b1,5); #The answers vary due to round off error\n", + "print\"\\nPropagation constant=\",round(beta1,5),\"rad/um\"; #The answers vary due to round off error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Propagation constant= 7.19801 rad/um\n", + "\n", + "Propagation constant= 0.49832\n", + "\n", + "Propagation constant= 6.15805 rad/um\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.10 , Page no:35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "#case-1\n", + "n1=1.49; #refractive index of core\n", + "n2=1.46; #refractive index of cladding\n", + "c=3*10**5; #speed of light in Km/s\n", + "t1=n1/c; #time delay for one traveling along axis in s/Km\n", + "t2=(n1**2/n2)/c; #time delay for one traveling along path that is totally reflecting at the first interface in s/km\n", + "\n", + "#case-2\n", + "n11=1.47; #refractive index of core\n", + "n21=1.46; #refractive index of cladding\n", + "c1=3*10**5; #speed of light in Km/s\n", + "t11=n11/c1; #time delay for one traveling along axis in\n", + "t22=(n11**2/n21)/c1; #time delay for one traveling along path that is totally reflecting at the first interface\n", + "\n", + "\n", + "print\"time delay for traveling along axis =\",round(t1*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", + "print\"\\ntime delay for traveling along path that is totally reflecting at the first interface =\",round(t2*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", + "print\"\\ntime delay for traveling along axis =\",round(t11*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", + "print\"\\ntime delay for traveling along path that is totally reflecting at the first interface =\",round(t22*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", + "#The answer provided in the textbook is wrong it has got wrong unit" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "time delay for traveling along axis = 4.96667 us/Km\n", + "\n", + "time delay for traveling along path that is totally reflecting at the first interface = 5.06872 us/Km\n", + "\n", + "time delay for traveling along axis = 4.9 us/Km\n", + "\n", + "time delay for traveling along path that is totally reflecting at the first interface = 4.93356 us/Km\n" + ] + } + ], + "prompt_number": 8 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb b/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb deleted file mode 100755 index fb6cc7a3..00000000 --- a/sample_notebooks/ManikandanD/Chapter_2_Light_propagation_in_optical_fiber.ipynb +++ /dev/null @@ -1,430 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e126fa636efa72af4b20cd3702da45f085d125811e3d4b6de05ba5fde96d2c77" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2:Light propagation in optical ber" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 , Page no:30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "ncore=1.46; #refractive index of core\n", - "nclad=1; #refractive index of cladding\n", - "c=3e5; #velocity of light in Km/s\n", - "L=1; #length of path in Km\n", - "\n", - "#CALCULATIONS\n", - "NA=math.sqrt(ncore**2-nclad**2); #Numerical aperture\n", - "delt_tau_by_L=(NA**2)/(2*c*ncore); #multipath pulse broadening in s/Km\n", - "delt_tau=delt_tau_by_L*L; #bandwidth distance product Hz\n", - "BL=(1/delt_tau)*L; #bandwidth distance product Hz\n", - "#case-2\n", - "ncore1=1.465; #refractive index of core\n", - "nclad1=1.45; #refractive index of cladding\n", - "NA1=math.sqrt(ncore1**2-nclad1**2); #Numerical aperture\n", - "delt_tau_by_L1=(NA1**2)/(2*c*ncore1); #multipath pulse broadening in s/m\n", - "BL1=(1/delt_tau_by_L1)*L; #bandwidth distance product Hz\n", - "\n", - "#RESULTS\n", - "print\"Numerical aperture=\",round(NA,5); #The answers vary due to round off error\n", - "print\"\\nMultipath pulse broadening=\",round(delt_tau_by_L*1e9,5),\"ns/Km\"; #The answer provided in the textbook is wrong//multiplication by 1e9 to convert s/Km to ns/Km \n", - "print\"\\nBandwidth distance product=\",round(BL*1e-6,5),\"GHz \"; #The answer provided in the textbook is wrong//multiplication by 1e-6 to convert Hz to MHz\n", - "print\"\\n\\nNumerical aperture=\",round(NA1,5);\n", - "print\"\\nMultipath pulse broadening=\",round(delt_tau_by_L1*1e9,5),\"ns/Km\"; #The answer provided in the textbook is wrong//multiplication by 1e9 to convert s/Km to ns/Km \n", - "print\"\\nBandwidth distance product=\",round(BL1*1e-9,5),\"GHz \"; #The answer provided in the textbook is wrong//multiplication by 1e-6 to convert Hz to GHz" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerical aperture= 1.06377\n", - "\n", - "Multipath pulse broadening= 1291.78082 ns/Km\n", - "\n", - "Bandwidth distance product= 0.77413 GHz \n", - "\n", - "\n", - "Numerical aperture= 0.20911\n", - "\n", - "Multipath pulse broadening= 49.74403 ns/Km\n", - "\n", - "Bandwidth distance product= 0.0201 GHz \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2 , Page no:30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "lamda1=0.7; #wavelength in um\n", - "lamda2=1.3; #wavelength in um\n", - "lamda3=2; #wavelength in um\n", - "\n", - "#CALCULATIONS\n", - "f_lambda1=(303.33*(lamda1**-1)-233.33); #equation for lambda1\n", - "f_lambda2=(303.33*(lamda2**-1)-233.33); #equation for lambda2\n", - "f_lambda3=(303.33*(lamda3**-1)-233.33); #equation for lambda3\n", - "\n", - "#RESULTS\n", - "print\"Material dispersion at Lambda 0.7um=\",round(f_lambda1,5);\n", - "print\"\\nMaterial dispersion at Lambda 1.3um=\",round(f_lambda2,5); #The answers vary due to round off error\n", - "print\"\\nMaterial dispersion at Lambda 2um=\",round(f_lambda3,5); #The answers vary due to round off error\n", - "print\"\\nIts is a standard silica fiber\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Material dispersion at Lambda 0.7um= 199.99857\n", - "\n", - "Material dispersion at Lambda 1.3um= 0.00077\n", - "\n", - "Material dispersion at Lambda 2um= -81.665\n", - "\n", - "Its is a standard silica fiber\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 , Page no:32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "ncore=1.505; #refractive index of core\n", - "nclad=1.502; #refractive index of cladding\n", - "V=2.4; #v no. for single mode \n", - "lambda1=1300e-9; #operating wavelength in m\n", - "\n", - "#CALCULATIONS\n", - "NA=math.sqrt(ncore**2-nclad**2); #numerical aperture\n", - "a=V*(lambda1)/(2*3.14*NA); #dimension of fiber core in m\n", - "\n", - "#RESULTS\n", - "print\"The numarical aperture =\",round(NA,5);\n", - "print\"\\n Dimension of fiber core =\",round(a*1e6,5),\"um\"; #multiplication by 1e6 to convert unit from m to um" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The numarical aperture = 0.09498\n", - "\n", - " Dimension of fiber core = 5.23079 um\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 , Page no:33" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "V=2; #v no. for single mode \n", - "a=4; #radius of fiber in um\n", - "\n", - "#CALCULATIONS\n", - "w=a*(0.65+1.619*V**(-3/2)+2.87*V**-6); #effective mode radius in um\n", - "\n", - "#RESULTS\n", - "print\"Effective mode radius =\",round(w,5),\"um\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Effective mode radius = 5.06899 um\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 , Page no:34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "m=0; #for dominant mode\n", - "v=0; #for dominant mode\n", - "n1=1.5; #refractive index of core\n", - "delta=0.01; #core clad index difference\n", - "a=5; #fiber radius in um\n", - "lambda1=1.3; #wavelength of operation in um\n", - "\n", - "#CALCULATIONS\n", - "k0=(2*3.14/lambda1); #constant in /m\n", - "beta=math.sqrt((k0**2)*(n1**2)-(2*k0*n1*math.sqrt(2*delta)/a)); #propagation constant in rad/um\n", - "\n", - "#RESULTS\n", - "print\"Propagation constant=\",round(beta,5),\"rad/um\"; #The answers vary due to round off error" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Propagation constant= 7.21781 rad/um\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8 , Page no:34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "M=1000; #modes supported\n", - "lambda1=1.3; #operating wavelength in um\n", - "n1=1.5; #refractive index of core\n", - "n2=1.48; #refractive index of cladding\n", - "\n", - "#CALCULATIONS\n", - "V=math.sqrt(2*M); #normalised frequency V no.\n", - "NA=math.sqrt(n1**2-n2**2); #numerical apperture\n", - "R=lambda1*V/(2*3.14*NA); #radius of fiber in um\n", - "\n", - "#RESULTS\n", - "print\"Core Radius=\",round(R,5),\"um\"; #The answer provided in the textbook is wrong" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Core Radius= 37.92063 um\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.9 , Page no:35" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "lambda1=1.3; #wavelength of operation in um\n", - "n1=1.5; #refractive index of core\n", - "n2=1.48; #refractive index of cladding\n", - "k0=2*3.14/lambda1; #constant in /m\n", - "\n", - "#CALCULATIONS\n", - "#case-1\n", - "b=0.5; #normalized propagation constant\n", - "k0=2*3.14/lambda1; #constant\n", - "beta=k0*math.sqrt(n2**2+b*(n1**2-n2**2)); #propagation constant\n", - "\n", - "#case-2\n", - "#given \n", - "lambda1=1.3; #wavelength of operation in um\n", - "n1=1.5; #refractive index of core\n", - "n2=1.48; #refractive index of cladding\n", - "k0=2*3.14/lambda1; #constant in /m\n", - "b=0.5; #normalized propagation constant\n", - "k0=2*3.14/lambda1; #constant\n", - "b1=(((n1+n2)/2)**2-n2**2)/(n1**2-n2**2); #normalized propagation constant\n", - "\n", - "#case-3\n", - "#given \n", - "lambda1=1.3; #wavelength of operation in um\n", - "n1=1.5; #refractive index of core\n", - "n21=1.0; #refractive index of cladding\n", - "k0=2*3.14/lambda1; #constant in /m\n", - "b=0.5; #normalized propagation constant\n", - "k0=2*3.14/lambda1; #constant\n", - "beta1=k0*math.sqrt(n21**2+b*(n1**2-n21**2)); #propagation constant\n", - "\n", - "#RESULTS\n", - "print\"Propagation constant=\",round(beta,5),\"rad/um\"; #The answers vary due to round off error\n", - "print\"\\nPropagation constant=\",round(b1,5); #The answers vary due to round off error\n", - "print\"\\nPropagation constant=\",round(beta1,5),\"rad/um\"; #The answers vary due to round off error" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Propagation constant= 7.19801 rad/um\n", - "\n", - "Propagation constant= 0.49832\n", - "\n", - "Propagation constant= 6.15805 rad/um\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.10 , Page no:35" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "#case-1\n", - "n1=1.49; #refractive index of core\n", - "n2=1.46; #refractive index of cladding\n", - "c=3*10**5; #speed of light in Km/s\n", - "t1=n1/c; #time delay for one traveling along axis in s/Km\n", - "t2=(n1**2/n2)/c; #time delay for one traveling along path that is totally reflecting at the first interface in s/km\n", - "\n", - "#case-2\n", - "n11=1.47; #refractive index of core\n", - "n21=1.46; #refractive index of cladding\n", - "c1=3*10**5; #speed of light in Km/s\n", - "t11=n11/c1; #time delay for one traveling along axis in\n", - "t22=(n11**2/n21)/c1; #time delay for one traveling along path that is totally reflecting at the first interface\n", - "\n", - "\n", - "print\"time delay for traveling along axis =\",round(t1*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", - "print\"\\ntime delay for traveling along path that is totally reflecting at the first interface =\",round(t2*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", - "print\"\\ntime delay for traveling along axis =\",round(t11*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", - "print\"\\ntime delay for traveling along path that is totally reflecting at the first interface =\",round(t22*1e6,5),\"us/Km\"; #multiplication by 1e6 to convert the unit from s/Km to us/Km\n", - "#The answer provided in the textbook is wrong it has got wrong unit" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "time delay for traveling along axis = 4.96667 us/Km\n", - "\n", - "time delay for traveling along path that is totally reflecting at the first interface = 5.06872 us/Km\n", - "\n", - "time delay for traveling along axis = 4.9 us/Km\n", - "\n", - "time delay for traveling along path that is totally reflecting at the first interface = 4.93356 us/Km\n" - ] - } - ], - "prompt_number": 8 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight.ipynb b/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight.ipynb new file mode 100755 index 00000000..5e1116e7 --- /dev/null +++ b/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight.ipynb @@ -0,0 +1,825 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:81e7e778194095c491cf9fdf7aefef02501d247d9b184528d44cff4b23142c68" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 :Motion in a straight line" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "s=9 #miles\n", + "#since 45 min=3/4hr\n", + "t=3/4 #hr\n", + "\n", + "#CALCULATIONS\n", + "v=(s/t)\n", + "\n", + "#RESULTS\n", + "print \"Velocity in min/hr =\",round(v);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in min/hr = 12.0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "s=(1100*3)\n", + "\n", + "#RESULTS\n", + "print\"Distance in ft =\",round(s);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Distance in ft = 3300.0\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "s=1.5*10**11; #m\n", + "v=3*10**8; #ms\n", + "\n", + "#CALCULATIONS\n", + "t=(s/v)\n", + "\n", + "#Result\n", + "print\"Time in second =\",round(t),\"sec\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in second = 500.0 sec\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "s=270; #mils\n", + "t=4.5; #hours\n", + "t2=7; #hours\n", + "s2=300; #mi\n", + "\n", + "#CALCULATIONS\n", + "v=(s/t)\n", + "vt=(v*t2)\n", + "t3=(s2/v)\n", + "\n", + "#RESULTS\n", + "print\"Velocity in min/hr =\",round(v),\"mi/hr\";\n", + "print\"Distance in mile =\",round(vt),\"mils\";\n", + "print\"Time in hr =\",round(t3),\"hours\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in min/hr = 60.0 mi/hr\n", + "Distance in mile = 420.0 mils\n", + "Time in hr = 5.0 hours\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "s=1000; #distance in mile\n", + "\n", + "#CALCULATIONS\n", + "v=400+120; #velocity in mile/hr\n", + "t=s/v;\n", + "\n", + "#RESULTS\n", + "print\"Time in hr =\",round(t,1); " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in hr = 1.9\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 , Page no:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v1=100; #speed in km/hr\n", + "v2=60; #speed in km/hr\n", + "v3=80; #speed in km/hr\n", + "t1=2; #time in hr\n", + "t2=2; #time in hr\n", + "t3=1; #time in hr\n", + "\n", + "#CALCULATIONS\n", + "v=((v1*t1)+(v2*t2)+(v3*t3))/(t1+t2+t3)\n", + "\n", + "#RESULTS\n", + "print\"Velocity in km/hr =\",round(v);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in km/hr = 80.0\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=40; #velocity in ft/sec\n", + "t=10; #time in sec\n", + "\n", + "#CALCULATIONS\n", + "a=v/t;\n", + "v1=a*t\n", + "\n", + "#RESULTS\n", + "print\"Accelaration in ft/sec square =\",round(a);\n", + "print\"Velocity in ft/sec =\",round(v1);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Accelaration in ft/sec square = 4.0\n", + "Velocity in ft/sec = 40.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=30; #velocity in min/hr\n", + "v0=20; #velocity in min/hr\n", + "t=1.5; #time in sec\n", + "\n", + "#CALCULATIONS\n", + "a=((v-v0)/t); #calculating acc. \n", + "t1=(36-30)/a; #calculating time\n", + "\n", + "#RESULTS\n", + "print\"Accelaration in (min/h)/sec =\",round(a,3);\n", + "print\"Time in second =\",round(t1,2);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Accelaration in (min/h)/sec = 6.667\n", + "Time in second = 0.9\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=24; #velocity in m/sec\n", + "a=8; #acc. in m/sec square\n", + "\n", + "#CALCULATIONS\n", + "t=v/a; #using t=v/a\n", + "s=(1/2)*(a*t*t); #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Time in sec =\",round(t);\n", + "print\"Distance in metre =\",round(s);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in sec = 3.0\n", + "Distance in metre = 36.0\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.10 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=30; #velocity in m/sec\n", + "a=6; #acc. in m/sec square\n", + "\n", + "#CALCULATIONS\n", + "t=v/a; #using t=v/a\n", + "s=(1/2)*(a*t*t); #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Time in sec =\",round(t);\n", + "print\"Distance in metre =\",round(s);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in sec = 5.0\n", + "Distance in metre = 75.0\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.11 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=math.sqrt(2*5*600);\n", + "\n", + "#RESULTS\n", + "print\"Velocity in ft/sec =\",round(v);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in ft/sec = 77.0\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.12 , Page no:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=50; #velocity in m/sec\n", + "s=500; #distance in m\n", + "\n", + "#CALCULATIONS\n", + "a=((v*v)/(2*s));\n", + "\n", + "#RESULTS\n", + "print\"Acc. in m/sec square =\",round(a,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Acc. in m/sec square = 2.5\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13 , Page no:13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v=15; #velocity in m/sec\n", + "v0=30; #velocity in m/sec\n", + "a=-2; #acc. in m/sec square\n", + "\n", + "#CALCULATIONS\n", + "s=((v*v)-(v0*v0))/(2*a); #kinematical equation\n", + "v=0;\n", + "s1=(v*v)-(v0*v0)/(2*a);\n", + "\n", + "#RESULTS\n", + "print\"Distance in metre =\",round(s,2);\n", + "print\"Distance in metre =\",round(s1,2);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Distance in metre = 168.75\n", + "Distance in metre = 225.0\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.14 , Page no:13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "g=9.8; #gravitational constant in m/sec square\n", + "t=2.5; #time in sec\n", + "\n", + "#CALCULATIONS\n", + "v=g*t;\n", + "h=(1/2)*g*t*t; #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Velocity in m/sec =\",round(v,2);\n", + "print\"Height in m =\",round(h,3);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in m/sec = 24.5\n", + "Height in m = 30.625\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.15 , Page no:13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "g=32; #gravitational constant in ft/sec square\n", + "h=64; #height in ft\n", + "\n", + "#CALCULATIONS\n", + "t=(math.sqrt((2*h)/g)); #kinematical equation\n", + "v=g*t; #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Time in sec =\",round(t);\n", + "print\"Velocity in ft/sec =\",round(v);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in sec = 2.0\n", + "Velocity in ft/sec = 64.0\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.16 , Page no:13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "g=32; #gravitational constant in ft/sec square\n", + "h=100; #height in ft\n", + "\n", + "#CALCULATIONS\n", + "v=math.sqrt(2*g*h); #calculating velocity \n", + "\n", + "#RESULTS\n", + "print\"Velocity in ft/sec =\",round(v);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in ft/sec = 80.0\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.17 , Page no:13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "h=0.78; #height in m\n", + "g=9.8; #gravitational constant in m/sec square\n", + "v=0.5; #velocity in m/sec\n", + "\n", + "#CALCULATIONS\n", + "t=math.sqrt((2*h)/g); #calculating t\n", + "s=v*t; #calculating distance\n", + "\n", + "#RESULTS\n", + "print\"Time required in sec =\",round(t,3);\n", + "print\"Horizontal distance in m =\",round(s,3);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time required in sec = 0.399\n", + "Horizontal distance in m = 0.199\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.18 , Page no:14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v0=20; #velocity in ft/sec\n", + "g=32; #gravitational constant in ft/sec\n", + "t=2; #time in sec\n", + "\n", + "#CALCULATIONS\n", + "v=v0+(g*t); #kinematical equation\n", + "s=(v0*t)+(1/2)*g*t*t; #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Velocity in ft/sec =\",round(v);\n", + "print\"Distance in ft =\",round(s);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in ft/sec = 84.0\n", + "Distance in ft = 104.0\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.19 , Page no:14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "v0=20; #velocity in ft/sec\n", + "g=-32; #gravitational constant in ft/sec\n", + "t=0.5; #time in sec\n", + "\n", + "#CALCULATIONS\n", + "v=v0+(g*t); #kinematical equation\n", + "t=2; #time in sec\n", + "s=v0+(g*t); #kinematical equation\n", + "\n", + "#RESULTS\n", + "print\"Velocity in ft/sec =\",round(v);\n", + "print\"Distance in ft =\",round(s);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity in ft/sec = 4.0\n", + "Distance in ft = -44.0\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.20 , Page no:14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#initialisation of variables\n", + "h=6; #height in ft\n", + "g=32; #gravitaional constant in ft/sec square\n", + "\n", + "#CALCULATIONS\n", + "t=math.sqrt((2*h)/g); #calculating time\n", + "\n", + "#RESULTS\n", + "print\"Time in sec =\",round(t,3);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time in sec = 0.612\n" + ] + } + ], + "prompt_number": 20 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight_line.ipynb b/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight_line.ipynb deleted file mode 100755 index 5e1116e7..00000000 --- a/sample_notebooks/ManikandanD/Chapter_2_Motion_in_a_straight_line.ipynb +++ /dev/null @@ -1,825 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:81e7e778194095c491cf9fdf7aefef02501d247d9b184528d44cff4b23142c68" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 :Motion in a straight line" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "s=9 #miles\n", - "#since 45 min=3/4hr\n", - "t=3/4 #hr\n", - "\n", - "#CALCULATIONS\n", - "v=(s/t)\n", - "\n", - "#RESULTS\n", - "print \"Velocity in min/hr =\",round(v);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in min/hr = 12.0\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "s=(1100*3)\n", - "\n", - "#RESULTS\n", - "print\"Distance in ft =\",round(s);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Distance in ft = 3300.0\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "s=1.5*10**11; #m\n", - "v=3*10**8; #ms\n", - "\n", - "#CALCULATIONS\n", - "t=(s/v)\n", - "\n", - "#Result\n", - "print\"Time in second =\",round(t),\"sec\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in second = 500.0 sec\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "s=270; #mils\n", - "t=4.5; #hours\n", - "t2=7; #hours\n", - "s2=300; #mi\n", - "\n", - "#CALCULATIONS\n", - "v=(s/t)\n", - "vt=(v*t2)\n", - "t3=(s2/v)\n", - "\n", - "#RESULTS\n", - "print\"Velocity in min/hr =\",round(v),\"mi/hr\";\n", - "print\"Distance in mile =\",round(vt),\"mils\";\n", - "print\"Time in hr =\",round(t3),\"hours\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in min/hr = 60.0 mi/hr\n", - "Distance in mile = 420.0 mils\n", - "Time in hr = 5.0 hours\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "s=1000; #distance in mile\n", - "\n", - "#CALCULATIONS\n", - "v=400+120; #velocity in mile/hr\n", - "t=s/v;\n", - "\n", - "#RESULTS\n", - "print\"Time in hr =\",round(t,1); " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in hr = 1.9\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 , Page no:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v1=100; #speed in km/hr\n", - "v2=60; #speed in km/hr\n", - "v3=80; #speed in km/hr\n", - "t1=2; #time in hr\n", - "t2=2; #time in hr\n", - "t3=1; #time in hr\n", - "\n", - "#CALCULATIONS\n", - "v=((v1*t1)+(v2*t2)+(v3*t3))/(t1+t2+t3)\n", - "\n", - "#RESULTS\n", - "print\"Velocity in km/hr =\",round(v);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in km/hr = 80.0\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=40; #velocity in ft/sec\n", - "t=10; #time in sec\n", - "\n", - "#CALCULATIONS\n", - "a=v/t;\n", - "v1=a*t\n", - "\n", - "#RESULTS\n", - "print\"Accelaration in ft/sec square =\",round(a);\n", - "print\"Velocity in ft/sec =\",round(v1);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Accelaration in ft/sec square = 4.0\n", - "Velocity in ft/sec = 40.0\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=30; #velocity in min/hr\n", - "v0=20; #velocity in min/hr\n", - "t=1.5; #time in sec\n", - "\n", - "#CALCULATIONS\n", - "a=((v-v0)/t); #calculating acc. \n", - "t1=(36-30)/a; #calculating time\n", - "\n", - "#RESULTS\n", - "print\"Accelaration in (min/h)/sec =\",round(a,3);\n", - "print\"Time in second =\",round(t1,2);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Accelaration in (min/h)/sec = 6.667\n", - "Time in second = 0.9\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.9 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=24; #velocity in m/sec\n", - "a=8; #acc. in m/sec square\n", - "\n", - "#CALCULATIONS\n", - "t=v/a; #using t=v/a\n", - "s=(1/2)*(a*t*t); #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Time in sec =\",round(t);\n", - "print\"Distance in metre =\",round(s);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in sec = 3.0\n", - "Distance in metre = 36.0\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.10 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=30; #velocity in m/sec\n", - "a=6; #acc. in m/sec square\n", - "\n", - "#CALCULATIONS\n", - "t=v/a; #using t=v/a\n", - "s=(1/2)*(a*t*t); #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Time in sec =\",round(t);\n", - "print\"Distance in metre =\",round(s);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in sec = 5.0\n", - "Distance in metre = 75.0\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.11 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=math.sqrt(2*5*600);\n", - "\n", - "#RESULTS\n", - "print\"Velocity in ft/sec =\",round(v);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in ft/sec = 77.0\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.12 , Page no:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=50; #velocity in m/sec\n", - "s=500; #distance in m\n", - "\n", - "#CALCULATIONS\n", - "a=((v*v)/(2*s));\n", - "\n", - "#RESULTS\n", - "print\"Acc. in m/sec square =\",round(a,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Acc. in m/sec square = 2.5\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.13 , Page no:13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v=15; #velocity in m/sec\n", - "v0=30; #velocity in m/sec\n", - "a=-2; #acc. in m/sec square\n", - "\n", - "#CALCULATIONS\n", - "s=((v*v)-(v0*v0))/(2*a); #kinematical equation\n", - "v=0;\n", - "s1=(v*v)-(v0*v0)/(2*a);\n", - "\n", - "#RESULTS\n", - "print\"Distance in metre =\",round(s,2);\n", - "print\"Distance in metre =\",round(s1,2);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Distance in metre = 168.75\n", - "Distance in metre = 225.0\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.14 , Page no:13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "g=9.8; #gravitational constant in m/sec square\n", - "t=2.5; #time in sec\n", - "\n", - "#CALCULATIONS\n", - "v=g*t;\n", - "h=(1/2)*g*t*t; #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Velocity in m/sec =\",round(v,2);\n", - "print\"Height in m =\",round(h,3);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in m/sec = 24.5\n", - "Height in m = 30.625\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.15 , Page no:13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "g=32; #gravitational constant in ft/sec square\n", - "h=64; #height in ft\n", - "\n", - "#CALCULATIONS\n", - "t=(math.sqrt((2*h)/g)); #kinematical equation\n", - "v=g*t; #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Time in sec =\",round(t);\n", - "print\"Velocity in ft/sec =\",round(v);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in sec = 2.0\n", - "Velocity in ft/sec = 64.0\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.16 , Page no:13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "g=32; #gravitational constant in ft/sec square\n", - "h=100; #height in ft\n", - "\n", - "#CALCULATIONS\n", - "v=math.sqrt(2*g*h); #calculating velocity \n", - "\n", - "#RESULTS\n", - "print\"Velocity in ft/sec =\",round(v);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in ft/sec = 80.0\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.17 , Page no:13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "h=0.78; #height in m\n", - "g=9.8; #gravitational constant in m/sec square\n", - "v=0.5; #velocity in m/sec\n", - "\n", - "#CALCULATIONS\n", - "t=math.sqrt((2*h)/g); #calculating t\n", - "s=v*t; #calculating distance\n", - "\n", - "#RESULTS\n", - "print\"Time required in sec =\",round(t,3);\n", - "print\"Horizontal distance in m =\",round(s,3);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time required in sec = 0.399\n", - "Horizontal distance in m = 0.199\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.18 , Page no:14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v0=20; #velocity in ft/sec\n", - "g=32; #gravitational constant in ft/sec\n", - "t=2; #time in sec\n", - "\n", - "#CALCULATIONS\n", - "v=v0+(g*t); #kinematical equation\n", - "s=(v0*t)+(1/2)*g*t*t; #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Velocity in ft/sec =\",round(v);\n", - "print\"Distance in ft =\",round(s);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in ft/sec = 84.0\n", - "Distance in ft = 104.0\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.19 , Page no:14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "v0=20; #velocity in ft/sec\n", - "g=-32; #gravitational constant in ft/sec\n", - "t=0.5; #time in sec\n", - "\n", - "#CALCULATIONS\n", - "v=v0+(g*t); #kinematical equation\n", - "t=2; #time in sec\n", - "s=v0+(g*t); #kinematical equation\n", - "\n", - "#RESULTS\n", - "print\"Velocity in ft/sec =\",round(v);\n", - "print\"Distance in ft =\",round(s);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity in ft/sec = 4.0\n", - "Distance in ft = -44.0\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.20 , Page no:14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#initialisation of variables\n", - "h=6; #height in ft\n", - "g=32; #gravitaional constant in ft/sec square\n", - "\n", - "#CALCULATIONS\n", - "t=math.sqrt((2*h)/g); #calculating time\n", - "\n", - "#RESULTS\n", - "print\"Time in sec =\",round(t,3);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time in sec = 0.612\n" - ] - } - ], - "prompt_number": 20 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ManikandanD/chapter1.ipynb b/sample_notebooks/ManikandanD/chapter1.ipynb new file mode 100755 index 00000000..e79571af --- /dev/null +++ b/sample_notebooks/ManikandanD/chapter1.ipynb @@ -0,0 +1,256 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:d769dfed1de81f32faa9bbbfcfead0c5e629ef3b47c5b247ff782d0972a27a01" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Bonding in Solids" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3 , Page no:15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "r=2; #in angstrom(distance)\n", + "e=1.6E-19; # in C (charge of electron)\n", + "E_o= 8.85E-12;# absolute premittivity\n", + "\n", + "#calculate\n", + "r=2*1*10**-10; # since r is in angstrom\n", + "V=-e**2/(4*3.14*E_o*r); # calculate potential\n", + "V1=V/e; # changing to eV\n", + "\n", + "#result\n", + "print \"\\nThe potential energy is V = \",V,\"J\";\n", + "print \"In electron-Volt V = \",round(V,3),\"eV\"; \n", + "print \"Note: the answer in the book is wrong due to calculation mistake\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "The potential energy is V = -1.15153477995e-18 J\n", + "In electron-Volt V = -0.0 eV\n", + "Note: the answer in the book is wrong due to calculation mistake\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 , Page no:15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "from __future__ import division\n", + "#given\n", + "r0=0.236; #in nanometer(interionic distance)\n", + "e=1.6E-19; # in C (charge of electron)\n", + "E_o= 8.85E-12;# absolute premittivity\n", + "N=8; # Born constant\n", + "IE=5.14;# in eV (ionisation energy of sodium)\n", + "EA=3.65;# in eV (electron affinity of Chlorine)\n", + "pi=3.14; # value of pi used in the solution\n", + "\n", + "#calculate\n", + "r0=r0*1E-9; # since r is in nanometer\n", + "PE=(e**2/(4*pi*E_o*r0))*(1-1/N); # calculate potential energy\n", + "PE=PE/e; #changing unit from J to eV\n", + "NE=IE-EA;# calculation of Net energy\n", + "BE=PE-NE;# calculation of Bond Energy\n", + "\n", + "#result\n", + "print\"The potential energy is PE= \",round(PE,2),\"eV\";\n", + "print\"The net energy is NE= \",round(NE,2),\"eV\";\n", + "print\"The bond energy is BE= \",round(BE,2),\"eV\";\n", + "# Note: (1)-In order to make the answer prcatically feasible and avoid the unusual answer, I have used r_0=0.236 nm instead of 236 nm. because using this value will give very much irrelevant answer.\n", + "# Note: (2) There is slight variation in the answer due to round off." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The potential energy is PE= 5.34 eV\n", + "The net energy is NE= 1.49 eV\n", + "The bond energy is BE= 3.85 eV\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5 , Page no:16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "r_0=.41; #in mm(lattice constant)\n", + "e=1.6E-19; #in C (charge of electron)\n", + "E_o= 8.85E-12; #absolute premittivity\n", + "n=0.5; #repulsive exponent value\n", + "alpha=1.76; #Madelung constant\n", + "pi=3.14; # value of pi used in the solution\n", + "\n", + "#calculate\n", + "r=.41*1E-3; #since r is in mm\n", + "Beta=72*pi*E_o*r**4/(alpha*e**2*(n-1)); #calculation compressibility\n", + "\n", + "#result\n", + "print\"The compressibility is\tBeta=\",round(Beta);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The compressibility is\tBeta= -2.50967916144e+15\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 , Page no:16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "r_0=3.56; #in Angstrom\n", + "e=1.6E-19; #in C (charge of electron)\n", + "IE=3.89; #in eV (ionisation energy of Cs)\n", + "EA=-3.61; #in eV (electron affinity of Cl)\n", + "n=10.5; #Born constant\n", + "E_o= 8.85E-12; #absolute premittivity\n", + "alpha=1.763; #Madelung constant\n", + "pi=3.14; #value of pi used in the solution\n", + "\n", + "#calculate\n", + "r_0=r_0*1E-10; #since r is in nanometer\n", + "U=-alpha*(e**2/(4*pi*E_o*r_0))*(1-1/n); #calculate potential energy\n", + "U=U/e; #changing unit from J to eV\n", + "ACE=U+EA+IE; #calculation of atomic cohesive energy\n", + "\n", + "#result\n", + "print\"The ionic cohesive energy is \",round(U),\"eV\";\n", + "print\"The atomic cohesive energy is\",round(ACE),\"eV\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ionic cohesive energy is -6.0 eV\n", + "The atomic cohesive energy is -6.0 eV\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7 , Page no:17" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "r_0=2.81; #in Angstrom\n", + "e=1.6E-19; #in C (charge of electron)\n", + "n=9; #Born constant\n", + "E_o= 8.85E-12; #absolute premittivity\n", + "alpha=1.748; #Madelung constant\n", + "pi=3.14; #value of pi used in the solution\n", + "\n", + "#calculate\n", + "r_0=r_0*1E-10; #since r is in nanometer\n", + "V=-alpha*(e**2/(4*pi*E_o*r_0))*(1-1/n); #calculate potential energy\n", + "V=V/e; #changing unit from J to eV\n", + "V_1=V/2; #Since only half of the energy contribute per ion to the cohecive energy therfore\n", + "\n", + "#result\n", + "print\"The potential energy is V=\",round(V,2),\"eV\";\n", + "print\"The energy contributing per ions to the cohesive energy is \",round(V_1,2),\"eV\";" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The potential energy is V= -7.96 eV\n", + "The energy contributing per ions to the cohesive energy is -3.98 eV\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ManikandanD/chapter_1_.ipynb b/sample_notebooks/ManikandanD/chapter_1_.ipynb deleted file mode 100755 index e79571af..00000000 --- a/sample_notebooks/ManikandanD/chapter_1_.ipynb +++ /dev/null @@ -1,256 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:d769dfed1de81f32faa9bbbfcfead0c5e629ef3b47c5b247ff782d0972a27a01" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Bonding in Solids" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3 , Page no:15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "r=2; #in angstrom(distance)\n", - "e=1.6E-19; # in C (charge of electron)\n", - "E_o= 8.85E-12;# absolute premittivity\n", - "\n", - "#calculate\n", - "r=2*1*10**-10; # since r is in angstrom\n", - "V=-e**2/(4*3.14*E_o*r); # calculate potential\n", - "V1=V/e; # changing to eV\n", - "\n", - "#result\n", - "print \"\\nThe potential energy is V = \",V,\"J\";\n", - "print \"In electron-Volt V = \",round(V,3),\"eV\"; \n", - "print \"Note: the answer in the book is wrong due to calculation mistake\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "The potential energy is V = -1.15153477995e-18 J\n", - "In electron-Volt V = -0.0 eV\n", - "Note: the answer in the book is wrong due to calculation mistake\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4 , Page no:15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "from __future__ import division\n", - "#given\n", - "r0=0.236; #in nanometer(interionic distance)\n", - "e=1.6E-19; # in C (charge of electron)\n", - "E_o= 8.85E-12;# absolute premittivity\n", - "N=8; # Born constant\n", - "IE=5.14;# in eV (ionisation energy of sodium)\n", - "EA=3.65;# in eV (electron affinity of Chlorine)\n", - "pi=3.14; # value of pi used in the solution\n", - "\n", - "#calculate\n", - "r0=r0*1E-9; # since r is in nanometer\n", - "PE=(e**2/(4*pi*E_o*r0))*(1-1/N); # calculate potential energy\n", - "PE=PE/e; #changing unit from J to eV\n", - "NE=IE-EA;# calculation of Net energy\n", - "BE=PE-NE;# calculation of Bond Energy\n", - "\n", - "#result\n", - "print\"The potential energy is PE= \",round(PE,2),\"eV\";\n", - "print\"The net energy is NE= \",round(NE,2),\"eV\";\n", - "print\"The bond energy is BE= \",round(BE,2),\"eV\";\n", - "# Note: (1)-In order to make the answer prcatically feasible and avoid the unusual answer, I have used r_0=0.236 nm instead of 236 nm. because using this value will give very much irrelevant answer.\n", - "# Note: (2) There is slight variation in the answer due to round off." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The potential energy is PE= 5.34 eV\n", - "The net energy is NE= 1.49 eV\n", - "The bond energy is BE= 3.85 eV\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5 , Page no:16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "r_0=.41; #in mm(lattice constant)\n", - "e=1.6E-19; #in C (charge of electron)\n", - "E_o= 8.85E-12; #absolute premittivity\n", - "n=0.5; #repulsive exponent value\n", - "alpha=1.76; #Madelung constant\n", - "pi=3.14; # value of pi used in the solution\n", - "\n", - "#calculate\n", - "r=.41*1E-3; #since r is in mm\n", - "Beta=72*pi*E_o*r**4/(alpha*e**2*(n-1)); #calculation compressibility\n", - "\n", - "#result\n", - "print\"The compressibility is\tBeta=\",round(Beta);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The compressibility is\tBeta= -2.50967916144e+15\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6 , Page no:16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "r_0=3.56; #in Angstrom\n", - "e=1.6E-19; #in C (charge of electron)\n", - "IE=3.89; #in eV (ionisation energy of Cs)\n", - "EA=-3.61; #in eV (electron affinity of Cl)\n", - "n=10.5; #Born constant\n", - "E_o= 8.85E-12; #absolute premittivity\n", - "alpha=1.763; #Madelung constant\n", - "pi=3.14; #value of pi used in the solution\n", - "\n", - "#calculate\n", - "r_0=r_0*1E-10; #since r is in nanometer\n", - "U=-alpha*(e**2/(4*pi*E_o*r_0))*(1-1/n); #calculate potential energy\n", - "U=U/e; #changing unit from J to eV\n", - "ACE=U+EA+IE; #calculation of atomic cohesive energy\n", - "\n", - "#result\n", - "print\"The ionic cohesive energy is \",round(U),\"eV\";\n", - "print\"The atomic cohesive energy is\",round(ACE),\"eV\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ionic cohesive energy is -6.0 eV\n", - "The atomic cohesive energy is -6.0 eV\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7 , Page no:17" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "r_0=2.81; #in Angstrom\n", - "e=1.6E-19; #in C (charge of electron)\n", - "n=9; #Born constant\n", - "E_o= 8.85E-12; #absolute premittivity\n", - "alpha=1.748; #Madelung constant\n", - "pi=3.14; #value of pi used in the solution\n", - "\n", - "#calculate\n", - "r_0=r_0*1E-10; #since r is in nanometer\n", - "V=-alpha*(e**2/(4*pi*E_o*r_0))*(1-1/n); #calculate potential energy\n", - "V=V/e; #changing unit from J to eV\n", - "V_1=V/2; #Since only half of the energy contribute per ion to the cohecive energy therfore\n", - "\n", - "#result\n", - "print\"The potential energy is V=\",round(V,2),\"eV\";\n", - "print\"The energy contributing per ions to the cohesive energy is \",round(V_1,2),\"eV\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The potential energy is V= -7.96 eV\n", - "The energy contributing per ions to the cohesive energy is -3.98 eV\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MaulikRathod/MaulikRathod_version_backup/ch11.ipynb b/sample_notebooks/MaulikRathod/MaulikRathod_version_backup/ch11.ipynb new file mode 100755 index 00000000..3b3ec8a7 --- /dev/null +++ b/sample_notebooks/MaulikRathod/MaulikRathod_version_backup/ch11.ipynb @@ -0,0 +1,745 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:f1e32f78d016d65eaf62d619ce157e62f2d402e55bfc70a9a046c3e8d919d007" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11 : Pumping Machinery" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.1 Page No : 223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variables\n", + "\n", + "import math \n", + "h= 75. \t#ft\n", + "e= 0.75\n", + "k= 0.01\n", + "Q= 3000. \t#gal/min\n", + "k1= 1.2\n", + "N= 1500.\n", + "g= 32.2 \t#ft/sec**2\n", + "D= 0.836 \t#ft\n", + "\n", + "#CALCULATIONS\n", + "W= h/e\n", + "v1= math.sqrt((W-h)/k)\n", + "Q1= Q/374.06\n", + "f1= Q1/(k1*D**2)\n", + "u1= math.pi*D*N/60\n", + "w1= W*g/u1\n", + "B= math.degrees(math.atan((f1/(u1-w1))))\n", + "\n", + "#RESULTS\n", + "print 'Diameter of impeller = %.3f ft '%(D)\n", + "print ' Blade angle at outlet edge of impeller = %.f degrees '%(B)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of impeller = 0.836 ft \n", + " Blade angle at outlet edge of impeller = 30 degrees \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.3 Page No : 226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "V= 150. \t#ft**3/sec\n", + "A1= 750. \t#r.p.m\n", + "di= 21. \t#in\n", + "do= 30. \t#in\n", + "v= 50. \t#ft/sec\n", + "A= 70. \t#degrees\n", + "w= 4.\t#in\n", + "p= 30. \t#per cent\n", + "p1= 25. \t#per cent\n", + "sv= 12.8 \t#ft**3/lb\n", + "g= 32.2 \t#ft/sec**2\n", + "\n", + "#CALCULATIONS\n", + "u= A1*2*math.pi*di/(24*60)\n", + "u1= A1*2*math.pi*do/(24*60)\n", + "f1= V/(math.pi*(do/12)*(1./3))\n", + "w1= u1-f1*1/math.tan(math.radians((A)))\n", + "v1= math.sqrt(f1**2+w1**2)\n", + "P= (u1**2+v**2-(f1**2/(math.sin(math.radians(A)))**2))/(2*g)\n", + "h= 30*v1**2/(100*2*g)\n", + "Nh= v1**2/(20*2*g)\n", + "Prt= P+Nh\n", + "W= u1*w1/g\n", + "e= Prt*100/W\n", + "Power= Prt*V/(sv*550)\n", + "\n", + "#RESULTS\n", + "print 'Total pressure rise = %.1f ft of air'%(Prt)\n", + "print ' manometric efficiency = %.1f percent'%(e)\n", + "print ' Power = %.2f hp '%(Power)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total pressure rise = 137.9 ft of air\n", + " manometric efficiency = 58.5 percent\n", + " Power = 2.94 hp \n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.4 Page No : 228" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "g= 32.2 \t#ft/sec**2\n", + "u1= 90. \t#ft/sec\n", + "w1= 70. \t#ft\n", + "e= 0.8\n", + "h1= 10. \t#ft\n", + "h2= 16. \t#ft\n", + "h3= 5. \t#ft\n", + "k= 2./5\n", + "f1= 20. \t#ft/sec\n", + "f= 18. \t#ft/sec\n", + "a= 45. \t #degrees\n", + "x1= 164.4 \t#ft\n", + "\n", + "#CALCULATIONS\n", + "Hm= u1*w1/g\n", + "Hm1= e*Hm\n", + "lh= Hm-Hm1-h1-h2-h3\n", + "vg= k*math.sqrt(f1**2+w1**2)\n", + "pr= ((f**2+u1**2-f1**2/(math.sin(math.radians(a)))**2)/(2*g))-h2\n", + "pr1= x1-pr\n", + "ge= pr1*g*2*100/(vg/k)**2\n", + "\n", + "#RESULTS\n", + "print 'manometer Head = %.1f ft '%(Hm1)\n", + "print ' outlet velocity from guides = %.1f ft/sec '%(vg)\n", + "print ' Pressure rise through impeller only = %.1f ft '%(pr)\n", + "print ' Guide balde efficiency = %.f per cent '%(ge)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "manometer Head = 156.5 ft \n", + " outlet velocity from guides = 29.1 ft/sec \n", + " Pressure rise through impeller only = 102.4 ft \n", + " Guide balde efficiency = 75 per cent \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.6 Page No : 231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "D1= 7.5 \t#in\n", + "Q1= 850. \t#gal/min\n", + "p1= 62.4 \t#lb/ft**3\n", + "N1= 1800.\n", + "D2= 15. \t#in\n", + "Q2= 12000. \t#gal/min\n", + "p2= 64. \t#lb/ft**3\n", + "N1= 1800. \t#r.p.m \n", + "H1= 14. \t#lb/ft**2\n", + "\n", + "#CALCULATIONS\n", + "N2= Q2*N1*(D1)**3/(Q1*D2**3)\n", + "P1= p1*H1/144\n", + "P2= P1*N2**2*D2**2*p2/(N1**2*p1*D1**2)\n", + "\n", + "#RESULTS\n", + "print 'N2 = %.f r.p.m '%(N2+4)\n", + "print ' P2 = %.f lb/in**2 '%(P2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "N2 = 3180 r.p.m \n", + " P2 = 78 lb/in**2 \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.8 Page No : 234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "#initialisation of variables\n", + "r= 5.\n", + "\n", + "#CALCULATIONS\n", + "sr= r**2\n", + "sr1= r**2/r\n", + "\n", + "#RESULTS\n", + "print 'Corresponding ratio = %.f '%(sr)\n", + "print ' Corresponding ratio = %.f '%(sr1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Corresponding ratio = 25 \n", + " Corresponding ratio = 5 \n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.9 Page No : 236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "e= 0.88\n", + "w= 1.25 \t#in\n", + "d= 10. \t#in\n", + "q= 630. \t#gal/min\n", + "a= 40. \t#degrees\n", + "g= 32.2 \t#ft/sec**2\n", + "e1= 0.83\n", + "\n", + "#CALCULATIONS\n", + "Q= q/(6.24*60)\n", + "f1= Q/(e*math.pi*(d/12)*(w/12))\n", + "u1= 1000*(w*4/12)*2*math.pi/60\n", + "w1= u1-f1*1/math.tan(math.radians(a))\n", + "W= u1*w1/g\n", + "lr= (f1**2+u1**2-f1**2/(math.sin(math.radians(a)))**2)/(2*g)\n", + "mh= e1*W\n", + "p= mh-lr\n", + "v1= math.sqrt(f1**2+w1**2)\n", + "ke= v1**2/(2*g)\n", + "pke= p*100/ke\n", + "me= 100*lr/W\n", + "\n", + "#RESULTS\n", + "print 'Velocity of flow = %.f ft/sec'%(f1)\n", + "print ' Work done = %.1f ft-lb/lb'%(W)\n", + "print ' manometric efficiency = %.1f ft'%(mh)\n", + "print ' Pressure recovered = %.1f ft head'%(p)\n", + "print ' Kinetic energy discharge = %.f ft-lb/lb'%(ke)\n", + "print ' Percentage of kinetic energy recovered = %.1f per cent'%(pke)\n", + "print ' manometric efficiency = %d percent'%(me)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Velocity of flow = 7 ft/sec\n", + " Work done = 47.8 ft-lb/lb\n", + " manometric efficiency = 39.7 ft\n", + " Pressure recovered = 11.2 ft head\n", + " Kinetic energy discharge = 20 ft-lb/lb\n", + " Percentage of kinetic energy recovered = 55.7 per cent\n", + " manometric efficiency = 59 percent\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.10 Page No : 239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "W1= 7640. \t#gal/min\n", + "W2= 11400. \t#gal/min\n", + "Hm= 63. \t#ft\n", + "Hm1= 80. \t#ft\n", + "ep1= 72. \t#per cent\n", + "ep2= 76. \t#per cent\n", + "\n", + "#CALCULATIONS\n", + "whp1= W1*Hm/(60*550)\n", + "whp2= W2*Hm1/(60*550)\n", + "bhp1= whp1*100/ep1\n", + "bhp2= whp2*100/ep2\n", + "w1= W2/10\n", + "\n", + "#RESULTS\n", + "print 'For both pumps discharge = %.f gal/min against an 80-ft head'%(W2)\n", + "print ' delivery from one pump = %.1f h.p '%(bhp1)\n", + "print ' delivery from two pumps = %.1f h.p '%(bhp2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For both pumps discharge = 11400 gal/min against an 80-ft head\n", + " delivery from one pump = 20.3 h.p \n", + " delivery from two pumps = 36.4 h.p \n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.11 Page No : 241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "h= 94. \t#ft\n", + "w= 62.4 \t#lb/ft**3\n", + "e= 0.58\n", + "p= 73.5 \t#per cent\n", + "\n", + "#CALCULATIONS\n", + "WHP= h*e*w/550\n", + "BHP= WHP/(p/100)\n", + "\n", + "#RESULTS\n", + "print 'W.H.P= %.2f h.p'%(WHP)\n", + "print ' Brake horse power= %.1f'%(BHP)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "W.H.P= 6.19 h.p\n", + " Brake horse power= 8.4\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.12 Page No : 243" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "sl= 12. \t#ft\n", + "l= 20. \t#ft\n", + "d= 4. \t#in\n", + "dp= 6. \t#in\n", + "lst= 18. \t#in\n", + "k= 0.025\n", + "H= 32. \t#ft\n", + "g= 32.2 \t#ft/sec**2\n", + "pf= 6. \t#ft\n", + "a= 33.83 \n", + "a1= 9.53\n", + "\n", + "#CALCULATIONS\n", + "A= math.sqrt((H-sl-d)*g/a)*a1\n", + "Q= 2*math.pi*(dp/12)**2*lst/(12*4*60)\n", + "v= Q/(math.pi*(d/12)**2/4)\n", + "kh= v**2/(2*g)\n", + "fh= k*l*v**2*12/(2*g*d)\n", + "N= math.sqrt((H-sl-pf)/(kh+fh))\n", + "\n", + "#RESULTS\n", + "print 'premissible speed = %.1f r.p.m'%(A)\n", + "print ' maximum premissible speed = %.1f r.p.m'%(N)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "premissible speed = 37.2 r.p.m\n", + " maximum premissible speed = 168.8 r.p.m\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.13 Page No : 245" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "b= 6. \t#in\n", + "s= 12. \t #in\n", + "d= 4. \t #in\n", + "a1= 30. \t#degrees\n", + "a2= 90. \t#degrees\n", + "a3= 120. \t#degrees\n", + "N= 120. \t#r.p.m\n", + "n= 4.\n", + "#calculations\n", + "A= 2*math.pi*N/60\n", + "V= math.pi*(b/12)**2*n/4\n", + "v= (b/12)**2*A*(b/12)/(d/12)**2\n", + "Q1= v*math.pi*(d/12)**2*math.sin(math.radians(a1))/4\n", + "Q2= v*math.pi*(d/12)**2*math.sin(math.radians(a2))/4\n", + "Q3= v*math.pi*(d/12)**2*math.sin(math.radians(a3))/4\n", + "Q4= V-Q1\n", + "Q5= Q2-V\n", + "Q6= Q3-V\n", + "a4= math.degrees(math.asin(V/(v*math.pi*(d/12)**2)))+a1\n", + "A= 180-a4\n", + "\n", + "#RESULTS\n", + "print 'rate of flow at a1 = %.3f cuses'%(Q4)\n", + "print ' rate of flow at a2 = %.3f cuses'%(Q5)\n", + "print ' rate of flow at a3 = %.3f cuses'%(Q6)\n", + "print ' crak angle = %.1f degrees'%(a4)\n", + "print ' crak angle = %.1f degrees'%(A)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "rate of flow at a1 = 0.169 cuses\n", + " rate of flow at a2 = 0.448 cuses\n", + " rate of flow at a3 = 0.283 cuses\n", + " crak angle = 39.2 degrees\n", + " crak angle = 140.8 degrees\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.14 Page No : 247" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "\n", + "#initialisation of variables\n", + "n= 2. \t#strokes/sec\n", + "dp= 6. \t#in\n", + "ds= 18. \t#in\n", + "ds1=4. \t#in\n", + "l= 20. \t#ft\n", + "l1= 20. \t#ft\n", + "f= 0.008\n", + "la= 5. \t#ft\n", + "A= 60. \t#r.p.m\n", + "f= 0.008\n", + "w= 62.4 \t#lb/ft**3\n", + "g=32.2\n", + "\n", + "#CALCULATIONS\n", + "V= math.pi*(ds/12)*n*(dp/12)**2/4\n", + "vmp= 2*math.pi*A*(ds/24)/60\n", + "vmp1= vmp*(dp**2/ds1**2)\n", + "hfmax= 4*f*(l-la)*vmp1**2/(2*g*ds1/12)\n", + "H1= round(2*hfmax/3,1)\n", + "H2= H1*13\n", + "Wls= (H1+H2)*w*math.pi/16*1.5*2\n", + "mv= V/(math.pi*(ds1/12)**2/4)\n", + "lh= round(4*f*(l-la)*mv**2/(2*g*(ds1/12)),2)\n", + "lhf= 12*lh\n", + "Wls1= (lh+13.21)*w*math.pi*1.5/16 *2 \n", + "WS= Wls-Wls1\n", + "\n", + "#RESULTS\n", + "print 'Work lost per second= %.f ft lb/sec'%(Wls)\n", + "print ' Work saved per second = %.f ft-lb/sec'%(WS)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Work lost per second= 875 ft lb/sec\n", + " Work saved per second = 352 ft-lb/sec\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.15 Page No : 248" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "d= 7.5 \t#in\n", + "s= 15. \t#in\n", + "l= 36. \t#ft\n", + "h1= 34. \t#ft\n", + "h2= 12. \t#ft\n", + "L= 10. \t #ft\n", + "g= 32.2 \t#ft/sec**2\n", + "f= 0.008\n", + "l1= 20. \t#ft\n", + "d1= 4. \t#in\n", + "h3= 110. \t#ft\n", + "w= 62.4 \t#lb/ft**3\n", + "l2= 180. \t#ft\n", + "\n", + "#CALCULATIONS\n", + "Q= (math.pi/4)*(d)**2*(s/12)*2*(l/60)/144\n", + "v= Q/((math.pi/4)*(d1/12)**2)\n", + "a= (d/4)**2*(d/12)*(l*2*math.pi/60)**2\n", + "H= h1-h2-(L*a/g)-(v**2*0.5/g)-(4*f*l1*v**2/(2*g*(d1/12)))\n", + "H1= h1+h3+(L*a/g)+(v**2*0.5/g)+(4*f*l2*v**2/(2*g*(d1/12)))\n", + "dh= (H1-H)*w/144\n", + "NP= dh*(math.pi/4)*d**2\n", + "\n", + "#RESULTS\n", + "print 'Head at piston = %.2f ft of water absolute'%(H)\n", + "print ' Head at piston = %.2f ft of water absolute'%(H1)\n", + "print ' Difference on head of piston = %.f lb/in**2'%(dh)\n", + "print ' Net load on piston = %.f lb'%(NP)\n", + "\n", + "#The answer is a bit different due to rounding off error in textbook\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Head at piston = 11.04 ft of water absolute\n", + " Head at piston = 161.59 ft of water absolute\n", + " Difference on head of piston = 65 lb/in**2\n", + " Net load on piston = 2882 lb\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 11.16 Page No : 250" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "import math \n", + "from numpy import *\n", + "from numpy.linalg import *\n", + "\n", + "#initialisation of variables\n", + "f= 0.009\n", + "dc= 3.5 \t#in\n", + "ds= 6. \t#in\n", + "r= 0.25\n", + "sl= 8. \t#ft\n", + "d= 2.5 \t#in\n", + "l= 14. \t#ft\n", + "el= 8. \t#ft\n", + "ed= 22.5 \t#in\n", + "ph= 4. \t#ft\n", + "g= 32.2 \t#ft/sec**2\n", + "f= 0.009\n", + "\n", + "#CALCULATIONS\n", + "BC= el+l\n", + "v= math.sqrt(BC*g/(l*(d/2)*(r)*(dc/d)**2))*9.55\n", + "vec=roots([2,1/r,-1])\n", + "H1= 77\n", + "MV= math.sqrt(BC*g/(l*(d/2)*(r)*(dc/d)**2))*r*(math.sin(math.radians(H1))+(math.sin(math.radians(2*H1))/8))\n", + "mvp= MV*dc**2/d**2\n", + "hf= 4*f*(sl+l)*mvp**2/(2*g*(d/12))\n", + "\n", + "#RESULTS\n", + "print 'pump speed = %.1f r.p.m'%(v)\n", + "print ' Friction head = %.3f ft'%(hf)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "pump speed = 86.8 r.p.m\n", + " Friction head = 1.240 ft\n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MaulikRathod/ch11.ipynb b/sample_notebooks/MaulikRathod/ch11.ipynb deleted file mode 100755 index 3b3ec8a7..00000000 --- a/sample_notebooks/MaulikRathod/ch11.ipynb +++ /dev/null @@ -1,745 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:f1e32f78d016d65eaf62d619ce157e62f2d402e55bfc70a9a046c3e8d919d007" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11 : Pumping Machinery" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.1 Page No : 223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variables\n", - "\n", - "import math \n", - "h= 75. \t#ft\n", - "e= 0.75\n", - "k= 0.01\n", - "Q= 3000. \t#gal/min\n", - "k1= 1.2\n", - "N= 1500.\n", - "g= 32.2 \t#ft/sec**2\n", - "D= 0.836 \t#ft\n", - "\n", - "#CALCULATIONS\n", - "W= h/e\n", - "v1= math.sqrt((W-h)/k)\n", - "Q1= Q/374.06\n", - "f1= Q1/(k1*D**2)\n", - "u1= math.pi*D*N/60\n", - "w1= W*g/u1\n", - "B= math.degrees(math.atan((f1/(u1-w1))))\n", - "\n", - "#RESULTS\n", - "print 'Diameter of impeller = %.3f ft '%(D)\n", - "print ' Blade angle at outlet edge of impeller = %.f degrees '%(B)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diameter of impeller = 0.836 ft \n", - " Blade angle at outlet edge of impeller = 30 degrees \n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.3 Page No : 226" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "V= 150. \t#ft**3/sec\n", - "A1= 750. \t#r.p.m\n", - "di= 21. \t#in\n", - "do= 30. \t#in\n", - "v= 50. \t#ft/sec\n", - "A= 70. \t#degrees\n", - "w= 4.\t#in\n", - "p= 30. \t#per cent\n", - "p1= 25. \t#per cent\n", - "sv= 12.8 \t#ft**3/lb\n", - "g= 32.2 \t#ft/sec**2\n", - "\n", - "#CALCULATIONS\n", - "u= A1*2*math.pi*di/(24*60)\n", - "u1= A1*2*math.pi*do/(24*60)\n", - "f1= V/(math.pi*(do/12)*(1./3))\n", - "w1= u1-f1*1/math.tan(math.radians((A)))\n", - "v1= math.sqrt(f1**2+w1**2)\n", - "P= (u1**2+v**2-(f1**2/(math.sin(math.radians(A)))**2))/(2*g)\n", - "h= 30*v1**2/(100*2*g)\n", - "Nh= v1**2/(20*2*g)\n", - "Prt= P+Nh\n", - "W= u1*w1/g\n", - "e= Prt*100/W\n", - "Power= Prt*V/(sv*550)\n", - "\n", - "#RESULTS\n", - "print 'Total pressure rise = %.1f ft of air'%(Prt)\n", - "print ' manometric efficiency = %.1f percent'%(e)\n", - "print ' Power = %.2f hp '%(Power)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total pressure rise = 137.9 ft of air\n", - " manometric efficiency = 58.5 percent\n", - " Power = 2.94 hp \n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.4 Page No : 228" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "g= 32.2 \t#ft/sec**2\n", - "u1= 90. \t#ft/sec\n", - "w1= 70. \t#ft\n", - "e= 0.8\n", - "h1= 10. \t#ft\n", - "h2= 16. \t#ft\n", - "h3= 5. \t#ft\n", - "k= 2./5\n", - "f1= 20. \t#ft/sec\n", - "f= 18. \t#ft/sec\n", - "a= 45. \t #degrees\n", - "x1= 164.4 \t#ft\n", - "\n", - "#CALCULATIONS\n", - "Hm= u1*w1/g\n", - "Hm1= e*Hm\n", - "lh= Hm-Hm1-h1-h2-h3\n", - "vg= k*math.sqrt(f1**2+w1**2)\n", - "pr= ((f**2+u1**2-f1**2/(math.sin(math.radians(a)))**2)/(2*g))-h2\n", - "pr1= x1-pr\n", - "ge= pr1*g*2*100/(vg/k)**2\n", - "\n", - "#RESULTS\n", - "print 'manometer Head = %.1f ft '%(Hm1)\n", - "print ' outlet velocity from guides = %.1f ft/sec '%(vg)\n", - "print ' Pressure rise through impeller only = %.1f ft '%(pr)\n", - "print ' Guide balde efficiency = %.f per cent '%(ge)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "manometer Head = 156.5 ft \n", - " outlet velocity from guides = 29.1 ft/sec \n", - " Pressure rise through impeller only = 102.4 ft \n", - " Guide balde efficiency = 75 per cent \n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.6 Page No : 231" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "D1= 7.5 \t#in\n", - "Q1= 850. \t#gal/min\n", - "p1= 62.4 \t#lb/ft**3\n", - "N1= 1800.\n", - "D2= 15. \t#in\n", - "Q2= 12000. \t#gal/min\n", - "p2= 64. \t#lb/ft**3\n", - "N1= 1800. \t#r.p.m \n", - "H1= 14. \t#lb/ft**2\n", - "\n", - "#CALCULATIONS\n", - "N2= Q2*N1*(D1)**3/(Q1*D2**3)\n", - "P1= p1*H1/144\n", - "P2= P1*N2**2*D2**2*p2/(N1**2*p1*D1**2)\n", - "\n", - "#RESULTS\n", - "print 'N2 = %.f r.p.m '%(N2+4)\n", - "print ' P2 = %.f lb/in**2 '%(P2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "N2 = 3180 r.p.m \n", - " P2 = 78 lb/in**2 \n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.8 Page No : 234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "#initialisation of variables\n", - "r= 5.\n", - "\n", - "#CALCULATIONS\n", - "sr= r**2\n", - "sr1= r**2/r\n", - "\n", - "#RESULTS\n", - "print 'Corresponding ratio = %.f '%(sr)\n", - "print ' Corresponding ratio = %.f '%(sr1)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Corresponding ratio = 25 \n", - " Corresponding ratio = 5 \n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.9 Page No : 236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "e= 0.88\n", - "w= 1.25 \t#in\n", - "d= 10. \t#in\n", - "q= 630. \t#gal/min\n", - "a= 40. \t#degrees\n", - "g= 32.2 \t#ft/sec**2\n", - "e1= 0.83\n", - "\n", - "#CALCULATIONS\n", - "Q= q/(6.24*60)\n", - "f1= Q/(e*math.pi*(d/12)*(w/12))\n", - "u1= 1000*(w*4/12)*2*math.pi/60\n", - "w1= u1-f1*1/math.tan(math.radians(a))\n", - "W= u1*w1/g\n", - "lr= (f1**2+u1**2-f1**2/(math.sin(math.radians(a)))**2)/(2*g)\n", - "mh= e1*W\n", - "p= mh-lr\n", - "v1= math.sqrt(f1**2+w1**2)\n", - "ke= v1**2/(2*g)\n", - "pke= p*100/ke\n", - "me= 100*lr/W\n", - "\n", - "#RESULTS\n", - "print 'Velocity of flow = %.f ft/sec'%(f1)\n", - "print ' Work done = %.1f ft-lb/lb'%(W)\n", - "print ' manometric efficiency = %.1f ft'%(mh)\n", - "print ' Pressure recovered = %.1f ft head'%(p)\n", - "print ' Kinetic energy discharge = %.f ft-lb/lb'%(ke)\n", - "print ' Percentage of kinetic energy recovered = %.1f per cent'%(pke)\n", - "print ' manometric efficiency = %d percent'%(me)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Velocity of flow = 7 ft/sec\n", - " Work done = 47.8 ft-lb/lb\n", - " manometric efficiency = 39.7 ft\n", - " Pressure recovered = 11.2 ft head\n", - " Kinetic energy discharge = 20 ft-lb/lb\n", - " Percentage of kinetic energy recovered = 55.7 per cent\n", - " manometric efficiency = 59 percent\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.10 Page No : 239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "W1= 7640. \t#gal/min\n", - "W2= 11400. \t#gal/min\n", - "Hm= 63. \t#ft\n", - "Hm1= 80. \t#ft\n", - "ep1= 72. \t#per cent\n", - "ep2= 76. \t#per cent\n", - "\n", - "#CALCULATIONS\n", - "whp1= W1*Hm/(60*550)\n", - "whp2= W2*Hm1/(60*550)\n", - "bhp1= whp1*100/ep1\n", - "bhp2= whp2*100/ep2\n", - "w1= W2/10\n", - "\n", - "#RESULTS\n", - "print 'For both pumps discharge = %.f gal/min against an 80-ft head'%(W2)\n", - "print ' delivery from one pump = %.1f h.p '%(bhp1)\n", - "print ' delivery from two pumps = %.1f h.p '%(bhp2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "For both pumps discharge = 11400 gal/min against an 80-ft head\n", - " delivery from one pump = 20.3 h.p \n", - " delivery from two pumps = 36.4 h.p \n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.11 Page No : 241" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "h= 94. \t#ft\n", - "w= 62.4 \t#lb/ft**3\n", - "e= 0.58\n", - "p= 73.5 \t#per cent\n", - "\n", - "#CALCULATIONS\n", - "WHP= h*e*w/550\n", - "BHP= WHP/(p/100)\n", - "\n", - "#RESULTS\n", - "print 'W.H.P= %.2f h.p'%(WHP)\n", - "print ' Brake horse power= %.1f'%(BHP)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "W.H.P= 6.19 h.p\n", - " Brake horse power= 8.4\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.12 Page No : 243" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "sl= 12. \t#ft\n", - "l= 20. \t#ft\n", - "d= 4. \t#in\n", - "dp= 6. \t#in\n", - "lst= 18. \t#in\n", - "k= 0.025\n", - "H= 32. \t#ft\n", - "g= 32.2 \t#ft/sec**2\n", - "pf= 6. \t#ft\n", - "a= 33.83 \n", - "a1= 9.53\n", - "\n", - "#CALCULATIONS\n", - "A= math.sqrt((H-sl-d)*g/a)*a1\n", - "Q= 2*math.pi*(dp/12)**2*lst/(12*4*60)\n", - "v= Q/(math.pi*(d/12)**2/4)\n", - "kh= v**2/(2*g)\n", - "fh= k*l*v**2*12/(2*g*d)\n", - "N= math.sqrt((H-sl-pf)/(kh+fh))\n", - "\n", - "#RESULTS\n", - "print 'premissible speed = %.1f r.p.m'%(A)\n", - "print ' maximum premissible speed = %.1f r.p.m'%(N)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "premissible speed = 37.2 r.p.m\n", - " maximum premissible speed = 168.8 r.p.m\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.13 Page No : 245" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "b= 6. \t#in\n", - "s= 12. \t #in\n", - "d= 4. \t #in\n", - "a1= 30. \t#degrees\n", - "a2= 90. \t#degrees\n", - "a3= 120. \t#degrees\n", - "N= 120. \t#r.p.m\n", - "n= 4.\n", - "#calculations\n", - "A= 2*math.pi*N/60\n", - "V= math.pi*(b/12)**2*n/4\n", - "v= (b/12)**2*A*(b/12)/(d/12)**2\n", - "Q1= v*math.pi*(d/12)**2*math.sin(math.radians(a1))/4\n", - "Q2= v*math.pi*(d/12)**2*math.sin(math.radians(a2))/4\n", - "Q3= v*math.pi*(d/12)**2*math.sin(math.radians(a3))/4\n", - "Q4= V-Q1\n", - "Q5= Q2-V\n", - "Q6= Q3-V\n", - "a4= math.degrees(math.asin(V/(v*math.pi*(d/12)**2)))+a1\n", - "A= 180-a4\n", - "\n", - "#RESULTS\n", - "print 'rate of flow at a1 = %.3f cuses'%(Q4)\n", - "print ' rate of flow at a2 = %.3f cuses'%(Q5)\n", - "print ' rate of flow at a3 = %.3f cuses'%(Q6)\n", - "print ' crak angle = %.1f degrees'%(a4)\n", - "print ' crak angle = %.1f degrees'%(A)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "rate of flow at a1 = 0.169 cuses\n", - " rate of flow at a2 = 0.448 cuses\n", - " rate of flow at a3 = 0.283 cuses\n", - " crak angle = 39.2 degrees\n", - " crak angle = 140.8 degrees\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.14 Page No : 247" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "import math \n", - "\n", - "#initialisation of variables\n", - "n= 2. \t#strokes/sec\n", - "dp= 6. \t#in\n", - "ds= 18. \t#in\n", - "ds1=4. \t#in\n", - "l= 20. \t#ft\n", - "l1= 20. \t#ft\n", - "f= 0.008\n", - "la= 5. \t#ft\n", - "A= 60. \t#r.p.m\n", - "f= 0.008\n", - "w= 62.4 \t#lb/ft**3\n", - "g=32.2\n", - "\n", - "#CALCULATIONS\n", - "V= math.pi*(ds/12)*n*(dp/12)**2/4\n", - "vmp= 2*math.pi*A*(ds/24)/60\n", - "vmp1= vmp*(dp**2/ds1**2)\n", - "hfmax= 4*f*(l-la)*vmp1**2/(2*g*ds1/12)\n", - "H1= round(2*hfmax/3,1)\n", - "H2= H1*13\n", - "Wls= (H1+H2)*w*math.pi/16*1.5*2\n", - "mv= V/(math.pi*(ds1/12)**2/4)\n", - "lh= round(4*f*(l-la)*mv**2/(2*g*(ds1/12)),2)\n", - "lhf= 12*lh\n", - "Wls1= (lh+13.21)*w*math.pi*1.5/16 *2 \n", - "WS= Wls-Wls1\n", - "\n", - "#RESULTS\n", - "print 'Work lost per second= %.f ft lb/sec'%(Wls)\n", - "print ' Work saved per second = %.f ft-lb/sec'%(WS)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Work lost per second= 875 ft lb/sec\n", - " Work saved per second = 352 ft-lb/sec\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.15 Page No : 248" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "d= 7.5 \t#in\n", - "s= 15. \t#in\n", - "l= 36. \t#ft\n", - "h1= 34. \t#ft\n", - "h2= 12. \t#ft\n", - "L= 10. \t #ft\n", - "g= 32.2 \t#ft/sec**2\n", - "f= 0.008\n", - "l1= 20. \t#ft\n", - "d1= 4. \t#in\n", - "h3= 110. \t#ft\n", - "w= 62.4 \t#lb/ft**3\n", - "l2= 180. \t#ft\n", - "\n", - "#CALCULATIONS\n", - "Q= (math.pi/4)*(d)**2*(s/12)*2*(l/60)/144\n", - "v= Q/((math.pi/4)*(d1/12)**2)\n", - "a= (d/4)**2*(d/12)*(l*2*math.pi/60)**2\n", - "H= h1-h2-(L*a/g)-(v**2*0.5/g)-(4*f*l1*v**2/(2*g*(d1/12)))\n", - "H1= h1+h3+(L*a/g)+(v**2*0.5/g)+(4*f*l2*v**2/(2*g*(d1/12)))\n", - "dh= (H1-H)*w/144\n", - "NP= dh*(math.pi/4)*d**2\n", - "\n", - "#RESULTS\n", - "print 'Head at piston = %.2f ft of water absolute'%(H)\n", - "print ' Head at piston = %.2f ft of water absolute'%(H1)\n", - "print ' Difference on head of piston = %.f lb/in**2'%(dh)\n", - "print ' Net load on piston = %.f lb'%(NP)\n", - "\n", - "#The answer is a bit different due to rounding off error in textbook\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Head at piston = 11.04 ft of water absolute\n", - " Head at piston = 161.59 ft of water absolute\n", - " Difference on head of piston = 65 lb/in**2\n", - " Net load on piston = 2882 lb\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 11.16 Page No : 250" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "import math \n", - "from numpy import *\n", - "from numpy.linalg import *\n", - "\n", - "#initialisation of variables\n", - "f= 0.009\n", - "dc= 3.5 \t#in\n", - "ds= 6. \t#in\n", - "r= 0.25\n", - "sl= 8. \t#ft\n", - "d= 2.5 \t#in\n", - "l= 14. \t#ft\n", - "el= 8. \t#ft\n", - "ed= 22.5 \t#in\n", - "ph= 4. \t#ft\n", - "g= 32.2 \t#ft/sec**2\n", - "f= 0.009\n", - "\n", - "#CALCULATIONS\n", - "BC= el+l\n", - "v= math.sqrt(BC*g/(l*(d/2)*(r)*(dc/d)**2))*9.55\n", - "vec=roots([2,1/r,-1])\n", - "H1= 77\n", - "MV= math.sqrt(BC*g/(l*(d/2)*(r)*(dc/d)**2))*r*(math.sin(math.radians(H1))+(math.sin(math.radians(2*H1))/8))\n", - "mvp= MV*dc**2/d**2\n", - "hf= 4*f*(sl+l)*mvp**2/(2*g*(d/12))\n", - "\n", - "#RESULTS\n", - "print 'pump speed = %.1f r.p.m'%(v)\n", - "print ' Friction head = %.3f ft'%(hf)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "pump speed = 86.8 r.p.m\n", - " Friction head = 1.240 ft\n" - ] - } - ], - "prompt_number": 15 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MayankSahu/Chapter1.ipynb b/sample_notebooks/MayankSahu/Chapter1.ipynb new file mode 100755 index 00000000..530c71c7 --- /dev/null +++ b/sample_notebooks/MayankSahu/Chapter1.ipynb @@ -0,0 +1 @@ +{"nbformat_minor": 0, "cells": [{"source": "#Chapter1 : Concepts of electric current and Laws", "cell_type": "markdown", "metadata": {}}, {"source": "## Example1.1, Page number 4", "cell_type": "markdown", "metadata": {}}, {"execution_count": 1, "cell_type": "code", "source": "#variable declaration\nL =12 #meter\nA=0.01*10**-4 #m**2\nR=0.2 #ohm\n\n#calculation\np=R*A/L #specific resistance\n\n#result\nprint \"specific resistance = \" , p, \"ohm-metre\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "specific resistance = 1.66666666667e-08 ohm-metre\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.2, Page number 5", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "\n#variable declaration\na0=0.0043 \nt1=27 #degree celsius\nt2=40\nR1=1.5 #ohm\n\n#calculation\nR2=R1*(1+a0*t2)/(1+a0*t1) #ohm\n\n#result\nprint \"The resistance of armature winding at 40 degree celcius =\" , round(R2,3) ,\"ohm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "The resistance of armature winding at 40 degree celcius = 1.575 ohm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.3, Page number 13", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "#variable decdlaration\nR1=5 #ohm \nR2=10\nR3=15\nV=120 #volt\n\n#calculation\nR=R1+R2+R3 #ohm\nI=V/R # ampere\nV1=I*R1 #volt\nV2=I*R2\nV3=I*R3\n\n#result\nprint \"Resistance = \" , R , \"ohm\"\nprint \"cureent = \" , I , \"amperes\"\nprint \"Voltage V1 = \" , V1 , \"volts\"\nprint \"Voltage V2 = \" , V2 , \"volts\"\nprint \"Voltage V3 = \" , V3 , \"volts\"\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Resistance = 30 ohm\ncureent = 4 amperes\nVoltage V1 = 20 volts\nVoltage V2 = 40 volts\nVoltage V3 = 60 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.4, Page number 14", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "#varaiable declaration\nRab =(2.0*4.0)/(2+4) #ohms\nRbc =(6.0*8.0)/(6+8)\n\n#calculation\nRac = Rab+Rbc #ohms\n\n#result\nprint \"resistance across AC = \" , round(Rac,2) , \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "resistance across AC = 4.76 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.5, Page number 14", "cell_type": "markdown", "metadata": {}}, {"execution_count": 5, "cell_type": "code", "source": "#variable declaration\nRab=4 #ohm\nRbc=(12.0*8.0)/(12+8)\nRcd=(3.0*6.0)/(3+6)\n\n#calculation\nRad=Rab+Rbc+Rcd #ohm\n\n#result\nprint \"resistance across AC = \" , Rad, \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "resistance across AC = 10.8 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.6, Page number 15", "cell_type": "markdown", "metadata": {}}, {"execution_count": 6, "cell_type": "code", "source": "#variable declaration\nR1=8 #ohms\nR=6\n#calculations\nR2 = 48/2 # R = R1*R2/(R1+R2)\n\n#result\nprint \" Resistance R2 = \" , R2, \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Resistance R2 = 24 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.7, Page number 15", "cell_type": "markdown", "metadata": {}}, {"execution_count": 7, "cell_type": "code", "source": "#variable declaration\nI=12.0 #ampere\nR1=6.0 #ohms\nR2=8.0\n\n#calculations\nI1=I*R2/(R1+R2) #amperes\nI2=I*R1/(R1+R2)\n\n#result\nprint \"I1= \" , round(I1,3) , \"amperes\" \nprint \"I2= \" , round(I2,2) , \"amperes\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "I1= 6.857 amperes\nI2= 5.14 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.9, Page number 17", "cell_type": "markdown", "metadata": {}}, {"execution_count": 8, "cell_type": "code", "source": "#variable declaration\nR1=0.02 #ohms\nR2=0.03\nI = 10 #amperes\n\n#Calculations\nI1=(I*R2)/(R1+R2)\nI2=(I*R1)/(R1+R2)\n\n#result\nprint \" I1= \" , I1 , \"amperes \"\nprint \" I2= \" , I2 , \"amperes \" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " I1= 6.0 amperes \n I2= 4.0 amperes \n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.10, Page number 18", "cell_type": "markdown", "metadata": {}}, {"execution_count": 9, "cell_type": "code", "source": "#variable declaration\nV=200.0 #volts\nI=25.0 #amperes\nP1=1500.0 #watts\n\n#calculations \nR1=(V*V)/P1 #ohms\nR=V/I #total resistance\nR2=R*R1/(R1-R) #ohms\n\n#result\nprint \"R1 = \" ,round(R1,2) , \"ohms\" \nprint \"R2 = \" , round(R2,2) , \"ohms\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "R1 = 26.67 ohms\nR2 = 11.43 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.11, Page number 19", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "#variable declaration\nV=100.0 #volts \nP=1500.0 #watts\n\n#calculations\nR=(V**2/P)/2 #ohms\nRa=R\nRb=R\nRc=R\nR1=((Ra*Rc)/(Ra+Rc))+Rb\nI=V/R1 #amperes\nI1=(I*Ra)/(Ra+Rc)\nI2=(I*Ra)/(Ra+Rc)\nPb=I*I*Ra #watts\nPa=I1*I1*Rb\nPc=I2*I2*Rc\n\n#result\nprint \"power dissipated in coil Pa = \" , round(Pa,2) , \"watts\"\nprint \"power dissipated in coil Pb = \" , round(Pb,2), \"watts\"\nprint \"power dissipated in coil Pc = \" , round(Pc,2) , \"watts\"\n\n#Round off error in book \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power dissipated in coil Pa = 333.33 watts\npower dissipated in coil Pb = 1333.33 watts\npower dissipated in coil Pc = 333.33 watts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.12, Page number 20", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "#variable declaration\nL=3600 #six lamp 1000 watt each for six days\nH=3000 # heater\nM=735.5 # single phase motor\nF=2400 #four fans 75W\nC=0.9 #cost of energy\n\n#Calculations\nT=L+H+M+F #total energy consumed in watt \nTE=T*30/1000\nB=TE*C #Bill amount in Rs\n\n#result\nprint \"Bill amount = Rs \" , round(B) \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Bill amount = Rs 263.0\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.18, Page number 34", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "#variable declaration\nRry=4.0 #ohm\nRyb=1.0\nRbr=5.0\n\n#calculation\nRr=(Rbr*Rry)/(Rry+Rbr+Ryb)\nRy=(Rry*Ryb)/(Rry+Rbr+Ryb)\nRb=(Rbr*Ryb)/(Rry+Rbr+Ryb)\n\n#result\nprint \"Rr = \" , Rr , \"ohms\"\nprint \"Ry = \" , Ry , \"ohms\"\nprint \"Rb= \" , Rb , \"ohms\"\n\n#Value of Rr in book is printed wrong \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Rr = 2.0 ohms\nRy = 0.4 ohms\nRb= 0.5 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.19, Page number 34", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "#variable declaration\nRr=2.0 #ohms\nRy=0.67\nRb=1.0\n\n#calculations\nRry=(Rr*Ry)+(Ry*Rb)+(Rb*Rr)/Rb\nRyb=((Rr*Ry)+(Ry*Rb)+(Rb*Rr))/Rr\nRbr=((Rr*Ry)+(Ry*Rb)+(Rb*Rr))/Ry\n\n#result\nprint \"Rry = \" , round(Rry) , \"ohms\"\nprint \"Ryb = \" , round(Ryb) , \"ohms\"\nprint \"Rbr = \" , round(Rbr) , \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Rry = 4.0 ohms\nRyb = 2.0 ohms\nRbr = 6.0 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/MayankSahu/Chapter1_.ipynb b/sample_notebooks/MayankSahu/Chapter1_.ipynb deleted file mode 100755 index 530c71c7..00000000 --- a/sample_notebooks/MayankSahu/Chapter1_.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"nbformat_minor": 0, "cells": [{"source": "#Chapter1 : Concepts of electric current and Laws", "cell_type": "markdown", "metadata": {}}, {"source": "## Example1.1, Page number 4", "cell_type": "markdown", "metadata": {}}, {"execution_count": 1, "cell_type": "code", "source": "#variable declaration\nL =12 #meter\nA=0.01*10**-4 #m**2\nR=0.2 #ohm\n\n#calculation\np=R*A/L #specific resistance\n\n#result\nprint \"specific resistance = \" , p, \"ohm-metre\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "specific resistance = 1.66666666667e-08 ohm-metre\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.2, Page number 5", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "\n#variable declaration\na0=0.0043 \nt1=27 #degree celsius\nt2=40\nR1=1.5 #ohm\n\n#calculation\nR2=R1*(1+a0*t2)/(1+a0*t1) #ohm\n\n#result\nprint \"The resistance of armature winding at 40 degree celcius =\" , round(R2,3) ,\"ohm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "The resistance of armature winding at 40 degree celcius = 1.575 ohm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.3, Page number 13", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "#variable decdlaration\nR1=5 #ohm \nR2=10\nR3=15\nV=120 #volt\n\n#calculation\nR=R1+R2+R3 #ohm\nI=V/R # ampere\nV1=I*R1 #volt\nV2=I*R2\nV3=I*R3\n\n#result\nprint \"Resistance = \" , R , \"ohm\"\nprint \"cureent = \" , I , \"amperes\"\nprint \"Voltage V1 = \" , V1 , \"volts\"\nprint \"Voltage V2 = \" , V2 , \"volts\"\nprint \"Voltage V3 = \" , V3 , \"volts\"\n\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Resistance = 30 ohm\ncureent = 4 amperes\nVoltage V1 = 20 volts\nVoltage V2 = 40 volts\nVoltage V3 = 60 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.4, Page number 14", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "#varaiable declaration\nRab =(2.0*4.0)/(2+4) #ohms\nRbc =(6.0*8.0)/(6+8)\n\n#calculation\nRac = Rab+Rbc #ohms\n\n#result\nprint \"resistance across AC = \" , round(Rac,2) , \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "resistance across AC = 4.76 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.5, Page number 14", "cell_type": "markdown", "metadata": {}}, {"execution_count": 5, "cell_type": "code", "source": "#variable declaration\nRab=4 #ohm\nRbc=(12.0*8.0)/(12+8)\nRcd=(3.0*6.0)/(3+6)\n\n#calculation\nRad=Rab+Rbc+Rcd #ohm\n\n#result\nprint \"resistance across AC = \" , Rad, \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "resistance across AC = 10.8 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.6, Page number 15", "cell_type": "markdown", "metadata": {}}, {"execution_count": 6, "cell_type": "code", "source": "#variable declaration\nR1=8 #ohms\nR=6\n#calculations\nR2 = 48/2 # R = R1*R2/(R1+R2)\n\n#result\nprint \" Resistance R2 = \" , R2, \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Resistance R2 = 24 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.7, Page number 15", "cell_type": "markdown", "metadata": {}}, {"execution_count": 7, "cell_type": "code", "source": "#variable declaration\nI=12.0 #ampere\nR1=6.0 #ohms\nR2=8.0\n\n#calculations\nI1=I*R2/(R1+R2) #amperes\nI2=I*R1/(R1+R2)\n\n#result\nprint \"I1= \" , round(I1,3) , \"amperes\" \nprint \"I2= \" , round(I2,2) , \"amperes\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "I1= 6.857 amperes\nI2= 5.14 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.9, Page number 17", "cell_type": "markdown", "metadata": {}}, {"execution_count": 8, "cell_type": "code", "source": "#variable declaration\nR1=0.02 #ohms\nR2=0.03\nI = 10 #amperes\n\n#Calculations\nI1=(I*R2)/(R1+R2)\nI2=(I*R1)/(R1+R2)\n\n#result\nprint \" I1= \" , I1 , \"amperes \"\nprint \" I2= \" , I2 , \"amperes \" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " I1= 6.0 amperes \n I2= 4.0 amperes \n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.10, Page number 18", "cell_type": "markdown", "metadata": {}}, {"execution_count": 9, "cell_type": "code", "source": "#variable declaration\nV=200.0 #volts\nI=25.0 #amperes\nP1=1500.0 #watts\n\n#calculations \nR1=(V*V)/P1 #ohms\nR=V/I #total resistance\nR2=R*R1/(R1-R) #ohms\n\n#result\nprint \"R1 = \" ,round(R1,2) , \"ohms\" \nprint \"R2 = \" , round(R2,2) , \"ohms\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "R1 = 26.67 ohms\nR2 = 11.43 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.11, Page number 19", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "#variable declaration\nV=100.0 #volts \nP=1500.0 #watts\n\n#calculations\nR=(V**2/P)/2 #ohms\nRa=R\nRb=R\nRc=R\nR1=((Ra*Rc)/(Ra+Rc))+Rb\nI=V/R1 #amperes\nI1=(I*Ra)/(Ra+Rc)\nI2=(I*Ra)/(Ra+Rc)\nPb=I*I*Ra #watts\nPa=I1*I1*Rb\nPc=I2*I2*Rc\n\n#result\nprint \"power dissipated in coil Pa = \" , round(Pa,2) , \"watts\"\nprint \"power dissipated in coil Pb = \" , round(Pb,2), \"watts\"\nprint \"power dissipated in coil Pc = \" , round(Pc,2) , \"watts\"\n\n#Round off error in book \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power dissipated in coil Pa = 333.33 watts\npower dissipated in coil Pb = 1333.33 watts\npower dissipated in coil Pc = 333.33 watts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.12, Page number 20", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "#variable declaration\nL=3600 #six lamp 1000 watt each for six days\nH=3000 # heater\nM=735.5 # single phase motor\nF=2400 #four fans 75W\nC=0.9 #cost of energy\n\n#Calculations\nT=L+H+M+F #total energy consumed in watt \nTE=T*30/1000\nB=TE*C #Bill amount in Rs\n\n#result\nprint \"Bill amount = Rs \" , round(B) \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Bill amount = Rs 263.0\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.18, Page number 34", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "#variable declaration\nRry=4.0 #ohm\nRyb=1.0\nRbr=5.0\n\n#calculation\nRr=(Rbr*Rry)/(Rry+Rbr+Ryb)\nRy=(Rry*Ryb)/(Rry+Rbr+Ryb)\nRb=(Rbr*Ryb)/(Rry+Rbr+Ryb)\n\n#result\nprint \"Rr = \" , Rr , \"ohms\"\nprint \"Ry = \" , Ry , \"ohms\"\nprint \"Rb= \" , Rb , \"ohms\"\n\n#Value of Rr in book is printed wrong \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Rr = 2.0 ohms\nRy = 0.4 ohms\nRb= 0.5 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "## Example1.19, Page number 34", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "#variable declaration\nRr=2.0 #ohms\nRy=0.67\nRb=1.0\n\n#calculations\nRry=(Rr*Ry)+(Ry*Rb)+(Rb*Rr)/Rb\nRyb=((Rr*Ry)+(Ry*Rb)+(Rb*Rr))/Rr\nRbr=((Rr*Ry)+(Ry*Rb)+(Rb*Rr))/Ry\n\n#result\nprint \"Rry = \" , round(Rry) , \"ohms\"\nprint \"Ryb = \" , round(Ryb) , \"ohms\"\nprint \"Rbr = \" , round(Rbr) , \"ohms\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Rry = 4.0 ohms\nRyb = 2.0 ohms\nRbr = 6.0 ohms\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/MayankSahu/Chapter5.ipynb b/sample_notebooks/MayankSahu/Chapter5.ipynb new file mode 100755 index 00000000..7738b9ee --- /dev/null +++ b/sample_notebooks/MayankSahu/Chapter5.ipynb @@ -0,0 +1 @@ +{"nbformat_minor": 0, "cells": [{"source": "#Chapter5 : Electrical Machines", "cell_type": "markdown", "metadata": {}}, {"source": "##Example 5.1 , Page number 178", "cell_type": "markdown", "metadata": {}}, {"execution_count": 1, "cell_type": "code", "source": "#determine the induced emf in the armature\n\n#varaible declaration\nP=4 #poles\nA=2 #wave wound\nn=50 #number of slots\nSc=24 #slots/conductor\nN=600 #speed of armature \nF=10e-3 #webers\n\n#calculations\nZ=Sc*n #total conductor\nE=F*Z*N*P/(60*A) #emf induced\n\nprint \" emf induced E = \" , E , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced E = 240.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.2 , Page number 178", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "#determine the induced emf in the armature\n\n#variable declaration\nP=4 #poles\nA=4 #wave wound\nn=50 #number of slots\nSc=24 #slots/conductor\nN=600 #rpm \nF=10e-3 #webers\n\n#calculations\nZ=Sc*n;#total conductor\nE=F*Z*N*P/(60*A) #emf induced\n\n#result\nprint \"e.m.f induced E = \" , E, \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "e.m.f induced E = 120.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.3 , Page number 179", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "#determine the speed\n\n#variable declaration\nP=6 #poles\nA1=2 #wave wound\nZ=780 #armature conductors\nF=12*10**-3 #webers \nE=400 #volt\nA2=6 #wave wound\n#calculation\nN=(E*60*A1)/(F*Z*P) #rpm\nN2=(E*60*A2)/(F*Z*P) #rpm\n\n#result\nprint \" Speed of the armature = \" , round(N,2) , \"rpm\"\nprint \" Speed when lap is wound = \" , round(N2,1) , \"rpm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Speed of the armature = 854.7 rpm\n Speed when lap is wound = 2564.1 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.4 , Page number 182", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "#determine the emf induced\n\n#variable declaration\nR=0.5 #ohm\nRs=100.0 \nV=250.0 #volts\nP=10000.0 #watts\n\n#calculation\nI=P/V #ampere\nIs=V/Rs \nIa=I+Is \nEg=V+(R*Ia) #volts\n\n#result\nprint \" emf induced Eg = \" , Eg , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 271.25 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.5 , Page number 183", "cell_type": "markdown", "metadata": {}}, {"execution_count": 5, "cell_type": "code", "source": "#calculate the emf induced in the armature\n\n#variable declaration\nIl=200 #amperes\nVl=500 #volts\nRa=0.03 #ohm\nRs=0.015\nR=150\nBCD=2 #one volt per brush\n\n#calculation\nI=Vl/R #ampere\nIa=Il+I \nEg=Vl+(Ia*Ra)+(Ia*Rs)+BCD #volts\n\n#result\nprint \" emf induced Eg = \" , round(Eg,2) , \"volts\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 511.13 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.6 , Page number 184", "cell_type": "markdown", "metadata": {}}, {"execution_count": 6, "cell_type": "code", "source": "#calculate the emf induced in the armature\n\n#variable declaration\nI1=200 #ampere\nVl=500 #volts\nRa=0.03 #ohm\nRs=0.015\nIs=200 #ampere\nR=150 #ohm\n\n#calculation\nBCD=2 #one volt per brush\nI=(Vl+(Is*Rs))/R #ampere\nIa = I1 + I\nEg=Vl+(Ia*Ra)+(Ia*Rs)+BCD #volts\n\n#result\nprint \" emf induced Eg = \" , round(Eg,2) ,\"volts\"\n\n#Error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 511.15 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.7 , Page number 196", "cell_type": "markdown", "metadata": {}}, {"execution_count": 7, "cell_type": "code", "source": "#calculate the back emf induced on full load\n\n#variable declaration\nRa=0.5 #armature resistance\nRs=250 #shunt resistance\nVl=250 #line volt\nIl=40 #ampere\n\n#calculation\nIs=Vl/Rs #amperes\nIa=Il-Is\nEb=Vl-(Ia*Ra) #volts\n\n#result\nprint \"emf induced Eb = \", Eb, \"volts\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "emf induced Eb = 230.5 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.8 , Page number 196", "cell_type": "markdown", "metadata": {}}, {"execution_count": 8, "cell_type": "code", "source": "#find the power developed in circiut\n\n#variable declaration\nPl=20e3 #watts\nVl=200.0 #volts \nRa=0.05 #ohms\nR=150.0\n\n#calculation\nI=Vl/R #ampere\nIl=Pl/Vl\nIa=Il+I\nEg=Vl+(Ia*Ra) #volts\nP=Eg*Ia #watts\n\n#result\nprint \"power developed = \" , round(P,2) , \"watt\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power developed = 20780.09 watt\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.9 , Page number 197", "cell_type": "markdown", "metadata": {}}, {"execution_count": 9, "cell_type": "code", "source": "#calculate the speed of the machine when running\n\n#variable declaration\nN1=1000 #speed of generator\nE1=205.06 #emf generator\nE2=195.06 #emf of motor\n\n#calculation\nN2=(E2*N1)/E1 #speed of generator\n\n#result\nprint\"speed of motor = \" , round(N2,2) ,\"rpm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "speed of motor = 951.23 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.10 , Page number 198", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "#dtermine its speed when its take crnt 25 amps\n\n#variable declaration\nVl=250.0 #volts\nRa=0.05 #ohm\nR=0.02 #ohm\nIa=30.0 #ampere\nI1=30.0\nN1=400.0\nI2=25.0\n\n#calculation\nE1=Vl-(Ia*Ra)-(Ia*R) #volts\nN2=(N1*E1*I1)/(E1*I2) #rpm\n\n#result\nprint \"speed of motor = \" , round(N2,2) ,\"rpm\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "speed of motor = 480.0 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.11 , Page number 199", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "#find the torque whn its take scurnt 60amprs\n\n#variable declaration\nVl=200 #volts\nIl=60 #amperes\nR=50 #ohm\nf=0.03 # flux \nZ=700 #armature conductors\nP=4 #pole\nA=2\n\n#calculation\nI=Vl/R # amperes\nIa=Il-I #amperes\nT=(0.159*f*Z*Ia*P)/A\n\n#result\nprint \" Torque = \" , round(T,2) , \"N-m\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Torque = 373.97 N-m\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.12 , Page number 214", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "#calcute the num of prim turns and prim $sec current\n\n#variable declaration\nKVA = 50.0\nE1 = 6000.0 #volts\nE2 = 250.0 #volts\nN2 = 52.0 #number of turns\n\n#calculation\nN1=N2*E1/E2\nI2=KVA*1000/E2 #ampere\nI1=KVA*1000/E1 #ampere\n\n#result\nprint \" primary number of turns = \" , N1 , \"turns\"\nprint \" secondary current = \" , I2, \"amperes\"\nprint \" primary current = \" , round(I1,2), \"amperes\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " primary number of turns = 1248.0 turns\n secondary current = 200.0 amperes\n primary current = 8.33 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.13 , Page number 215", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "#determine the emf induced in the secondry max value of flux density\n\n#calculation\nf=50 #Hz\nN1=350 #turns\nN2=800 #turns\nE1=400 #volts\nA=75e-4 #m**2\n\n#calculation\nE2=(N2*E1)/N1 #volts\nBm=E1/(4.44*f*A*N1) #Wb/m**2\n\n#result\nprint \" flux density = \" , round(Bm,3) , \"wb/m**2\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " flux density = 0.686 wb/m**2\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.14 , Page number 215", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "import math\n\n#find the magnetic nd iron loss component of current\n\n#variable declaration\nE1=440 #volts\nE2=200 #volts\nI=0.2 #amperea\ncoso=0.18 #p.f.\n\n#calculation\nsino= math.sqrt(1-coso**2) \nIw=I*coso #ampere\nIu=I*sino #ampere\n\n#result\nprint \" Magnetising compenet of current = \" , round(Iw,3), \"amperes\"\nprint \" iron loss compenet of current = \" , round(Iu,4), \"amperes\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Magnetising compenet of current = 0.036 amperes\n iron loss compenet of current = 0.1967 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.15 , Page number 216", "cell_type": "markdown", "metadata": {}}, {"execution_count": 15, "cell_type": "code", "source": "#calculate the efficiency at loads\n\n#variable declaration\nKVA=20\nIl=350 #iron loss\nCl=400 #copper loss\nx=1 # fraction of load\npf=0.8 # at full load\npf1=0.4 #at half load\nx1=0.5 #fraction of load\n\n#calculation\nop=KVA*1000*x*pf\nop1=KVA*1000*x1*pf1\nTl=Il+(Cl*x*x)\nTl1=Il+(Cl*x1*x1)\nip=op+Tl\nip1=op1+Tl1\nn=op/ip*100\nn1=op1/ip1*100\n\n#result\nprint \"efficiency at half load = \" , round(n,2) \nprint \"efficiency at full load = \" , round(n1,2) \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "efficiency at half load = 95.52\nefficiency at full load = 89.89\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.16 , Page number 221", "cell_type": "markdown", "metadata": {}}, {"execution_count": 16, "cell_type": "code", "source": "#calculate the synchronous speed ,slip,frequncy induced emf\n\n#variable declaration\nf=50.0 #Hz\np=4 #poles \nN=1460.0 #rpm\n\n#calculation\nNs=120*f/p #rpm\ns=(Ns-N)/Ns #slip\nf1=(s*f) #Hz\n\n#result\nprint \"synchronous speed Ns = \" , Ns , \"rpm\"\nprint \"slip s = \" , round(s,3)\nprint \" Frequency of rotor induced emf f = \" , round(f1,2) , \"Hz\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "synchronous speed Ns = 1500.0 rpm\nslip s = 0.027\n Frequency of rotor induced emf f = 1.33 Hz\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.17 , Page number 222", "cell_type": "markdown", "metadata": {}}, {"execution_count": 17, "cell_type": "code", "source": "#determine the value of slip nd speed of motor\n\n#variable declaration\nP=6 #pole\nf=50 #Hz\nf1=1.5\n\n#calculation\nNs=120*f/P\ns=f1/f\nN=Ns*(1-s)\n\n#result\nprint \" speed of motor = \", N, \" RPM\"\nprint \" slip = \" , round(s,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " speed of motor = 970.0 RPM\n slip = 0.03\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.18 , Page number 222", "cell_type": "markdown", "metadata": {}}, {"execution_count": 18, "cell_type": "code", "source": "#calculate the numbers of poles ,slip at full load,frequncy rotor,speed of motor\n\n#variable declaration\nNs=1000.0 #rpm\nN=960\nf=50 #Hz\n\n#calculation\nP=120*f/Ns #synchronous speed\ns=(Ns-N)/Ns #slip \nf1=s*f #Hz\nN=Ns*(1-0.08) #speed of motor at 8% slip\n\n#result\nprint \" number of poles p = \" , P\nprint \" slip s = \" , round(s,2)\nprint \" Frequency of rotor emf f = \" , f , \"Hz\"\nprint \" Speed of motor at 8% slip N = \" , N , \"RPM\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " number of poles p = 6.0\n slip s = 0.04\n Frequency of rotor emf f = 50 Hz\n Speed of motor at 8% slip N = 920.0 RPM\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.19 , Page number 231", "cell_type": "markdown", "metadata": {}}, {"execution_count": 19, "cell_type": "code", "source": "#calculate the induced emf per phase\n\n#variable declaration\nf=50 #Hz\nP=16 #poles\nN=160 #rpm\nS=6 #slip\nF=0.025 #flux\n\n#calculation\nn=N*S #conductors\nZ=n/3 \ne=2.22*F*f*Z #rms value\n\n#result\nprint \"Induced emf per phase e = \" , e , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Induced emf per phase e = 888.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/MayankSahu/Chapter5_.ipynb b/sample_notebooks/MayankSahu/Chapter5_.ipynb deleted file mode 100755 index 7738b9ee..00000000 --- a/sample_notebooks/MayankSahu/Chapter5_.ipynb +++ /dev/null @@ -1 +0,0 @@ -{"nbformat_minor": 0, "cells": [{"source": "#Chapter5 : Electrical Machines", "cell_type": "markdown", "metadata": {}}, {"source": "##Example 5.1 , Page number 178", "cell_type": "markdown", "metadata": {}}, {"execution_count": 1, "cell_type": "code", "source": "#determine the induced emf in the armature\n\n#varaible declaration\nP=4 #poles\nA=2 #wave wound\nn=50 #number of slots\nSc=24 #slots/conductor\nN=600 #speed of armature \nF=10e-3 #webers\n\n#calculations\nZ=Sc*n #total conductor\nE=F*Z*N*P/(60*A) #emf induced\n\nprint \" emf induced E = \" , E , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced E = 240.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.2 , Page number 178", "cell_type": "markdown", "metadata": {}}, {"execution_count": 2, "cell_type": "code", "source": "#determine the induced emf in the armature\n\n#variable declaration\nP=4 #poles\nA=4 #wave wound\nn=50 #number of slots\nSc=24 #slots/conductor\nN=600 #rpm \nF=10e-3 #webers\n\n#calculations\nZ=Sc*n;#total conductor\nE=F*Z*N*P/(60*A) #emf induced\n\n#result\nprint \"e.m.f induced E = \" , E, \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "e.m.f induced E = 120.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.3 , Page number 179", "cell_type": "markdown", "metadata": {}}, {"execution_count": 3, "cell_type": "code", "source": "#determine the speed\n\n#variable declaration\nP=6 #poles\nA1=2 #wave wound\nZ=780 #armature conductors\nF=12*10**-3 #webers \nE=400 #volt\nA2=6 #wave wound\n#calculation\nN=(E*60*A1)/(F*Z*P) #rpm\nN2=(E*60*A2)/(F*Z*P) #rpm\n\n#result\nprint \" Speed of the armature = \" , round(N,2) , \"rpm\"\nprint \" Speed when lap is wound = \" , round(N2,1) , \"rpm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Speed of the armature = 854.7 rpm\n Speed when lap is wound = 2564.1 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.4 , Page number 182", "cell_type": "markdown", "metadata": {}}, {"execution_count": 4, "cell_type": "code", "source": "#determine the emf induced\n\n#variable declaration\nR=0.5 #ohm\nRs=100.0 \nV=250.0 #volts\nP=10000.0 #watts\n\n#calculation\nI=P/V #ampere\nIs=V/Rs \nIa=I+Is \nEg=V+(R*Ia) #volts\n\n#result\nprint \" emf induced Eg = \" , Eg , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 271.25 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.5 , Page number 183", "cell_type": "markdown", "metadata": {}}, {"execution_count": 5, "cell_type": "code", "source": "#calculate the emf induced in the armature\n\n#variable declaration\nIl=200 #amperes\nVl=500 #volts\nRa=0.03 #ohm\nRs=0.015\nR=150\nBCD=2 #one volt per brush\n\n#calculation\nI=Vl/R #ampere\nIa=Il+I \nEg=Vl+(Ia*Ra)+(Ia*Rs)+BCD #volts\n\n#result\nprint \" emf induced Eg = \" , round(Eg,2) , \"volts\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 511.13 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.6 , Page number 184", "cell_type": "markdown", "metadata": {}}, {"execution_count": 6, "cell_type": "code", "source": "#calculate the emf induced in the armature\n\n#variable declaration\nI1=200 #ampere\nVl=500 #volts\nRa=0.03 #ohm\nRs=0.015\nIs=200 #ampere\nR=150 #ohm\n\n#calculation\nBCD=2 #one volt per brush\nI=(Vl+(Is*Rs))/R #ampere\nIa = I1 + I\nEg=Vl+(Ia*Ra)+(Ia*Rs)+BCD #volts\n\n#result\nprint \" emf induced Eg = \" , round(Eg,2) ,\"volts\"\n\n#Error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " emf induced Eg = 511.15 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.7 , Page number 196", "cell_type": "markdown", "metadata": {}}, {"execution_count": 7, "cell_type": "code", "source": "#calculate the back emf induced on full load\n\n#variable declaration\nRa=0.5 #armature resistance\nRs=250 #shunt resistance\nVl=250 #line volt\nIl=40 #ampere\n\n#calculation\nIs=Vl/Rs #amperes\nIa=Il-Is\nEb=Vl-(Ia*Ra) #volts\n\n#result\nprint \"emf induced Eb = \", Eb, \"volts\" \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "emf induced Eb = 230.5 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.8 , Page number 196", "cell_type": "markdown", "metadata": {}}, {"execution_count": 8, "cell_type": "code", "source": "#find the power developed in circiut\n\n#variable declaration\nPl=20e3 #watts\nVl=200.0 #volts \nRa=0.05 #ohms\nR=150.0\n\n#calculation\nI=Vl/R #ampere\nIl=Pl/Vl\nIa=Il+I\nEg=Vl+(Ia*Ra) #volts\nP=Eg*Ia #watts\n\n#result\nprint \"power developed = \" , round(P,2) , \"watt\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "power developed = 20780.09 watt\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.9 , Page number 197", "cell_type": "markdown", "metadata": {}}, {"execution_count": 9, "cell_type": "code", "source": "#calculate the speed of the machine when running\n\n#variable declaration\nN1=1000 #speed of generator\nE1=205.06 #emf generator\nE2=195.06 #emf of motor\n\n#calculation\nN2=(E2*N1)/E1 #speed of generator\n\n#result\nprint\"speed of motor = \" , round(N2,2) ,\"rpm\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "speed of motor = 951.23 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.10 , Page number 198", "cell_type": "markdown", "metadata": {}}, {"execution_count": 10, "cell_type": "code", "source": "#dtermine its speed when its take crnt 25 amps\n\n#variable declaration\nVl=250.0 #volts\nRa=0.05 #ohm\nR=0.02 #ohm\nIa=30.0 #ampere\nI1=30.0\nN1=400.0\nI2=25.0\n\n#calculation\nE1=Vl-(Ia*Ra)-(Ia*R) #volts\nN2=(N1*E1*I1)/(E1*I2) #rpm\n\n#result\nprint \"speed of motor = \" , round(N2,2) ,\"rpm\"\n\n#round off error in book\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "speed of motor = 480.0 rpm\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.11 , Page number 199", "cell_type": "markdown", "metadata": {}}, {"execution_count": 11, "cell_type": "code", "source": "#find the torque whn its take scurnt 60amprs\n\n#variable declaration\nVl=200 #volts\nIl=60 #amperes\nR=50 #ohm\nf=0.03 # flux \nZ=700 #armature conductors\nP=4 #pole\nA=2\n\n#calculation\nI=Vl/R # amperes\nIa=Il-I #amperes\nT=(0.159*f*Z*Ia*P)/A\n\n#result\nprint \" Torque = \" , round(T,2) , \"N-m\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Torque = 373.97 N-m\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.12 , Page number 214", "cell_type": "markdown", "metadata": {}}, {"execution_count": 12, "cell_type": "code", "source": "#calcute the num of prim turns and prim $sec current\n\n#variable declaration\nKVA = 50.0\nE1 = 6000.0 #volts\nE2 = 250.0 #volts\nN2 = 52.0 #number of turns\n\n#calculation\nN1=N2*E1/E2\nI2=KVA*1000/E2 #ampere\nI1=KVA*1000/E1 #ampere\n\n#result\nprint \" primary number of turns = \" , N1 , \"turns\"\nprint \" secondary current = \" , I2, \"amperes\"\nprint \" primary current = \" , round(I1,2), \"amperes\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " primary number of turns = 1248.0 turns\n secondary current = 200.0 amperes\n primary current = 8.33 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.13 , Page number 215", "cell_type": "markdown", "metadata": {}}, {"execution_count": 13, "cell_type": "code", "source": "#determine the emf induced in the secondry max value of flux density\n\n#calculation\nf=50 #Hz\nN1=350 #turns\nN2=800 #turns\nE1=400 #volts\nA=75e-4 #m**2\n\n#calculation\nE2=(N2*E1)/N1 #volts\nBm=E1/(4.44*f*A*N1) #Wb/m**2\n\n#result\nprint \" flux density = \" , round(Bm,3) , \"wb/m**2\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " flux density = 0.686 wb/m**2\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.14 , Page number 215", "cell_type": "markdown", "metadata": {}}, {"execution_count": 14, "cell_type": "code", "source": "import math\n\n#find the magnetic nd iron loss component of current\n\n#variable declaration\nE1=440 #volts\nE2=200 #volts\nI=0.2 #amperea\ncoso=0.18 #p.f.\n\n#calculation\nsino= math.sqrt(1-coso**2) \nIw=I*coso #ampere\nIu=I*sino #ampere\n\n#result\nprint \" Magnetising compenet of current = \" , round(Iw,3), \"amperes\"\nprint \" iron loss compenet of current = \" , round(Iu,4), \"amperes\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " Magnetising compenet of current = 0.036 amperes\n iron loss compenet of current = 0.1967 amperes\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.15 , Page number 216", "cell_type": "markdown", "metadata": {}}, {"execution_count": 15, "cell_type": "code", "source": "#calculate the efficiency at loads\n\n#variable declaration\nKVA=20\nIl=350 #iron loss\nCl=400 #copper loss\nx=1 # fraction of load\npf=0.8 # at full load\npf1=0.4 #at half load\nx1=0.5 #fraction of load\n\n#calculation\nop=KVA*1000*x*pf\nop1=KVA*1000*x1*pf1\nTl=Il+(Cl*x*x)\nTl1=Il+(Cl*x1*x1)\nip=op+Tl\nip1=op1+Tl1\nn=op/ip*100\nn1=op1/ip1*100\n\n#result\nprint \"efficiency at half load = \" , round(n,2) \nprint \"efficiency at full load = \" , round(n1,2) \n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "efficiency at half load = 95.52\nefficiency at full load = 89.89\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.16 , Page number 221", "cell_type": "markdown", "metadata": {}}, {"execution_count": 16, "cell_type": "code", "source": "#calculate the synchronous speed ,slip,frequncy induced emf\n\n#variable declaration\nf=50.0 #Hz\np=4 #poles \nN=1460.0 #rpm\n\n#calculation\nNs=120*f/p #rpm\ns=(Ns-N)/Ns #slip\nf1=(s*f) #Hz\n\n#result\nprint \"synchronous speed Ns = \" , Ns , \"rpm\"\nprint \"slip s = \" , round(s,3)\nprint \" Frequency of rotor induced emf f = \" , round(f1,2) , \"Hz\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "synchronous speed Ns = 1500.0 rpm\nslip s = 0.027\n Frequency of rotor induced emf f = 1.33 Hz\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.17 , Page number 222", "cell_type": "markdown", "metadata": {}}, {"execution_count": 17, "cell_type": "code", "source": "#determine the value of slip nd speed of motor\n\n#variable declaration\nP=6 #pole\nf=50 #Hz\nf1=1.5\n\n#calculation\nNs=120*f/P\ns=f1/f\nN=Ns*(1-s)\n\n#result\nprint \" speed of motor = \", N, \" RPM\"\nprint \" slip = \" , round(s,3)\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " speed of motor = 970.0 RPM\n slip = 0.03\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.18 , Page number 222", "cell_type": "markdown", "metadata": {}}, {"execution_count": 18, "cell_type": "code", "source": "#calculate the numbers of poles ,slip at full load,frequncy rotor,speed of motor\n\n#variable declaration\nNs=1000.0 #rpm\nN=960\nf=50 #Hz\n\n#calculation\nP=120*f/Ns #synchronous speed\ns=(Ns-N)/Ns #slip \nf1=s*f #Hz\nN=Ns*(1-0.08) #speed of motor at 8% slip\n\n#result\nprint \" number of poles p = \" , P\nprint \" slip s = \" , round(s,2)\nprint \" Frequency of rotor emf f = \" , f , \"Hz\"\nprint \" Speed of motor at 8% slip N = \" , N , \"RPM\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": " number of poles p = 6.0\n slip s = 0.04\n Frequency of rotor emf f = 50 Hz\n Speed of motor at 8% slip N = 920.0 RPM\n"}], "metadata": {"collapsed": false, "trusted": true}}, {"source": "##Example 5.19 , Page number 231", "cell_type": "markdown", "metadata": {}}, {"execution_count": 19, "cell_type": "code", "source": "#calculate the induced emf per phase\n\n#variable declaration\nf=50 #Hz\nP=16 #poles\nN=160 #rpm\nS=6 #slip\nF=0.025 #flux\n\n#calculation\nn=N*S #conductors\nZ=n/3 \ne=2.22*F*f*Z #rms value\n\n#result\nprint \"Induced emf per phase e = \" , e , \"volts\"\n", "outputs": [{"output_type": "stream", "name": "stdout", "text": "Induced emf per phase e = 888.0 volts\n"}], "metadata": {"collapsed": false, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.8", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}} \ No newline at end of file diff --git a/sample_notebooks/Mayur Phadtare/Mayur Phadtare_version_backup/chapter.3.ipynb b/sample_notebooks/Mayur Phadtare/Mayur Phadtare_version_backup/chapter.3.ipynb new file mode 100644 index 00000000..7cace9d2 --- /dev/null +++ b/sample_notebooks/Mayur Phadtare/Mayur Phadtare_version_backup/chapter.3.ipynb @@ -0,0 +1,589 @@ +{ + "metadata": { + "name": "chapter no.3.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 3:Coplanar Parallel forces" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.1,Page No.48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AB=L_BC=L_CD=L_DA=2 #m\n", + "\n", + "#Loads\n", + "F_B=10 #N\n", + "F_C=20 #N\n", + "F_D=30 #N\n", + "F_A=40 #N\n", + "\n", + "#Calculations\n", + "\n", + "#Taking Moment at point A\n", + "#As the Forces F_A & F_B pass through point A,these Forces will be zero\n", + "#Resultant Moment of all Forces\n", + "M_A=-(-F_D*L_DA-F_C*L_CD) #N.m\n", + "\n", + "#Result\n", + "print\"Resultant Moment about point A is\",round(M_A,2),\"N.m (Anticlockwise)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant Moment about point A is 100.0 N.m (Anticlockwise)\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.2,Page No.50" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "F_A=100 #N\n", + "OCB=60 #Degrees\n", + "L_OC=3 #m\n", + "\n", + "#Calculations\n", + "\n", + "#Triangle OBC is a right Angled triangle\n", + "L_OB=L_OC*sin(60*pi*180**-1)\n", + "\n", + "#Moment of force 100 #N about o\n", + "M_O=F_A*L_OB #Nm\n", + "\n", + "#Result\n", + "print\"Moment of Force about O is\",round(M_O,2),\"Nm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Moment of Force about O is 259.81 Nm\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.3,Page No.54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AB=30 #cm\n", + "L_BC=40 #cm\n", + "\n", + "#Loads\n", + "F_A=100 #N\n", + "F_B=200 #N\n", + "F_C=300 #N\n", + "\n", + "#Calculations\n", + "\n", + "#resultant of all forces\n", + "R=F_A+F_B+F_C #N\n", + "\n", + "#Let resultant be acting at distance x from point A\n", + "\n", + "#Now taking moments at point A\n", + "M_A=-(-F_C*(L_AB+L_BC)-F_B*L_AB) #N.m\n", + "\n", + "#Moment of resultant R about A\n", + "#M_R=R*x\n", + "\n", + "#But algebraic sum of moments of all forces about A = Moment of resultant about A\n", + "x=M_A*R**-1\n", + "\n", + "#Result\n", + "print\"Resultant is\",round(R,2),\"N\"\n", + "print\"Distance of resultant from point A\",round(x,2),\"cm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant is 600.0 N\n", + "Distance of resultant from point A 45.0 cm\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.4,Page No.54" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AC=4 #m\n", + "L_CD=3 #m\n", + "L_AD=7 #m\n", + "\n", + "#Forces\n", + "F_A=50 #N\n", + "F_D=100 #N\n", + "R=250 #N #Resultant \n", + "\n", + "#Calculations\n", + "\n", + "#Part-1\n", + "#Magnitude of Force F_B\n", + "F=R-F_A-F_D #N\n", + "\n", + "#Part-2\n", + "#Distance from pt A\n", + "#Taking Moment of all forces at pt A\n", + "#M_A=0\n", + "#Now moments of all forces = Moment of Resultant\n", + "#After simplifying further we get\n", + "x=(R*L_AC-F_D*L_AD)*F_B**-1 #m\n", + "\n", + "#Result\n", + "print\"Magnitude of Force F is\",round(F,2),\"N\"\n", + "print\"Distance of force f from A is\",round(x,2),\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Magnitude of Force F is 100.0 N\n", + "Distance of force f from A is 3.0 m\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.5,Page No.55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AB=0.9 #m\n", + "L_BC=1.2 #m\n", + "L_CD=0.75 #m\n", + "L=L_AB+L_BC+L_CD #m\n", + "\n", + "#Forces\n", + "F_A=100 #N\n", + "F_B=150 #N\n", + "F_C=25 #N\n", + "F_D=200 #N\n", + "\n", + "#Calculations\n", + "\n", + "#Part-1\n", + "#Magnitude of Resultant\n", + "R=F_A-F_B-F_C+F_D #N\n", + "\n", + "#Part-2\n", + "#Let x be the distance of Resultant from A\n", + "x=-(F_B*L_AB+F_C*(L_AB+L_BC)-F_D*L)*R**-1 #m\n", + "\n", + "#Result\n", + "print\"Magnitude of Resultant\",round(R,2),\"N\"\n", + "print\"Distance of Resultant from x is\",round(x,2),\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Magnitude of Resultant 125.0 N\n", + "Distance of Resultant from x is 3.06 m\n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.6,Page No.57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AC=L_CD=1 #m\n", + "L_DB=1.5 #m\n", + "L=3.5 #m\n", + "\n", + "#Forces\n", + "F_A=32.5 #N\n", + "F_C=150 #N\n", + "F_D=67.5 #N\n", + "F_B=10 #N\n", + "\n", + "#Calculations\n", + "\n", + "#Part-1\n", + "\n", + "#Single Force ststem\n", + "R=-(F_A-F_C+F_D-F_B) #N\n", + "\n", + "#Let x be the distance of Resultant from A\n", + "x=-(F_C*L_AC-F_D*(L_AC+L_CD)+F_B*L)*R**-1 #m\n", + "\n", + "#Part-2\n", + "\n", + "#Single Force is given By R\n", + "\n", + "#Now moment of couple at pt A\n", + "M_A=-R*round(x,2) #N.m\n", + "\n", + "#Part-3\n", + "\n", + "#Now couple at B\n", + "L_BE=L+x\n", + "M_B=R*round(L_BE,3) #N.m\n", + "\n", + "#Result\n", + "print\"Single Force is\",round(R,2),\"N\"\n", + "print\"Couple at A\",round(M_A,2),\"N.m\"\n", + "print\"Couple at B\",round(M_B,2),\"N.m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2.66666666667\n", + "Single Force is 60.0 N\n", + "Couple at A 49.8 N.m\n", + "Couple at B 160.02 N.m\n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.7,Page No.59" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AB=L_DE=0.6 #m\n", + "L_BC=0.9 #m\n", + "L_CD=1.2 #m\n", + "\n", + "#Forces\n", + "F_A=4 #N\n", + "F_B=8 #N\n", + "F_C=8 #N\n", + "F_D=16 #N\n", + "F_E=12 #N\n", + "\n", + "#Calculations\n", + "\n", + "#Resultant Of All Forces\n", + "R=-F_A+F_B-F_C+F_D-F_E #N\n", + "\n", + "#As the Resultatn Force is zero,tere will be two possibilities.The system will have a resultant coup\n", + "#Algebraic sum of moments of all forces about A\n", + "M_A=-F_B*L_AB+F_C*(L_AB+L_BC)-F_D*(L_AB+L_BC+L_CD)+F_E*(L_AB+L_BC+L_CD+L_DE) #N.m\n", + "\n", + "#As the algebraic sum of moments of all forces is not zero,the ststem will have couple of magnitude 3.6 #N.m\n", + "\n", + "#Result\n", + "print\"Resultant of Parallel Forces is\",round(R,2),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant of Parallel Forces is 0.0 N\n" + ] + } + ], + "prompt_number": 56 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.8,Page No.59" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "L_AB=L_DE=2 #m\n", + "L_BC=0.5 #m\n", + "L_CD=0.5 #m\n", + "\n", + "#Forces\n", + "F_A=20 #N\n", + "F_B=20 #N\n", + "F_C=40 #N\n", + "F_D=30 #N\n", + "F_E=10 #N\n", + "\n", + "\n", + "#Calculations\n", + "\n", + "#Resultant Of All Forces\n", + "R=-F_A+F_B+F_C-F_D-F_E #N\n", + "\n", + "#As the Resultant is zero and also the resultant force on the body is zero,the body will be in equilibrium\n", + "\n", + "#Result\n", + "print\"Resultant of Parallel Forces is\",round(R,2),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant of Parallel Forces is 0.0 N\n" + ] + } + ], + "prompt_number": 58 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.9,Page No.60" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Distances\n", + "L_OA=200 #mm\n", + "L_OB=100 #mm\n", + "L_BC=200 #mm\n", + "\n", + "COA=90 #Degrees\n", + "\n", + "#Forces\n", + "F_A=2000 #N\n", + "F_B=1500 #N\n", + "F_C=1000 #N\n", + "\n", + "#Calculations\n", + "\n", + "#Resolving FOrce A in two components\n", + "F_A1=F_A*cos(30*pi*180**-1) #Component along x-axis\n", + "F_A2=F_A*sin(30*pi*180**-1) #Component along y-axis\n", + "\n", + "#Resolving all forces along X-axis\n", + "F_x=F_A1-F_B-F_C\n", + "F_y=F_A2\n", + "\n", + "#Resultant \n", + "R=(F_x**2+F_y**2)**0.5 #N\n", + "\n", + "#Taking Moments of all forces about pt O\n", + "M_o=-(F_y*L_OA-F_B*L_OB-F_C*(L_BC+L_OB)) #N.mm\n", + "\n", + "#Result\n", + "print\"Equivalent system through point O is:Resultant\",round(R,2),\"N\"\n", + "print\" :Moment\",round(M_o,2),\"N.mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Equivalent system through point O is:Resultant 1260.85 N\n", + " :Moment 250000.0 N.mm\n" + ] + } + ], + "prompt_number": 63 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3.10,Page No.61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration Of Variables\n", + "\n", + "#Lengths\n", + "L_AC=1 #m\n", + "L_CB=1.5 #m\n", + "L_CD=0.8 #m\n", + "L_DB=0.7 #m\n", + "L=2.5 #m\n", + "\n", + "#Forces\n", + "F_C=4000 #N\n", + "F_B=2500 #N\n", + "M_D=2000 #N*m\n", + "\n", + "#Calculations\n", + "\n", + "#Resultant of all forces\n", + "R=-F_C+F_B #N\n", + "\n", + "#As the Force is acting in downward direction,so negative sign\n", + "R2=-R\n", + "\n", + "#Sum of Moments of all Forces\n", + "M=(F_C*L_AC+M_D-F_B*L)\n", + "M2=-M #Anticlockwise\n", + "\n", + "#Now distance of resultant from x is\n", + "x=(F_C*L_AC+M_D-F_B*L)*R2**-1\n", + "\n", + "#Negative sign indicates that it acts left of A\n", + "x2=-x\n", + "\n", + "#Result\n", + "print\"Resultant of the system\",round(R2,2),\"N\"\n", + "print\"Equivalent system through A\",round(M2,2),\"N.m (Anticlockwise)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant of the system 1500.0 N\n", + "Equivalent system through A 250.0 N.m (Anticlockwise)\n" + ] + } + ], + "prompt_number": 72 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Mayur Phadtare/chapter_no.3.ipynb b/sample_notebooks/Mayur Phadtare/chapter_no.3.ipynb deleted file mode 100644 index 7cace9d2..00000000 --- a/sample_notebooks/Mayur Phadtare/chapter_no.3.ipynb +++ /dev/null @@ -1,589 +0,0 @@ -{ - "metadata": { - "name": "chapter no.3.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 3:Coplanar Parallel forces" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.1,Page No.48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AB=L_BC=L_CD=L_DA=2 #m\n", - "\n", - "#Loads\n", - "F_B=10 #N\n", - "F_C=20 #N\n", - "F_D=30 #N\n", - "F_A=40 #N\n", - "\n", - "#Calculations\n", - "\n", - "#Taking Moment at point A\n", - "#As the Forces F_A & F_B pass through point A,these Forces will be zero\n", - "#Resultant Moment of all Forces\n", - "M_A=-(-F_D*L_DA-F_C*L_CD) #N.m\n", - "\n", - "#Result\n", - "print\"Resultant Moment about point A is\",round(M_A,2),\"N.m (Anticlockwise)\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant Moment about point A is 100.0 N.m (Anticlockwise)\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.2,Page No.50" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "F_A=100 #N\n", - "OCB=60 #Degrees\n", - "L_OC=3 #m\n", - "\n", - "#Calculations\n", - "\n", - "#Triangle OBC is a right Angled triangle\n", - "L_OB=L_OC*sin(60*pi*180**-1)\n", - "\n", - "#Moment of force 100 #N about o\n", - "M_O=F_A*L_OB #Nm\n", - "\n", - "#Result\n", - "print\"Moment of Force about O is\",round(M_O,2),\"Nm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Moment of Force about O is 259.81 Nm\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.3,Page No.54" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AB=30 #cm\n", - "L_BC=40 #cm\n", - "\n", - "#Loads\n", - "F_A=100 #N\n", - "F_B=200 #N\n", - "F_C=300 #N\n", - "\n", - "#Calculations\n", - "\n", - "#resultant of all forces\n", - "R=F_A+F_B+F_C #N\n", - "\n", - "#Let resultant be acting at distance x from point A\n", - "\n", - "#Now taking moments at point A\n", - "M_A=-(-F_C*(L_AB+L_BC)-F_B*L_AB) #N.m\n", - "\n", - "#Moment of resultant R about A\n", - "#M_R=R*x\n", - "\n", - "#But algebraic sum of moments of all forces about A = Moment of resultant about A\n", - "x=M_A*R**-1\n", - "\n", - "#Result\n", - "print\"Resultant is\",round(R,2),\"N\"\n", - "print\"Distance of resultant from point A\",round(x,2),\"cm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant is 600.0 N\n", - "Distance of resultant from point A 45.0 cm\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.4,Page No.54" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AC=4 #m\n", - "L_CD=3 #m\n", - "L_AD=7 #m\n", - "\n", - "#Forces\n", - "F_A=50 #N\n", - "F_D=100 #N\n", - "R=250 #N #Resultant \n", - "\n", - "#Calculations\n", - "\n", - "#Part-1\n", - "#Magnitude of Force F_B\n", - "F=R-F_A-F_D #N\n", - "\n", - "#Part-2\n", - "#Distance from pt A\n", - "#Taking Moment of all forces at pt A\n", - "#M_A=0\n", - "#Now moments of all forces = Moment of Resultant\n", - "#After simplifying further we get\n", - "x=(R*L_AC-F_D*L_AD)*F_B**-1 #m\n", - "\n", - "#Result\n", - "print\"Magnitude of Force F is\",round(F,2),\"N\"\n", - "print\"Distance of force f from A is\",round(x,2),\"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Magnitude of Force F is 100.0 N\n", - "Distance of force f from A is 3.0 m\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.5,Page No.55" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AB=0.9 #m\n", - "L_BC=1.2 #m\n", - "L_CD=0.75 #m\n", - "L=L_AB+L_BC+L_CD #m\n", - "\n", - "#Forces\n", - "F_A=100 #N\n", - "F_B=150 #N\n", - "F_C=25 #N\n", - "F_D=200 #N\n", - "\n", - "#Calculations\n", - "\n", - "#Part-1\n", - "#Magnitude of Resultant\n", - "R=F_A-F_B-F_C+F_D #N\n", - "\n", - "#Part-2\n", - "#Let x be the distance of Resultant from A\n", - "x=-(F_B*L_AB+F_C*(L_AB+L_BC)-F_D*L)*R**-1 #m\n", - "\n", - "#Result\n", - "print\"Magnitude of Resultant\",round(R,2),\"N\"\n", - "print\"Distance of Resultant from x is\",round(x,2),\"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Magnitude of Resultant 125.0 N\n", - "Distance of Resultant from x is 3.06 m\n" - ] - } - ], - "prompt_number": 33 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.6,Page No.57" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AC=L_CD=1 #m\n", - "L_DB=1.5 #m\n", - "L=3.5 #m\n", - "\n", - "#Forces\n", - "F_A=32.5 #N\n", - "F_C=150 #N\n", - "F_D=67.5 #N\n", - "F_B=10 #N\n", - "\n", - "#Calculations\n", - "\n", - "#Part-1\n", - "\n", - "#Single Force ststem\n", - "R=-(F_A-F_C+F_D-F_B) #N\n", - "\n", - "#Let x be the distance of Resultant from A\n", - "x=-(F_C*L_AC-F_D*(L_AC+L_CD)+F_B*L)*R**-1 #m\n", - "\n", - "#Part-2\n", - "\n", - "#Single Force is given By R\n", - "\n", - "#Now moment of couple at pt A\n", - "M_A=-R*round(x,2) #N.m\n", - "\n", - "#Part-3\n", - "\n", - "#Now couple at B\n", - "L_BE=L+x\n", - "M_B=R*round(L_BE,3) #N.m\n", - "\n", - "#Result\n", - "print\"Single Force is\",round(R,2),\"N\"\n", - "print\"Couple at A\",round(M_A,2),\"N.m\"\n", - "print\"Couple at B\",round(M_B,2),\"N.m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "2.66666666667\n", - "Single Force is 60.0 N\n", - "Couple at A 49.8 N.m\n", - "Couple at B 160.02 N.m\n" - ] - } - ], - "prompt_number": 53 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.7,Page No.59" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AB=L_DE=0.6 #m\n", - "L_BC=0.9 #m\n", - "L_CD=1.2 #m\n", - "\n", - "#Forces\n", - "F_A=4 #N\n", - "F_B=8 #N\n", - "F_C=8 #N\n", - "F_D=16 #N\n", - "F_E=12 #N\n", - "\n", - "#Calculations\n", - "\n", - "#Resultant Of All Forces\n", - "R=-F_A+F_B-F_C+F_D-F_E #N\n", - "\n", - "#As the Resultatn Force is zero,tere will be two possibilities.The system will have a resultant coup\n", - "#Algebraic sum of moments of all forces about A\n", - "M_A=-F_B*L_AB+F_C*(L_AB+L_BC)-F_D*(L_AB+L_BC+L_CD)+F_E*(L_AB+L_BC+L_CD+L_DE) #N.m\n", - "\n", - "#As the algebraic sum of moments of all forces is not zero,the ststem will have couple of magnitude 3.6 #N.m\n", - "\n", - "#Result\n", - "print\"Resultant of Parallel Forces is\",round(R,2),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant of Parallel Forces is 0.0 N\n" - ] - } - ], - "prompt_number": 56 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.8,Page No.59" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "L_AB=L_DE=2 #m\n", - "L_BC=0.5 #m\n", - "L_CD=0.5 #m\n", - "\n", - "#Forces\n", - "F_A=20 #N\n", - "F_B=20 #N\n", - "F_C=40 #N\n", - "F_D=30 #N\n", - "F_E=10 #N\n", - "\n", - "\n", - "#Calculations\n", - "\n", - "#Resultant Of All Forces\n", - "R=-F_A+F_B+F_C-F_D-F_E #N\n", - "\n", - "#As the Resultant is zero and also the resultant force on the body is zero,the body will be in equilibrium\n", - "\n", - "#Result\n", - "print\"Resultant of Parallel Forces is\",round(R,2),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant of Parallel Forces is 0.0 N\n" - ] - } - ], - "prompt_number": 58 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.9,Page No.60" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Distances\n", - "L_OA=200 #mm\n", - "L_OB=100 #mm\n", - "L_BC=200 #mm\n", - "\n", - "COA=90 #Degrees\n", - "\n", - "#Forces\n", - "F_A=2000 #N\n", - "F_B=1500 #N\n", - "F_C=1000 #N\n", - "\n", - "#Calculations\n", - "\n", - "#Resolving FOrce A in two components\n", - "F_A1=F_A*cos(30*pi*180**-1) #Component along x-axis\n", - "F_A2=F_A*sin(30*pi*180**-1) #Component along y-axis\n", - "\n", - "#Resolving all forces along X-axis\n", - "F_x=F_A1-F_B-F_C\n", - "F_y=F_A2\n", - "\n", - "#Resultant \n", - "R=(F_x**2+F_y**2)**0.5 #N\n", - "\n", - "#Taking Moments of all forces about pt O\n", - "M_o=-(F_y*L_OA-F_B*L_OB-F_C*(L_BC+L_OB)) #N.mm\n", - "\n", - "#Result\n", - "print\"Equivalent system through point O is:Resultant\",round(R,2),\"N\"\n", - "print\" :Moment\",round(M_o,2),\"N.mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Equivalent system through point O is:Resultant 1260.85 N\n", - " :Moment 250000.0 N.mm\n" - ] - } - ], - "prompt_number": 63 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3.10,Page No.61" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration Of Variables\n", - "\n", - "#Lengths\n", - "L_AC=1 #m\n", - "L_CB=1.5 #m\n", - "L_CD=0.8 #m\n", - "L_DB=0.7 #m\n", - "L=2.5 #m\n", - "\n", - "#Forces\n", - "F_C=4000 #N\n", - "F_B=2500 #N\n", - "M_D=2000 #N*m\n", - "\n", - "#Calculations\n", - "\n", - "#Resultant of all forces\n", - "R=-F_C+F_B #N\n", - "\n", - "#As the Force is acting in downward direction,so negative sign\n", - "R2=-R\n", - "\n", - "#Sum of Moments of all Forces\n", - "M=(F_C*L_AC+M_D-F_B*L)\n", - "M2=-M #Anticlockwise\n", - "\n", - "#Now distance of resultant from x is\n", - "x=(F_C*L_AC+M_D-F_B*L)*R2**-1\n", - "\n", - "#Negative sign indicates that it acts left of A\n", - "x2=-x\n", - "\n", - "#Result\n", - "print\"Resultant of the system\",round(R2,2),\"N\"\n", - "print\"Equivalent system through A\",round(M2,2),\"N.m (Anticlockwise)\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant of the system 1500.0 N\n", - "Equivalent system through A 250.0 N.m (Anticlockwise)\n" - ] - } - ], - "prompt_number": 72 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MeenaChandrupatla/Chapter2.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter2.ipynb new file mode 100755 index 00000000..88d5cb73 --- /dev/null +++ b/sample_notebooks/MeenaChandrupatla/Chapter2.ipynb @@ -0,0 +1,187 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Gases" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1,Page no.9" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "volume occupied by 20 grams of carbon dioxide= 11.61 liter\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "G= 20 #in grams\n", + "R= 0.08205 #l−atm/mole K\n", + "T= 30 #in Celsius\n", + "P= 740 #in mm\n", + "M= 44.01 \n", + "#CALCULATIONS\n", + "V= G*R*(273.15+T)*760/(P*M)\n", + "#RESULTS\n", + "V=round(V,2)\n", + "print 'volume occupied by 20 grams of carbon dioxide=',V,'liter'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2, Page no.9" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "molecular weight of hydrocarbon= 102.32 g.mole\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "G= 0.110 #in grams\n", + "R= 0.08205 #l−atm /mole K\n", + "T= 26.1 #Celsius\n", + "P= 743 #in mm\n", + "V= 0.0270\n", + "#CALCULATIONS\n", + "M= G*R*(273.15+T)*760/(P*V)\n", + "#RESULTS\n", + "M=round(M,2)\n", + "print 'molecular weight of hydrocarbon=',M,'g.mole'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4,Pg.no.10" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "pressure calculated using ideal gas law= 48.93 atm\n", + "pressure calculated using vander wals equation= 39.12 atm\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "R= 0.08205 #l−atm degˆ−1 moleˆ−1\n", + "T= 25 #in K\n", + "n= 1 #mole\n", + "V= 0.5 #liter \n", + "b= 0.04267 #lit moleˆ−1\n", + "a= 3.592 #lit ˆ2 atm molˆ−2\n", + "#CALCULATIONS\n", + "P= R*(273.15+T)/V\n", + "P1= (R*(273.15+T)/(V-b))-(a/V**2)\n", + "#RESULTS\n", + "P=round(P,2)\n", + "P1=round(P1,2)\n", + "print 'pressure calculated using ideal gas law=',P,'atm'\n", + "print 'pressure calculated using vander wals equation=',P1,'atm'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5,Pg.no.10" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "volume occupied by mole of oxygen= 0.272 litre moleˆ−1\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "T= -88 #in Celsius\n", + "Tc= 154.4 #in Kelvin\n", + "Pc= 49.7 #pressure in atm\n", + "P= 44.7 #pressure in atm\n", + "R= 0.08205 #atm mˆ3 moleˆ−1 Kˆ−1\n", + "r= 0.8\n", + "#CALCULATIONS\n", + "V= r*R*(273.15+T)/P\n", + "#RESULTS\n", + "V=round(V,3)\n", + "print 'volume occupied by mole of oxygen=',V,'litre moleˆ−1'" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/MeenaChandrupatla/Chapter2_Gases.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter2_Gases.ipynb deleted file mode 100755 index 88d5cb73..00000000 --- a/sample_notebooks/MeenaChandrupatla/Chapter2_Gases.ipynb +++ /dev/null @@ -1,187 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Gases" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.1,Page no.9" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "volume occupied by 20 grams of carbon dioxide= 11.61 liter\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "G= 20 #in grams\n", - "R= 0.08205 #l−atm/mole K\n", - "T= 30 #in Celsius\n", - "P= 740 #in mm\n", - "M= 44.01 \n", - "#CALCULATIONS\n", - "V= G*R*(273.15+T)*760/(P*M)\n", - "#RESULTS\n", - "V=round(V,2)\n", - "print 'volume occupied by 20 grams of carbon dioxide=',V,'liter'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.2, Page no.9" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "molecular weight of hydrocarbon= 102.32 g.mole\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "G= 0.110 #in grams\n", - "R= 0.08205 #l−atm /mole K\n", - "T= 26.1 #Celsius\n", - "P= 743 #in mm\n", - "V= 0.0270\n", - "#CALCULATIONS\n", - "M= G*R*(273.15+T)*760/(P*V)\n", - "#RESULTS\n", - "M=round(M,2)\n", - "print 'molecular weight of hydrocarbon=',M,'g.mole'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.4,Pg.no.10" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "pressure calculated using ideal gas law= 48.93 atm\n", - "pressure calculated using vander wals equation= 39.12 atm\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "R= 0.08205 #l−atm degˆ−1 moleˆ−1\n", - "T= 25 #in K\n", - "n= 1 #mole\n", - "V= 0.5 #liter \n", - "b= 0.04267 #lit moleˆ−1\n", - "a= 3.592 #lit ˆ2 atm molˆ−2\n", - "#CALCULATIONS\n", - "P= R*(273.15+T)/V\n", - "P1= (R*(273.15+T)/(V-b))-(a/V**2)\n", - "#RESULTS\n", - "P=round(P,2)\n", - "P1=round(P1,2)\n", - "print 'pressure calculated using ideal gas law=',P,'atm'\n", - "print 'pressure calculated using vander wals equation=',P1,'atm'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.5,Pg.no.10" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "volume occupied by mole of oxygen= 0.272 litre moleˆ−1\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "T= -88 #in Celsius\n", - "Tc= 154.4 #in Kelvin\n", - "Pc= 49.7 #pressure in atm\n", - "P= 44.7 #pressure in atm\n", - "R= 0.08205 #atm mˆ3 moleˆ−1 Kˆ−1\n", - "r= 0.8\n", - "#CALCULATIONS\n", - "V= r*R*(273.15+T)/P\n", - "#RESULTS\n", - "V=round(V,3)\n", - "print 'volume occupied by mole of oxygen=',V,'litre moleˆ−1'" - ] - } - ], - "metadata": { - "anaconda-cloud": {}, - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic.ipynb new file mode 100755 index 00000000..5503c007 --- /dev/null +++ b/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic.ipynb @@ -0,0 +1,289 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1,Page number 6" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current in circuit is 0.3672\n" + ] + } + ], + "source": [ + "from math import pi\n", + "import math \n", + "# given\n", + "Bc=0.8\n", + "Hc=510\n", + "Bg=0.8\n", + "A=12.566 \n", + "lg=0.0015\n", + "lc=0.36\n", + "N=500\n", + "# calculations\n", + "Fg=Bg/A*(2*lg)\n", + "Fc=Hc*lc\n", + "F=Fc+Fg\n", + "i=F/N\n", + "Pre=Bc/Hc\n", + "RelPre=Pre/A\n", + "F=Hc*lc\n", + "i=F /N #current\n", + "print 'The current in circuit is ',i\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2,Page number 7" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The flux density is 5\n" + ] + } + ], + "source": [ + "from math import pi\n", + "A=12.566 \n", + "lc=360\n", + "N=500\n", + "i=4\n", + "lg=2*10**-3\n", + "m=-A*(lc/lg)\n", + "c=(N*i*A)/(lg)\n", + "Hc=(N*i)/(lc) #flux density\n", + "print 'The flux density is',Hc" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3,Page number 7" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The airgap flux value is -7.47688567997e-07\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "N1=500\n", + "I1=10\n", + "N2=500\n", + "I2=10\n", + "Ibafe=3*52*10**-2\n", + "A=12.566\n", + "b=1200\n", + "Ag=4*10^-4\n", + "Ac=4*10^-4\n", + "lg=5*10^-3\n", + "Ibecore=0.515\n", + "c=0.0002067\n", + "d=0.0004134\n", + "#calculations\n", + "F1=N1*I1\n", + "F2=N2*I2\n", + "Pre=1200*A\n", + "Rbafe=(Ibafe)/(Pre*Ac)\n", + "Rg=lg/(A*Ag)\n", + "Rbecore=Ibecore/(Pre*Ac)\n", + "Bg=d/(Ag)\n", + "Hg=Bg/A # airgap flux\n", + "print 'The airgap flux value is',Hg\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4,Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The magnetic flux is 0.153938040026\n" + ] + } + ], + "source": [ + "from math import pi\n", + "# given \n", + "Irad=20\n", + "Orad=25\n", + "Dia=22.5\n", + "N=250\n", + "i=2.5\n", + "B=1.225\n", + "# calculations\n", + "l=2*pi*Dia*10**-2\n", + "radius=1/2*(Irad+Orad)\n", + "H=(N*i)/l\n", + "A=pi*((Orad -Irad)/2)**2*10**-4\n", + "z=(1.225)*(pi*6.25*10**-4)\n", + "y=(N*z)\n", + "L=(y/i)\n", + "core=(B/H)\n", + "l=(2*pi*22.5*10**-2)\n", + "Rcore=(l)/(core*A)\n", + "L=(N**2)/(Rcore)\n", + "print 'The magnetic flux is',L" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 5,Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "flux density 144.0\n" + ] + } + ], + "source": [ + "import math\n", + "# given\n", + "n=500\n", + "E=100\n", + "A=0.001\n", + "b=1/120\n", + "f=1.2\n", + "#calculations\n", + "max1=(E/1000)*(b)\n", + "max2=(f*A)\n", + "E=(120*n*max2*2) # result\n", + "print 'flux density',E\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 6,Page number 9" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The dimension Am is 0.000210526315789\n" + ] + } + ], + "source": [ + "from math import pi\n", + "#given\n", + "lg=0.4*10**-2\n", + "Bg=0.8\n", + "Hm=42*10**3\n", + "A=4*pi*10**-7\n", + "Ag=2.5*10**-4\n", + "Bm=0.95\n", + "#calculations\n", + "Hg=Bg/A\n", + "lm=(lg/Hm)*Hg\n", + "Am=(Bg*Ag)/(Bm)\n", + "print 'The dimension Am is',Am\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic_Circuits.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic_Circuits.ipynb deleted file mode 100755 index 5503c007..00000000 --- a/sample_notebooks/MeenaChandrupatla/Chapter_1_Magnetic_Circuits.ipynb +++ /dev/null @@ -1,289 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1,Page number 6" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The current in circuit is 0.3672\n" - ] - } - ], - "source": [ - "from math import pi\n", - "import math \n", - "# given\n", - "Bc=0.8\n", - "Hc=510\n", - "Bg=0.8\n", - "A=12.566 \n", - "lg=0.0015\n", - "lc=0.36\n", - "N=500\n", - "# calculations\n", - "Fg=Bg/A*(2*lg)\n", - "Fc=Hc*lc\n", - "F=Fc+Fg\n", - "i=F/N\n", - "Pre=Bc/Hc\n", - "RelPre=Pre/A\n", - "F=Hc*lc\n", - "i=F /N #current\n", - "print 'The current in circuit is ',i\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2,Page number 7" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The flux density is 5\n" - ] - } - ], - "source": [ - "from math import pi\n", - "A=12.566 \n", - "lc=360\n", - "N=500\n", - "i=4\n", - "lg=2*10**-3\n", - "m=-A*(lc/lg)\n", - "c=(N*i*A)/(lg)\n", - "Hc=(N*i)/(lc) #flux density\n", - "print 'The flux density is',Hc" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3,Page number 7" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The airgap flux value is -7.47688567997e-07\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "N1=500\n", - "I1=10\n", - "N2=500\n", - "I2=10\n", - "Ibafe=3*52*10**-2\n", - "A=12.566\n", - "b=1200\n", - "Ag=4*10^-4\n", - "Ac=4*10^-4\n", - "lg=5*10^-3\n", - "Ibecore=0.515\n", - "c=0.0002067\n", - "d=0.0004134\n", - "#calculations\n", - "F1=N1*I1\n", - "F2=N2*I2\n", - "Pre=1200*A\n", - "Rbafe=(Ibafe)/(Pre*Ac)\n", - "Rg=lg/(A*Ag)\n", - "Rbecore=Ibecore/(Pre*Ac)\n", - "Bg=d/(Ag)\n", - "Hg=Bg/A # airgap flux\n", - "print 'The airgap flux value is',Hg\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4,Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The magnetic flux is 0.153938040026\n" - ] - } - ], - "source": [ - "from math import pi\n", - "# given \n", - "Irad=20\n", - "Orad=25\n", - "Dia=22.5\n", - "N=250\n", - "i=2.5\n", - "B=1.225\n", - "# calculations\n", - "l=2*pi*Dia*10**-2\n", - "radius=1/2*(Irad+Orad)\n", - "H=(N*i)/l\n", - "A=pi*((Orad -Irad)/2)**2*10**-4\n", - "z=(1.225)*(pi*6.25*10**-4)\n", - "y=(N*z)\n", - "L=(y/i)\n", - "core=(B/H)\n", - "l=(2*pi*22.5*10**-2)\n", - "Rcore=(l)/(core*A)\n", - "L=(N**2)/(Rcore)\n", - "print 'The magnetic flux is',L" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 5,Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "flux density 144.0\n" - ] - } - ], - "source": [ - "import math\n", - "# given\n", - "n=500\n", - "E=100\n", - "A=0.001\n", - "b=1/120\n", - "f=1.2\n", - "#calculations\n", - "max1=(E/1000)*(b)\n", - "max2=(f*A)\n", - "E=(120*n*max2*2) # result\n", - "print 'flux density',E\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 6,Page number 9" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The dimension Am is 0.000210526315789\n" - ] - } - ], - "source": [ - "from math import pi\n", - "#given\n", - "lg=0.4*10**-2\n", - "Bg=0.8\n", - "Hm=42*10**3\n", - "A=4*pi*10**-7\n", - "Ag=2.5*10**-4\n", - "Bm=0.95\n", - "#calculations\n", - "Hg=Bg/A\n", - "lm=(lg/Hm)*Hg\n", - "Am=(Bg*Ag)/(Bm)\n", - "print 'The dimension Am is',Am\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/MeenaChandrupatla/Chapter_2_The.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter_2_The.ipynb new file mode 100755 index 00000000..9406e5a1 --- /dev/null +++ b/sample_notebooks/MeenaChandrupatla/Chapter_2_The.ipynb @@ -0,0 +1,249 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 The Device" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1,Page number 7" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of voltage safety factor= 2.56\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "import math \n", + "Vpiv=1500 # peak inverse voltage\n", + "V=415 # main supply\n", + "Vf=Vpiv/(sqrt(2)*V) # voltage safety factor\n", + "Vf=round(Vf,2)\n", + "print 'value of voltage safety factor=',Vf" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2,Page number 7" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of peak inverse voltage= 683.07 volts\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "import math \n", + "Vf=2.1 # voltage safety factor \n", + "V=230 # main supply\n", + "Vpiv=sqrt(2)*Vf*V # peak inverse voltage\n", + "Vpiv=round(Vpiv,2)\n", + "print 'value of peak inverse voltage=',Vpiv,'volts'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3,Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of capacitive current= 0.0045 Amp\n" + ] + } + ], + "source": [ + "import math \n", + "C=30*10**-12 # equivalent capacitance \n", + "diffV=150*10**6 # dv/dt value of capacitor\n", + "Ic=C*(diffV) # capacitive current\n", + "print 'value of capacitive current=',Ic,'Amp'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4,Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of equivalent capacitance= 28.57 pico farad\n" + ] + } + ], + "source": [ + "import math \n", + "Ic=5.0 # capacitive current in milli amperes\n", + "difV=175.0 # dv/dt value in mega V/s\n", + "C=Ic/(difV)*10**3 # equivalent capacitance in pico farad\n", + "C=round(C,2)\n", + "print 'value of equivalent capacitance=',C,'pico farad'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5,Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of dv/dt= 240000000.0 v/s\n" + ] + } + ], + "source": [ + "import math \n", + "Ic=6*10**-3 # capacitive current\n", + "C=25*10**-12 # equivalent capacitance\n", + "diffV=Ic/C # dv/dt value of capacitor\n", + "print 'value of dv/dt=',diffV,'v/s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6,Page number 9" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of dv/dt that can trigger the device= 142 V/microseconds\n" + ] + } + ], + "source": [ + "import math \n", + "Ic=5 # capacitive current in milli amperes\n", + "C=35 # equivalent capacitance in pico farad\n", + "difV=Ic*10**3/C # value of dv/dt that can trigger the device in V/ microseconds\n", + "print 'value of dv/dt that can trigger the device=',difV,'V/microseconds'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7,Page number 9" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "value of voltage safety factor= 2.3 v\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "import math \n", + "Vpiv=1350 # peak inverse voltage in volts\n", + "V=415 # main supply in volts\n", + "Vf=Vpiv/(sqrt(2)*V) # voltage safety factor\n", + "Vf=round(Vf,2)\n", + "print 'value of voltage safety factor=',Vf,'v'" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/MeenaChandrupatla/Chapter_2_The_Device.ipynb b/sample_notebooks/MeenaChandrupatla/Chapter_2_The_Device.ipynb deleted file mode 100755 index 9406e5a1..00000000 --- a/sample_notebooks/MeenaChandrupatla/Chapter_2_The_Device.ipynb +++ /dev/null @@ -1,249 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 The Device" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.1,Page number 7" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of voltage safety factor= 2.56\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "import math \n", - "Vpiv=1500 # peak inverse voltage\n", - "V=415 # main supply\n", - "Vf=Vpiv/(sqrt(2)*V) # voltage safety factor\n", - "Vf=round(Vf,2)\n", - "print 'value of voltage safety factor=',Vf" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.2,Page number 7" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of peak inverse voltage= 683.07 volts\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "import math \n", - "Vf=2.1 # voltage safety factor \n", - "V=230 # main supply\n", - "Vpiv=sqrt(2)*Vf*V # peak inverse voltage\n", - "Vpiv=round(Vpiv,2)\n", - "print 'value of peak inverse voltage=',Vpiv,'volts'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.3,Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of capacitive current= 0.0045 Amp\n" - ] - } - ], - "source": [ - "import math \n", - "C=30*10**-12 # equivalent capacitance \n", - "diffV=150*10**6 # dv/dt value of capacitor\n", - "Ic=C*(diffV) # capacitive current\n", - "print 'value of capacitive current=',Ic,'Amp'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.4,Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of equivalent capacitance= 28.57 pico farad\n" - ] - } - ], - "source": [ - "import math \n", - "Ic=5.0 # capacitive current in milli amperes\n", - "difV=175.0 # dv/dt value in mega V/s\n", - "C=Ic/(difV)*10**3 # equivalent capacitance in pico farad\n", - "C=round(C,2)\n", - "print 'value of equivalent capacitance=',C,'pico farad'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.5,Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of dv/dt= 240000000.0 v/s\n" - ] - } - ], - "source": [ - "import math \n", - "Ic=6*10**-3 # capacitive current\n", - "C=25*10**-12 # equivalent capacitance\n", - "diffV=Ic/C # dv/dt value of capacitor\n", - "print 'value of dv/dt=',diffV,'v/s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.6,Page number 9" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of dv/dt that can trigger the device= 142 V/microseconds\n" - ] - } - ], - "source": [ - "import math \n", - "Ic=5 # capacitive current in milli amperes\n", - "C=35 # equivalent capacitance in pico farad\n", - "difV=Ic*10**3/C # value of dv/dt that can trigger the device in V/ microseconds\n", - "print 'value of dv/dt that can trigger the device=',difV,'V/microseconds'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.7,Page number 9" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "value of voltage safety factor= 2.3 v\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "import math \n", - "Vpiv=1350 # peak inverse voltage in volts\n", - "V=415 # main supply in volts\n", - "Vf=Vpiv/(sqrt(2)*V) # voltage safety factor\n", - "Vf=round(Vf,2)\n", - "print 'value of voltage safety factor=',Vf,'v'" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/MohdAnwar/MohdAnwar_version_backup/chapter1.ipynb b/sample_notebooks/MohdAnwar/MohdAnwar_version_backup/chapter1.ipynb new file mode 100755 index 00000000..d644b7e7 --- /dev/null +++ b/sample_notebooks/MohdAnwar/MohdAnwar_version_backup/chapter1.ipynb @@ -0,0 +1,443 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 01 : Antenna Principles" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.1 : page 1.42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "#given data :\n", + "E=4.0 #in V/m\n", + "Eta=120*pi #constant\n", + "#Formula : E/H=Eta\n", + "H=E/Eta #in A/m\n", + "print \"Strength of magnetic field in free space = %0.4f A/m \" %H" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Strength of magnetic field in free space = 0.0106 A/m \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.2 : page 1.42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "H=5.2 #in mA/m\n", + "Eta=120*pi #constant\n", + "#Formula : E/H=Eta\n", + "E=H*10**-3*Eta #in V/m\n", + "print \"Strength of Electric field in free space =\",round(E),\"V/m\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Strength of Electric field in free space = 2.0 V/m\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.3 : page 1.42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data :\n", + "I=20.0 #in A\n", + "Rr=100.0 #in Ohm\n", + "#Formula : Wr=I**2*R\n", + "Wr=I**2*Rr #in W\n", + "print \"Radiated power = %0.f kW \" %(Wr/1000) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radiated power = 40 kW \n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.4 : page 1.42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "#given data :\n", + "W=625.0 #in KW\n", + "r=30.0 #in Km\n", + "Erms=sqrt(90*W*1000)/(r*1000) #in V/m\n", + "print \"Strength of Electric field at 30Km away = %0.f mV/m \" %(Erms*1000) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Strength of Electric field at 30Km away = 250 mV/m \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.6 : page 1.43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "le=50.0 #in m\n", + "f=100.0 #in MHz\n", + "lamda=300.0/(f) #in m\n", + "Rr=(160*(pi)**2)*(le/lamda)**2 #in Ohm\n", + "print \"Radiation Resistance = %0.2f Mohm \" %(Rr/10**6) \n", + "#Note : Answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radiation Resistance = 0.44 Mohm \n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.7 : page 1.44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "l=30 #in m\n", + "Irms=20 #in A\n", + "f=1 #in MHz\n", + "r=10 #in Km\n", + "r=r*1000 #in m\n", + "le=2*l/pi #in m\n", + "lamda=300/(f) #in m\n", + "Erms=120*pi*le*Irms/(lamda*r) #in V/m\n", + "print \"Field strength at 10Km distance = %0.2e V/m \" %Erms \n", + "#Note : Answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Field strength at 10Km distance = 4.80e-02 V/m \n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.8 : page 1.44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "Rl=1.0 #in ohm\n", + "#Formula : Rr=80*pi**2*(l/lamda)**2\n", + "#Given l=lamda/10\n", + "#l/lamda=1/10\n", + "Rr=80*pi**2*(1.0/10)**2 #in Ohm\n", + "print \"Radiation resistance = %0.2f Ohm \" %(Rr) \n", + "Eta=Rr/(Rr+Rl) #Unitless\n", + "print \"Antenna Efficiency = %0.2f %% \" %(Eta*100) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radiation resistance = 7.90 Ohm \n", + "Antenna Efficiency = 88.76 % \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.9 : page 1.44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import sqrt\n", + "#given data :\n", + "r=100 #in Km\n", + "W=100 #in KW\n", + "Erms=sqrt(90*W*1000)/(r*1000) #in V/m\n", + "print \"Strength of Electric Field = %0.2f V/m \" %Erms " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Strength of Electric Field = 0.03 V/m \n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.10 : page 1.44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "le=200.0 #in m\n", + "Irms=200 #in A\n", + "f=300 #in KHz\n", + "r=10 #in Km\n", + "c=3*10**8 #speed of light i m/s\n", + "lamda=c/(f*1000) #in m\n", + "Erms=120*pi*le*Irms/(lamda*r*10**3) #in V/m\n", + "print \"Field strength at 10Km distance = %0.4f V/m\" %(Erms) \n", + "Rr=(160*(pi)**2)*(le/lamda)**2 #in Ohm\n", + "W=Irms**2*Rr #in Watts\n", + "print \"Radiated Power = %0.2f MW \" %(W/10**6) \n", + "#Note : Answer is wrong in the book. Unit of answer in the book is written mW instead of MW by mistake." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Field strength at 10Km distance = 1.5080 V/m\n", + "Radiated Power = 2.53 MW \n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.11 : page 1.45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "#Formula : Rr=80*pi**2*(l/lamda)**2\n", + "#Given l=lamda/60\n", + "#l/lamda=1/60\n", + "Rr=80*pi**2*(1.0/60)**2 #in Ohm\n", + "print \"Radiation resistance = %0.3f Ohm \" %Rr " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Radiation resistance = 0.219 Ohm \n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.12 : page 1.45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given data :\n", + "r=10.0 #in Km\n", + "Erms=10.0 #in mV/m\n", + "r1=20.0 #in Km\n", + "#Formula : Erms=sqrt(90*W)/r #in V/m\n", + "#Let swrt(90*W)=a\n", + "a=Erms*r \n", + "Erms1=a/r1 #in mV/m\n", + "print \"Field strength at 20Km distance = %0.f mV/m \" %Erms1 " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Field strength at 20Km distance = 5 mV/m \n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.13 : page 1.45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import pi\n", + "#given data :\n", + "r=1.0 #in Km\n", + "r=1*10**3 #in m\n", + "l=1.0 #in m\n", + "Irms=10.0 #in A\n", + "f=5.0 #in MHz\n", + "c=3*10**8 #speed of light i m/s\n", + "lamda=c/(f*10**6) #in m\n", + "le=2*l/pi #in m\n", + "Erms=120*pi*le*Irms/(lamda*r) #in V/m\n", + "print \"Field strength at 10Km distance = %0.4f V/m \" %Erms\n", + "#Note : Answer in the book is wrong. Mistake during value putting." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Field strength at 10Km distance = 0.0400 V/m \n" + ] + } + ], + "prompt_number": 26 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MohdAnwar/chapter1.ipynb b/sample_notebooks/MohdAnwar/chapter1.ipynb deleted file mode 100755 index d644b7e7..00000000 --- a/sample_notebooks/MohdAnwar/chapter1.ipynb +++ /dev/null @@ -1,443 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 01 : Antenna Principles" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.1 : page 1.42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "#given data :\n", - "E=4.0 #in V/m\n", - "Eta=120*pi #constant\n", - "#Formula : E/H=Eta\n", - "H=E/Eta #in A/m\n", - "print \"Strength of magnetic field in free space = %0.4f A/m \" %H" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Strength of magnetic field in free space = 0.0106 A/m \n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.2 : page 1.42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "H=5.2 #in mA/m\n", - "Eta=120*pi #constant\n", - "#Formula : E/H=Eta\n", - "E=H*10**-3*Eta #in V/m\n", - "print \"Strength of Electric field in free space =\",round(E),\"V/m\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Strength of Electric field in free space = 2.0 V/m\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.3 : page 1.42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given data :\n", - "I=20.0 #in A\n", - "Rr=100.0 #in Ohm\n", - "#Formula : Wr=I**2*R\n", - "Wr=I**2*Rr #in W\n", - "print \"Radiated power = %0.f kW \" %(Wr/1000) " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Radiated power = 40 kW \n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.4 : page 1.42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import sqrt\n", - "#given data :\n", - "W=625.0 #in KW\n", - "r=30.0 #in Km\n", - "Erms=sqrt(90*W*1000)/(r*1000) #in V/m\n", - "print \"Strength of Electric field at 30Km away = %0.f mV/m \" %(Erms*1000) " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Strength of Electric field at 30Km away = 250 mV/m \n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.6 : page 1.43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "le=50.0 #in m\n", - "f=100.0 #in MHz\n", - "lamda=300.0/(f) #in m\n", - "Rr=(160*(pi)**2)*(le/lamda)**2 #in Ohm\n", - "print \"Radiation Resistance = %0.2f Mohm \" %(Rr/10**6) \n", - "#Note : Answer in the book is wrong" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Radiation Resistance = 0.44 Mohm \n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.7 : page 1.44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "l=30 #in m\n", - "Irms=20 #in A\n", - "f=1 #in MHz\n", - "r=10 #in Km\n", - "r=r*1000 #in m\n", - "le=2*l/pi #in m\n", - "lamda=300/(f) #in m\n", - "Erms=120*pi*le*Irms/(lamda*r) #in V/m\n", - "print \"Field strength at 10Km distance = %0.2e V/m \" %Erms \n", - "#Note : Answer in the book is wrong" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Field strength at 10Km distance = 4.80e-02 V/m \n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.8 : page 1.44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "Rl=1.0 #in ohm\n", - "#Formula : Rr=80*pi**2*(l/lamda)**2\n", - "#Given l=lamda/10\n", - "#l/lamda=1/10\n", - "Rr=80*pi**2*(1.0/10)**2 #in Ohm\n", - "print \"Radiation resistance = %0.2f Ohm \" %(Rr) \n", - "Eta=Rr/(Rr+Rl) #Unitless\n", - "print \"Antenna Efficiency = %0.2f %% \" %(Eta*100) " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Radiation resistance = 7.90 Ohm \n", - "Antenna Efficiency = 88.76 % \n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.9 : page 1.44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import sqrt\n", - "#given data :\n", - "r=100 #in Km\n", - "W=100 #in KW\n", - "Erms=sqrt(90*W*1000)/(r*1000) #in V/m\n", - "print \"Strength of Electric Field = %0.2f V/m \" %Erms " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Strength of Electric Field = 0.03 V/m \n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.10 : page 1.44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "le=200.0 #in m\n", - "Irms=200 #in A\n", - "f=300 #in KHz\n", - "r=10 #in Km\n", - "c=3*10**8 #speed of light i m/s\n", - "lamda=c/(f*1000) #in m\n", - "Erms=120*pi*le*Irms/(lamda*r*10**3) #in V/m\n", - "print \"Field strength at 10Km distance = %0.4f V/m\" %(Erms) \n", - "Rr=(160*(pi)**2)*(le/lamda)**2 #in Ohm\n", - "W=Irms**2*Rr #in Watts\n", - "print \"Radiated Power = %0.2f MW \" %(W/10**6) \n", - "#Note : Answer is wrong in the book. Unit of answer in the book is written mW instead of MW by mistake." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Field strength at 10Km distance = 1.5080 V/m\n", - "Radiated Power = 2.53 MW \n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.11 : page 1.45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "#Formula : Rr=80*pi**2*(l/lamda)**2\n", - "#Given l=lamda/60\n", - "#l/lamda=1/60\n", - "Rr=80*pi**2*(1.0/60)**2 #in Ohm\n", - "print \"Radiation resistance = %0.3f Ohm \" %Rr " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Radiation resistance = 0.219 Ohm \n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.12 : page 1.45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given data :\n", - "r=10.0 #in Km\n", - "Erms=10.0 #in mV/m\n", - "r1=20.0 #in Km\n", - "#Formula : Erms=sqrt(90*W)/r #in V/m\n", - "#Let swrt(90*W)=a\n", - "a=Erms*r \n", - "Erms1=a/r1 #in mV/m\n", - "print \"Field strength at 20Km distance = %0.f mV/m \" %Erms1 " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Field strength at 20Km distance = 5 mV/m \n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.13 : page 1.45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import pi\n", - "#given data :\n", - "r=1.0 #in Km\n", - "r=1*10**3 #in m\n", - "l=1.0 #in m\n", - "Irms=10.0 #in A\n", - "f=5.0 #in MHz\n", - "c=3*10**8 #speed of light i m/s\n", - "lamda=c/(f*10**6) #in m\n", - "le=2*l/pi #in m\n", - "Erms=120*pi*le*Irms/(lamda*r) #in V/m\n", - "print \"Field strength at 10Km distance = %0.4f V/m \" %Erms\n", - "#Note : Answer in the book is wrong. Mistake during value putting." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Field strength at 10Km distance = 0.0400 V/m \n" - ] - } - ], - "prompt_number": 26 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/Chapter2,_Measurement.ipynb b/sample_notebooks/MohdAsif/Chapter2,_Measurement.ipynb new file mode 100755 index 00000000..f8ad79f0 --- /dev/null +++ b/sample_notebooks/MohdAsif/Chapter2,_Measurement.ipynb @@ -0,0 +1,257 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:7b602763fd5a9c056abb62703a3bc42ae0cb4a39b3c349f78c056ebe58b1c643" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Precision of the 5th measurement\n", + "#Given data : Measurements taken(Unit less)\n", + "X1=98;\n", + "X2=101;\n", + "X3=102;\n", + "X4=97;\n", + "X5=101;\n", + "X6=100;\n", + "X7=103;\n", + "X8=98;\n", + "X9=106;\n", + "X10=99.0;\n", + "#Calculation\n", + "Xn_bar=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10;\n", + "Xn=101 # value of 5th measurement\n", + "P=(1-abs((Xn-Xn_bar)/Xn_bar))*100 #Precision\n", + "print \"Precision of the 5th measurement,P(%) = \",round(P,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Precision of the 5th measurement,P(%) = 99.502\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_2_a" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Absolute error\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79 # in V\n", + "e=Ae-Am #absolute error\n", + "print \"Absolute error,e(V) = \",e" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Absolute error,e(V) = 1.0\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_2_b" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Finding error\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79 # in V\n", + "e=Ae-Am #error\n", + "ep=(e/Ae)*100 #relative percent error\n", + "print \"Relative Percent Error(%) = \",ep" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Relative Percent Error(%) = 1.25\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# maximum error\n", + "#given data :\n", + "V1=100 # in volts\n", + "V2=200 # in volts\n", + "V=V2-V1 # Voltage difference\n", + "A=.25 # Accuracy may be \u00b1 in %\n", + "max_error=(A/100)*V # in Volts\n", + "print \"maximum error(V) = \u00b1\",max_error" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "maximum error(V) = \u00b1 0.25\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#sensitivity and deflection error\n", + "# given data :\n", + "C=4.0 # change in output in mm\n", + "M=8.0 # magnitude of input in ohm\n", + "S=C/M # sensitivity\n", + "print \"sensitivity,S(mm/ohm) = \",S\n", + "D=M/C # Deflection\n", + "print \"Deflection factor,D(ohm/m) = \",D" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sensitivity,S(mm/ohm) = 0.5\n", + "Deflection factor,D(ohm/m) = 2.0\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_5 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Resolution\n", + "# given data :\n", + "V=200.0 # full scale reading in volts\n", + "N=100.0 # number of divisions \n", + "Scale_div=V/N # Volts\n", + "R=(1/10.0)*Scale_div # Resolution in Volts\n", + "print \"Resolution, R(V) = \",round(R,4)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resolution, R(V) = 0.2\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 2_3_6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Resolution\n", + "#given data :\n", + "V=9.999 # full scale read out in volt\n", + "c=range(0,9999) # range from 0 to 9999\n", + "R=(1/max(c))*V*10.0**3\n", + "print \"Resolution, R(mV)\", R" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resolution, R(mV) 0.0\n" + ] + } + ], + "prompt_number": 29 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/Chapter2,_Measurement_Errors.ipynb b/sample_notebooks/MohdAsif/Chapter2,_Measurement_Errors.ipynb deleted file mode 100755 index f8ad79f0..00000000 --- a/sample_notebooks/MohdAsif/Chapter2,_Measurement_Errors.ipynb +++ /dev/null @@ -1,257 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:7b602763fd5a9c056abb62703a3bc42ae0cb4a39b3c349f78c056ebe58b1c643" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Precision of the 5th measurement\n", - "#Given data : Measurements taken(Unit less)\n", - "X1=98;\n", - "X2=101;\n", - "X3=102;\n", - "X4=97;\n", - "X5=101;\n", - "X6=100;\n", - "X7=103;\n", - "X8=98;\n", - "X9=106;\n", - "X10=99.0;\n", - "#Calculation\n", - "Xn_bar=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10;\n", - "Xn=101 # value of 5th measurement\n", - "P=(1-abs((Xn-Xn_bar)/Xn_bar))*100 #Precision\n", - "print \"Precision of the 5th measurement,P(%) = \",round(P,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Precision of the 5th measurement,P(%) = 99.502\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_2_a" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Absolute error\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79 # in V\n", - "e=Ae-Am #absolute error\n", - "print \"Absolute error,e(V) = \",e" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Absolute error,e(V) = 1.0\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_2_b" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Finding error\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79 # in V\n", - "e=Ae-Am #error\n", - "ep=(e/Ae)*100 #relative percent error\n", - "print \"Relative Percent Error(%) = \",ep" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Relative Percent Error(%) = 1.25\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# maximum error\n", - "#given data :\n", - "V1=100 # in volts\n", - "V2=200 # in volts\n", - "V=V2-V1 # Voltage difference\n", - "A=.25 # Accuracy may be \u00b1 in %\n", - "max_error=(A/100)*V # in Volts\n", - "print \"maximum error(V) = \u00b1\",max_error" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "maximum error(V) = \u00b1 0.25\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#sensitivity and deflection error\n", - "# given data :\n", - "C=4.0 # change in output in mm\n", - "M=8.0 # magnitude of input in ohm\n", - "S=C/M # sensitivity\n", - "print \"sensitivity,S(mm/ohm) = \",S\n", - "D=M/C # Deflection\n", - "print \"Deflection factor,D(ohm/m) = \",D" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "sensitivity,S(mm/ohm) = 0.5\n", - "Deflection factor,D(ohm/m) = 2.0\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_5 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Resolution\n", - "# given data :\n", - "V=200.0 # full scale reading in volts\n", - "N=100.0 # number of divisions \n", - "Scale_div=V/N # Volts\n", - "R=(1/10.0)*Scale_div # Resolution in Volts\n", - "print \"Resolution, R(V) = \",round(R,4)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resolution, R(V) = 0.2\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 2_3_6" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Resolution\n", - "#given data :\n", - "V=9.999 # full scale read out in volt\n", - "c=range(0,9999) # range from 0 to 9999\n", - "R=(1/max(c))*V*10.0**3\n", - "print \"Resolution, R(mV)\", R" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resolution, R(mV) 0.0\n" - ] - } - ], - "prompt_number": 29 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/Chapter2_-_Measurement.ipynb b/sample_notebooks/MohdAsif/Chapter2_-_Measurement.ipynb new file mode 100755 index 00000000..3442a20e --- /dev/null +++ b/sample_notebooks/MohdAsif/Chapter2_-_Measurement.ipynb @@ -0,0 +1,1549 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:95b9e0f83468dda84f2de4d99c5a704a6fadf8064c232b063678fd245192ca75" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter2 - Measurement Errors" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.1 - page : 2-8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#precision of the 5th measurement\n", + "#given data :\n", + "X1=98.0 \n", + "X2=101.0\n", + "X3=102.0 \n", + "X4=97.0 \n", + "X5=101.0 \n", + "X6=100.0 \n", + "X7=103.0 \n", + "X8=98.0 \n", + "X9=106.0 \n", + "X10=99.0 \n", + "Xn_bar=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10 \n", + "Xn=101 # value of 5th measurement\n", + "P=(1-abs((Xn-Xn_bar)/Xn_bar))*100 \n", + "print \"Precision of the 5th measurement, P = \", round(P,2), \" %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Precision of the 5th measurement, P = 99.5 %\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.2.i - page : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Absolute error\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79.0 # in V\n", + "e=Ae-Am \n", + "print \"Absolute error, e = \", e, \" V\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Absolute error, e = 1.0 V\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.2.ii - page : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Error\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79.0 # in V\n", + "e=Ae-Am \n", + "error1=(e/Ae)*100 \n", + "print \"Error = \", error1, \" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Error = 1.25 %\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.2.iii - page : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Relative accuracy\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79.0 # in V\n", + "e=Ae-Am \n", + "error1=(e/Ae)*100 \n", + "A=(1-abs(e/Ae)) \n", + "print \"Relative Accuracy, A = \", A" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Relative Accuracy, A = 0.9875\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.2.iv - page : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# % accuracy\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79.0 # in V\n", + "e=Ae-Am \n", + "error1=(e/Ae)*100 \n", + "A=(1-abs(e/Ae)) \n", + "accuracy=A*100 \n", + "print \"Accuracy = \", accuracy, \" %\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Accuracy = 98.75 %\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.2.v - page : 2-10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# % error\n", + "#given data :\n", + "Ae=80.0 # in V\n", + "Am=79.0 # in V\n", + "e=Ae-Am \n", + "f=100.0 #full scale deflection\n", + "error1=(e/Ae)*100 \n", + "A=(1-abs(e/Ae)) \n", + "accuracy=A*100 \n", + "P_error=(e/f)*100 \n", + "print \"% error = \", P_error, \" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "% error = 1.0 %\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.3 - page : 2-11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Maximum error\n", + "#given data :\n", + "V1=100.0 # in V\n", + "V2=200.0 #in V\n", + "V=V2-V1 \n", + "A=0.25 #may be \u00b1 in %\n", + "max_error=(A/100)*V \n", + "print \"Maximum error = \u00b1 \", max_error, \" V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum error = \u00b1 0.25 V\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.4 - page : 2-12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# sensitivity and deflection error\n", + "#given data :\n", + "C=4.0 # change in output in mm\n", + "M=8.0 # magnitude of input in ohm\n", + "S=C/M \n", + "print \"sensitivity, S = \", S, \" mm/ohm\"\n", + "D=M/C \n", + "print \"Deflection factor, D = \", D, \" ohm/mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sensitivity, S = 0.5 mm/ohm\n", + "Deflection factor, D = 2.0 ohm/mm\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.5 - page : 2-14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Resolution\n", + "#given data :\n", + "V=200.0 # full scale reading in V\n", + "N=100.0 # number of divisions \n", + "Scale_div=V/N \n", + "R=(1.0/10)*Scale_div \n", + "print \"Resolution, R = \", R, \" V\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resolution, R = 0.2 V\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3.6 - page : 2-14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Resolution\n", + "#given data :\n", + "V=9.999 # full scale read out in volt\n", + "c=9999.0 # range from 0 to 9999\n", + "R=(1/c)*V*10**3 \n", + "print \"Resolution, R = \", R, \" mV\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resolution, R = 1.0 mV\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.1 - page : 2-23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Magnitude and relative error\n", + "#given data :\n", + "R1=15.0 #ohm\n", + "E1=R1*5.0/100 # \u00b1 limiting error for R1\n", + "R2=33.0 #ohm\n", + "E2=R2*2.0/100 # \u00b1 limiting error for R2\n", + "R3=75.0 #ohm\n", + "E3=R3*5.0/100 # \u00b1 limiting error for R3\n", + "RT=R1+R2+R3 # ohm(in series)\n", + "ET=E1+E2+E3 #\u00b1limiting error for RT\n", + "print \"For series connection, magnitude is \", RT, \" ohm & limiting error is \u00b1 \", ET, \" ohm.\" \n", + "Epr=ET/RT*100 #%\n", + "print \"Percent relative error : \u00b1\", round(Epr,1),\" %\" \n", + "\n", + "# Answer is not accurate in the textbook." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For series connection, magnitude is 123.0 ohm & limiting error is \u00b1 5.16 ohm.\n", + "Percent relative error : \u00b1 4.2 %\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.2 - page : 2-23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Magnitude and relative error\n", + "#given data :\n", + "R1=36.0 #ohm\n", + "E1=5.0 # \u00b1 limiting error for R1\n", + "R2=75.0 #ohm\n", + "E2=5.0 # \u00b1 limiting error for R2\n", + "RT=(R1*R2)/(R1+R2) #ohm(in parallel)\n", + "EP1=E1+E2 # \u00b1 limiting error\n", + "EP2=((R1*E1)/(R1+R2))+((R2*E2)/(R1+R2)) \n", + "ET=EP1+EP2 \n", + "etm=(ET/100)*RT \n", + "print \"Magnitude of limiting error is \u00b1\", round(etm,2), \" ohm\"\n", + "print \"Percentage relative error is \u00b1\", ET, \" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Magnitude of limiting error is \u00b1 3.65 ohm\n", + "Percentage relative error is \u00b1 15.0 %\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.3 page : 2-24" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Limiting error\n", + "vr=40.0 #reading of voltmeter in volts\n", + "v=50.0 #rane in volts\n", + "va=50.0 #ammeeter reading in mA\n", + "i=125.0 #range in mA\n", + "fsd=2.0 #accurace in percentage in \u00b1\n", + "dv=(2.0/100)*v #limiting error of voltmeter\n", + "da=(2./100)*i #liming error of the ammeter in mA\n", + "erv=dv/vr #relative limiting error in voltmeter reading\n", + "eri=da/i #relative limiting error in ammeter reading\n", + "et=erv+eri \n", + "pet=et*100 #percentage limiting error of the power calcultaed\n", + "print \"Percentage limiting error of the power calcultaed is \u00b1 \",pet,\" %\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage limiting error of the power calcultaed is \u00b1 4.5 %\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.4 - page : 2-25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# limiting error\n", + "r1=120.0 # ohm\n", + "er1=0.5 #limiting error in resistance 1 in ohm \u00b1\n", + "r2=2 #in A\n", + "er2=0.02 #limiting error in amperes \u00b1\n", + "e1=er2/r2 #limiting error in current\n", + "e2=er1/r1 #limiting eror in resistance\n", + "et=(2*e1+e2) #total error\n", + "etp=et*100 #percentage limtimg error\n", + "print \"Percentage limiting error in the value of power dissipation is \u00b1\",round(etp,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage limiting error in the value of power dissipation is \u00b1 2.417\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.5 - page : 2-25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#magnitude and limiting error\n", + "r1=120 #in ohm\n", + "er1=0.1 #limiting error in resistance 1 in ohm \u00b1\n", + "r2=2700 #in ohm\n", + "er2=0.5 #limiting error in resistance 2 in ohm \u00b1\n", + "r3=470 #in ohm\n", + "er3=0.5 #limiting error in resistance 3 in ohm \u00b1\n", + "rxm=(r2*r3)/r1 #magnitude of unknown resistance in ohm\n", + "rxe=(er1+er2+er3) #error\n", + "er=(rxe*rxm)/100 #relative error \u00b1\n", + "print \"Magnitude of unknown resistance is \",rxm,\" kohm\"\n", + "print \"Relative limiting error is \u00b1\",er,\" ohm\"\n", + "print \"Guranteed value of resistance is between \",rxm-er, \" ohm to \" ,rxm+er,\" ohm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Magnitude of unknown resistance is 10575 kohm\n", + "Relative limiting error is \u00b1 116.325 ohm\n", + "Guranteed value of resistance is between 10458.675 ohm to 10691.325 ohm\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.6 - page : 2-26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# absolute error, % error, relative error, % accuracy and % error of full scale reading\n", + "#given data :\n", + "Ae=80.0 # in volt\n", + "Am=79 # in volt\n", + "fsd=100 #full scale reading in volt\n", + "e=Ae-Am \n", + "print \"Absolute error, e = \",e,\" V\"\n", + "error1=(e/Ae)*100 \n", + "print \"Error = \",error1,\" %\"\n", + "A=1-abs(e/Ae) \n", + "print \"Relative accuracy, A = \",A,\" %\"\n", + "p_accuracy=A*100 \n", + "print \"% accuracy = \",p_accuracy,\" %\"\n", + "error2=(e/fsd)*100 \n", + "print \"% error expressed as percentage of full scale reading = \",error2,\" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Absolute error, e = 1.0 V\n", + "Error = 1.25 %\n", + "Relative accuracy, A = 0.9875 %\n", + "% accuracy = 98.75 %\n", + "% error expressed as percentage of full scale reading = 1.0 %\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.7 - page : 2-27" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# limiting error\n", + "#given data :\n", + "fsd=100.0 # in V\n", + "A=1.0 # (+ve or -ve) in %\n", + "del_A=(A/100)*fsd \n", + "As=15.0 #in V\n", + "e1=del_A/As \n", + "e=e1*100 \n", + "print \"Limiting error, e = \",round(e,4),\" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Limiting error, e = 6.6667 %\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6.8 - page : 2-27 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# limiting value of current and % limiting error\n", + "#given data :\n", + "As=2.5 # in A\n", + "fsd=10 #full scale reading in A\n", + "A=1.5/100 \n", + "del_A=A*fsd \n", + "At1=As+del_A \n", + "At2=As-del_A \n", + "print \"Limiting value of current, At1 = \",At1,\" A\"\n", + "print \"Limiting value of current, At2 = \",At2,\" A\"\n", + "e=(del_A/As)*100 \n", + "print \"Percentage limiting error, e = \",e,\" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Limiting value of current, At1 = 2.65 A\n", + "Limiting value of current, At2 = 2.35 A\n", + "Percentage limiting error, e = 6.0 %\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.1.i - page : 2-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN\n", + "import numpy\n", + "q=[49.7,50.1,50.2,49.6,49.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "print \"Arithematic mean is \",AM\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 49.86\n" + ] + } + ], + "prompt_number": 57 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.1.ii - page : 2-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#deviation\n", + "import numpy\n", + "q=[49.7,50.1,50.2,49.6,49.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "print \"Deviations of each value are : \"\n", + "for dev in d:\n", + " print dev\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Deviations of each value are : \n", + "-0.16\n", + "0.24\n", + "0.34\n", + "-0.26\n", + "-0.16\n" + ] + } + ], + "prompt_number": 58 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.1.iii - page : 2-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#algebric sum of deviation\n", + "import numpy\n", + "q=[49.7,50.1,50.2,49.6,49.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "dtotal=sum(d)\n", + "print \"Algebric sum of deviation is\", round(dtotal,4)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Algebric sum of deviation is 0.0\n" + ] + } + ], + "prompt_number": 59 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.1.iv - page : 2-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#standard deviation\n", + "import numpy\n", + "q=[49.7,50.1,50.2,49.6,49.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "sigma=0\n", + "n=5 # no. of measurements\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2)\n", + "print \"Standard Deviation is \",round(sigma,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard Deviation is 0.27\n" + ] + } + ], + "prompt_number": 60 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.2.i - page : 2-31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN\n", + "import numpy\n", + "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "print \"Arithematic mean is \",AM,\" V\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 101.3 V\n" + ] + } + ], + "prompt_number": 61 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.2.ii - page : 2-31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Deviation from mean\n", + "import numpy\n", + "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "print \"Deviations of each value are : \"\n", + "for dev in d:\n", + " print dev\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Deviations of each value are : \n", + "-0.1\n", + "0.1\n", + "0.4\n", + "0.0\n", + "0.0\n", + "-0.1\n", + "-0.3\n", + "0.0\n", + "0.2\n", + "-0.2\n" + ] + } + ], + "prompt_number": 62 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.2.iii - page : 2-31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#standard deviation\n", + "import numpy\n", + "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] \n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "sigma=0\n", + "n=10 # no. of measurements\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2)\n", + "print \"Standard Deviation is \",round(sigma,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard Deviation is 0.2\n" + ] + } + ], + "prompt_number": 63 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.2.iv - page : 2-31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#probable error\n", + "import numpy\n", + "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] \n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "sigma=0\n", + "n=10 # no. of measurements\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2)\n", + "pe1=0.6745*sigma # Probable error of one reading\n", + "print \"Probable error of one reading is \",pe1,\" V\"\n", + "pm=pe1/(n-1)**(1.0/2)\n", + "print \"Probable error of mean is \",round(pm,5)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Probable error of one reading is 0.1349 V\n", + "Probable error of mean is 0.04497\n" + ] + } + ], + "prompt_number": 64 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.3.i - page : 2-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Arithmetic mean\n", + "#given data :\n", + "X1=147.2 # in nF\n", + "X2=147.4 # in nF\n", + "X3=147.9 # in nF\n", + "X4=148.1 # in nF\n", + "X5=148.1 # in nF\n", + "X6=147.5 # in nF\n", + "X7=147.6 # in nF\n", + "X8=147.4 # in nF\n", + "X9=147.6 # in nF\n", + "X10=147.5 # in nF\n", + "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10 \n", + "print \"Arithmetic mean, AM = \",AM,\" nF\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithmetic mean, AM = 147.63 nF\n" + ] + } + ], + "prompt_number": 77 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.3.ii - page : 2-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Average deviation\n", + "#given data :\n", + "n=10 \n", + "X1=147.2 # in nF\n", + "X2=147.4 # in nF\n", + "X3=147.9 # in nF\n", + "X4=148.1 # in nF\n", + "X5=148.1 # in nF\n", + "X6=147.5 # in nF\n", + "X7=147.6 # in nF\n", + "X8=147.4 # in nF\n", + "X9=147.6 # in nF\n", + "X10=147.5 # in nF\n", + "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", + "d1=X1-AM \n", + "d2=X2-AM \n", + "d3=X3-AM \n", + "d4=X4-AM \n", + "d5=X5-AM \n", + "d6=X6-AM \n", + "d7=X7-AM \n", + "d8=X8-AM \n", + "d9=X9-AM \n", + "d10=X10-AM \n", + "Average_deviation=(abs(d1)+abs(d2)+abs(d3)+abs(d4)+abs(d5)+abs(d5)+abs(d6)+abs(d7)+abs(d8)+abs(d9)+abs(d10))/n \n", + "print \"Average deviation = \",Average_deviation,\" nF\"\n", + "# answer is wrong in book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average deviation = 0.289 nF\n" + ] + } + ], + "prompt_number": 79 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.3.iii - page : 2-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Standard deviation\n", + "#given data :\n", + "n=10 \n", + "X1=147.2 # in nF\n", + "X2=147.4 # in nF\n", + "X3=147.9 # in nF\n", + "X4=148.1 # in nF\n", + "X5=148.1 # in nF\n", + "X6=147.5 # in nF\n", + "X7=147.6 # in nF\n", + "X8=147.4 # in nF\n", + "X9=147.6 # in nF\n", + "X10=147.5 # in nF\n", + "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", + "d1=X1-AM \n", + "d2=X2-AM \n", + "d3=X3-AM \n", + "d4=X4-AM \n", + "d5=X5-AM \n", + "d6=X6-AM \n", + "d7=X7-AM \n", + "d8=X8-AM \n", + "d9=X9-AM \n", + "d10=X10-AM \n", + "sigma=((d1**2+d2**2+d3**2+d4**2+d5**2+d6**2+d7**2+d8**2+d9**2+d10**2)/(n-1))**(1.0/2) \n", + "print \"Standard deviation = \",round(sigma,4),\" nF\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard deviation = 0.3057 nF\n" + ] + } + ], + "prompt_number": 82 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.3.iv - page : 2-32" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#: Probable error\n", + "#given data :\n", + "n=10 \n", + "X1=147.2 # in nF\n", + "X2=147.4 # in nF\n", + "X3=147.9 # in nF\n", + "X4=148.1 # in nF\n", + "X5=148.1 # in nF\n", + "X6=147.5 # in nF\n", + "X7=147.6 # in nF\n", + "X8=147.4 # in nF\n", + "X9=147.6 # in nF\n", + "X10=147.5 # in nF\n", + "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", + "d1=X1-AM \n", + "d2=X2-AM \n", + "d3=X3-AM \n", + "d4=X4-AM \n", + "d5=X5-AM \n", + "d6=X6-AM \n", + "d7=X7-AM \n", + "d8=X8-AM \n", + "d9=X9-AM \n", + "d10=X10-AM \n", + "sigma=((d1**2+d2**2+d3**2+d4**2+d5**2+d6**2+d7**2+d8**2+d9**2+d10**2)/(n-1))**(1.0/2)\n", + "Pe1=0.6745*sigma # probable error of one reading\n", + "probable_error=Pe1/(n-1)**(1.0/2)\n", + "print \"Probable error of one reading = \",round(Pe1,4),\" nF\"\n", + "print \"Probable error of mean = \",round(probable_error,4),\" nF\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Probable error of one reading = 0.2062 nF\n", + "Probable error of mean = 0.0687 nF\n" + ] + } + ], + "prompt_number": 86 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.4.i - page : 2-34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN\n", + "import numpy\n", + "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "print \"Arithematic mean is \",AM,\" kg/cm2\"\n", + "#answer is wrong in textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 10.2875 kg/cm2\n" + ] + } + ], + "prompt_number": 65 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.4.ii - page : 2-34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#average deviation\n", + "import numpy\n", + "n=8 # NO. OF MEASUREMENTS\n", + "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM # deviation\n", + "davg=sum(abs(d))/n # average deviation\n", + "print \"Average deviation = \",round(davg,4),\" kg/cm2\"\n", + "#answer is wrong in textbook" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average deviation = 0.6156 kg/cm2\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.4.iii - page : 2-34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#standard deviation\n", + "import numpy\n", + "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "sigma=0\n", + "n=8 # no. of measurements\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2)\n", + "print \"Standard Deviation is \",round(sigma,4),\" kg/cm2\"\n", + "#answer is wrong in textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Standard Deviation is 0.8184 kg/cm2\n" + ] + } + ], + "prompt_number": 95 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7.4.iv - page : 2-34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#probable error\n", + "n=8 # no. of measurements\n", + "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "d=q-AM\n", + "sigma=0\n", + "n=10 # no. of measurements\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2)\n", + "pe1=0.6745*sigma # Probable error of one reading\n", + "print \"Probable error of one reading is \",round(pe1,4),\" kg/cm2\"\n", + "pm=pe1/(n-1)**(1.0/2)\n", + "print \"Probable error of mean is \",round(pm,4),\" kg/cm2\"\n", + "#answer is wrong in textbook\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Probable error of one reading is 0.4868 kg/cm2\n", + "Probable error of mean is 0.1623 kg/cm2\n" + ] + } + ], + "prompt_number": 67 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8.1 - page : 2-34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN ,median value ,standard deviation and variance\n", + "q=[25.5,30.3,31.1,29.6,32.4,39.4,28.9,30.0,33.3,31.4,29.5,30.5,31.7,33.0,29.2] #\n", + "AM= numpy.mean(q) #arithematic mean in mm\n", + "n=len(q) # no. of measurements\n", + "Q=q-AM\n", + "mv=sorted(q)[n/2] # get the median value from sorted q\n", + "d=q-AM\n", + "sigma=0\n", + "for dev in d:\n", + " sigma+=dev**2\n", + "sigma/=(n-1)\n", + "sigma**=(1.0/2) #standard deviation\n", + "V=sigma**2 #variance\n", + "print \"Arithematic mean is \",round(AM,4),\" V\"\n", + "print \"Median value is\",round(mv,1)\n", + "\n", + "print \"Standard Deviation is \",round(sigma,2)\n", + "\n", + "print \"Variance is \",round(V,0)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 31.0533 V\n", + "Median value is 30.5\n", + "Standard Deviation is 3.0\n", + "Variance is 9.0\n" + ] + } + ], + "prompt_number": 116 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8.2 - page : 2-37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN\n", + "#from __future__ import division\n", + "v=[10,11,12,13,14] #\n", + "f=[03,12,18,12,03] #\n", + "xn=[a*b for a,b in zip(v,f)]\n", + "am=sum(xn)/sum(f) # arithmetic mean\n", + "print \"Arithematic mean is \",am,\" V\"\n", + "dn=[x-am for x in v] # deviation\n", + "n_dn=[a*b for a,b in zip(f,dn)]\n", + "dn2=[a*b for a,b in zip(dn,dn)]\n", + "n_dn2=[a*b for a,b in zip(f,dn2)]\n", + "absn_dn=[abs(a) for a in n_dn]\n", + "mean_dev=sum(absn_dn)/sum(f)\n", + "print \"Mean deviation = \",mean_dev\n", + "sigma=(sum(n_dn2)/sum(f))**(1.0/2)\n", + "print \"Standard deviation is \", sigma\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 12.0 V\n", + "Mean deviation = 0.75\n", + "Standard deviation is 1.0\n" + ] + } + ], + "prompt_number": 46 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8.3 - page : 2-37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#ARITHEMATIC MEAN ,median value ,standard deviation \n", + "import numpy\n", + "q=[29.2,29.5,29.6,30.0,30.5,31.4,31.7,32.4,33.0,33.3,39.4,28.9] #\n", + "AM= numpy.mean(q)#arithematic mean in mm\n", + "print \"Arithematic mean is \",round(AM,2)\n", + "mv=sorted(q)[int(len(q)/2-1)]\n", + "print \"Median value = \",mv\n", + "d=[x-AM for x in q]\n", + "d2=[x**2 for x in d]\n", + "sigma=(sum(d2)/(len(q)-1))**(1.0/2)\n", + "print \"Standard Deviation = \",round(sigma,3)\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Arithematic mean is 31.57\n", + "Median value = 30.5\n", + "Standard Deviation = 2.886\n" + ] + } + ], + "prompt_number": 97 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8.4 - page:2-39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Unknown resistor \n", + "#given data :\n", + "S=1000.0 # ohm/V\n", + "V=100.0 #in V\n", + "I=5*10**-3 # in A\n", + "# part (i)\n", + "R_app=(V/I)*10**-3 \n", + "print \"(i) Apparent Resistor, R_app = \",R_app, \" kohm\"\n", + "# part (ii)\n", + "V1=150 #in V\n", + "Rv=S*V1*10**-3 \n", + "Rx=Rv/6.5 #actual resistance in kohm\n", + "print \"(ii) Actual resistance is \",round(Rx,2),\" kohm.\"\n", + "# part(iii)\n", + "per=(Rx-R_app)/Rx*100 # in %\n", + "print \"(iii) Percentage error due to loading effect of voltmeter is \",round(per,1), \" %\" \n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Apparent Resistor, R_app = 20.0 kohm\n", + "(ii) Actual resistance is 23.08 kohm.\n", + "(iii) Percentage error due to loading effect of voltmeter is 13.3 %\n" + ] + } + ], + "prompt_number": 103 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8.5 - page : 2-40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# limiting error\n", + "#given data :\n", + "del_A=2.5 # may be +ve or-ve in %\n", + "As=400.0 \n", + "FSD=600.0 # in V\n", + "del_A1=(del_A/100)*FSD \n", + "e=(del_A1/As)*100 # in %\n", + "print \"Limiting error, e = \",e, \" %\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Limiting error, e = 3.75 %\n" + ] + } + ], + "prompt_number": 104 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/Chapter2_-_Measurement_Errors.ipynb b/sample_notebooks/MohdAsif/Chapter2_-_Measurement_Errors.ipynb deleted file mode 100755 index 3442a20e..00000000 --- a/sample_notebooks/MohdAsif/Chapter2_-_Measurement_Errors.ipynb +++ /dev/null @@ -1,1549 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:95b9e0f83468dda84f2de4d99c5a704a6fadf8064c232b063678fd245192ca75" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter2 - Measurement Errors" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.1 - page : 2-8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#precision of the 5th measurement\n", - "#given data :\n", - "X1=98.0 \n", - "X2=101.0\n", - "X3=102.0 \n", - "X4=97.0 \n", - "X5=101.0 \n", - "X6=100.0 \n", - "X7=103.0 \n", - "X8=98.0 \n", - "X9=106.0 \n", - "X10=99.0 \n", - "Xn_bar=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10 \n", - "Xn=101 # value of 5th measurement\n", - "P=(1-abs((Xn-Xn_bar)/Xn_bar))*100 \n", - "print \"Precision of the 5th measurement, P = \", round(P,2), \" %\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Precision of the 5th measurement, P = 99.5 %\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.2.i - page : 2-10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Absolute error\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79.0 # in V\n", - "e=Ae-Am \n", - "print \"Absolute error, e = \", e, \" V\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Absolute error, e = 1.0 V\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.2.ii - page : 2-10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Error\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79.0 # in V\n", - "e=Ae-Am \n", - "error1=(e/Ae)*100 \n", - "print \"Error = \", error1, \" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Error = 1.25 %\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.2.iii - page : 2-10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Relative accuracy\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79.0 # in V\n", - "e=Ae-Am \n", - "error1=(e/Ae)*100 \n", - "A=(1-abs(e/Ae)) \n", - "print \"Relative Accuracy, A = \", A" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Relative Accuracy, A = 0.9875\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.2.iv - page : 2-10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# % accuracy\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79.0 # in V\n", - "e=Ae-Am \n", - "error1=(e/Ae)*100 \n", - "A=(1-abs(e/Ae)) \n", - "accuracy=A*100 \n", - "print \"Accuracy = \", accuracy, \" %\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Accuracy = 98.75 %\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.2.v - page : 2-10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# % error\n", - "#given data :\n", - "Ae=80.0 # in V\n", - "Am=79.0 # in V\n", - "e=Ae-Am \n", - "f=100.0 #full scale deflection\n", - "error1=(e/Ae)*100 \n", - "A=(1-abs(e/Ae)) \n", - "accuracy=A*100 \n", - "P_error=(e/f)*100 \n", - "print \"% error = \", P_error, \" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "% error = 1.0 %\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.3 - page : 2-11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Maximum error\n", - "#given data :\n", - "V1=100.0 # in V\n", - "V2=200.0 #in V\n", - "V=V2-V1 \n", - "A=0.25 #may be \u00b1 in %\n", - "max_error=(A/100)*V \n", - "print \"Maximum error = \u00b1 \", max_error, \" V\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum error = \u00b1 0.25 V\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.4 - page : 2-12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# sensitivity and deflection error\n", - "#given data :\n", - "C=4.0 # change in output in mm\n", - "M=8.0 # magnitude of input in ohm\n", - "S=C/M \n", - "print \"sensitivity, S = \", S, \" mm/ohm\"\n", - "D=M/C \n", - "print \"Deflection factor, D = \", D, \" ohm/mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "sensitivity, S = 0.5 mm/ohm\n", - "Deflection factor, D = 2.0 ohm/mm\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.5 - page : 2-14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Resolution\n", - "#given data :\n", - "V=200.0 # full scale reading in V\n", - "N=100.0 # number of divisions \n", - "Scale_div=V/N \n", - "R=(1.0/10)*Scale_div \n", - "print \"Resolution, R = \", R, \" V\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resolution, R = 0.2 V\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3.6 - page : 2-14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Resolution\n", - "#given data :\n", - "V=9.999 # full scale read out in volt\n", - "c=9999.0 # range from 0 to 9999\n", - "R=(1/c)*V*10**3 \n", - "print \"Resolution, R = \", R, \" mV\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resolution, R = 1.0 mV\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.1 - page : 2-23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Magnitude and relative error\n", - "#given data :\n", - "R1=15.0 #ohm\n", - "E1=R1*5.0/100 # \u00b1 limiting error for R1\n", - "R2=33.0 #ohm\n", - "E2=R2*2.0/100 # \u00b1 limiting error for R2\n", - "R3=75.0 #ohm\n", - "E3=R3*5.0/100 # \u00b1 limiting error for R3\n", - "RT=R1+R2+R3 # ohm(in series)\n", - "ET=E1+E2+E3 #\u00b1limiting error for RT\n", - "print \"For series connection, magnitude is \", RT, \" ohm & limiting error is \u00b1 \", ET, \" ohm.\" \n", - "Epr=ET/RT*100 #%\n", - "print \"Percent relative error : \u00b1\", round(Epr,1),\" %\" \n", - "\n", - "# Answer is not accurate in the textbook." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "For series connection, magnitude is 123.0 ohm & limiting error is \u00b1 5.16 ohm.\n", - "Percent relative error : \u00b1 4.2 %\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.2 - page : 2-23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Magnitude and relative error\n", - "#given data :\n", - "R1=36.0 #ohm\n", - "E1=5.0 # \u00b1 limiting error for R1\n", - "R2=75.0 #ohm\n", - "E2=5.0 # \u00b1 limiting error for R2\n", - "RT=(R1*R2)/(R1+R2) #ohm(in parallel)\n", - "EP1=E1+E2 # \u00b1 limiting error\n", - "EP2=((R1*E1)/(R1+R2))+((R2*E2)/(R1+R2)) \n", - "ET=EP1+EP2 \n", - "etm=(ET/100)*RT \n", - "print \"Magnitude of limiting error is \u00b1\", round(etm,2), \" ohm\"\n", - "print \"Percentage relative error is \u00b1\", ET, \" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Magnitude of limiting error is \u00b1 3.65 ohm\n", - "Percentage relative error is \u00b1 15.0 %\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.3 page : 2-24" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Limiting error\n", - "vr=40.0 #reading of voltmeter in volts\n", - "v=50.0 #rane in volts\n", - "va=50.0 #ammeeter reading in mA\n", - "i=125.0 #range in mA\n", - "fsd=2.0 #accurace in percentage in \u00b1\n", - "dv=(2.0/100)*v #limiting error of voltmeter\n", - "da=(2./100)*i #liming error of the ammeter in mA\n", - "erv=dv/vr #relative limiting error in voltmeter reading\n", - "eri=da/i #relative limiting error in ammeter reading\n", - "et=erv+eri \n", - "pet=et*100 #percentage limiting error of the power calcultaed\n", - "print \"Percentage limiting error of the power calcultaed is \u00b1 \",pet,\" %\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Percentage limiting error of the power calcultaed is \u00b1 4.5 %\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.4 - page : 2-25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# limiting error\n", - "r1=120.0 # ohm\n", - "er1=0.5 #limiting error in resistance 1 in ohm \u00b1\n", - "r2=2 #in A\n", - "er2=0.02 #limiting error in amperes \u00b1\n", - "e1=er2/r2 #limiting error in current\n", - "e2=er1/r1 #limiting eror in resistance\n", - "et=(2*e1+e2) #total error\n", - "etp=et*100 #percentage limtimg error\n", - "print \"Percentage limiting error in the value of power dissipation is \u00b1\",round(etp,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Percentage limiting error in the value of power dissipation is \u00b1 2.417\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.5 - page : 2-25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#magnitude and limiting error\n", - "r1=120 #in ohm\n", - "er1=0.1 #limiting error in resistance 1 in ohm \u00b1\n", - "r2=2700 #in ohm\n", - "er2=0.5 #limiting error in resistance 2 in ohm \u00b1\n", - "r3=470 #in ohm\n", - "er3=0.5 #limiting error in resistance 3 in ohm \u00b1\n", - "rxm=(r2*r3)/r1 #magnitude of unknown resistance in ohm\n", - "rxe=(er1+er2+er3) #error\n", - "er=(rxe*rxm)/100 #relative error \u00b1\n", - "print \"Magnitude of unknown resistance is \",rxm,\" kohm\"\n", - "print \"Relative limiting error is \u00b1\",er,\" ohm\"\n", - "print \"Guranteed value of resistance is between \",rxm-er, \" ohm to \" ,rxm+er,\" ohm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Magnitude of unknown resistance is 10575 kohm\n", - "Relative limiting error is \u00b1 116.325 ohm\n", - "Guranteed value of resistance is between 10458.675 ohm to 10691.325 ohm\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.6 - page : 2-26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# absolute error, % error, relative error, % accuracy and % error of full scale reading\n", - "#given data :\n", - "Ae=80.0 # in volt\n", - "Am=79 # in volt\n", - "fsd=100 #full scale reading in volt\n", - "e=Ae-Am \n", - "print \"Absolute error, e = \",e,\" V\"\n", - "error1=(e/Ae)*100 \n", - "print \"Error = \",error1,\" %\"\n", - "A=1-abs(e/Ae) \n", - "print \"Relative accuracy, A = \",A,\" %\"\n", - "p_accuracy=A*100 \n", - "print \"% accuracy = \",p_accuracy,\" %\"\n", - "error2=(e/fsd)*100 \n", - "print \"% error expressed as percentage of full scale reading = \",error2,\" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Absolute error, e = 1.0 V\n", - "Error = 1.25 %\n", - "Relative accuracy, A = 0.9875 %\n", - "% accuracy = 98.75 %\n", - "% error expressed as percentage of full scale reading = 1.0 %\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.7 - page : 2-27" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# limiting error\n", - "#given data :\n", - "fsd=100.0 # in V\n", - "A=1.0 # (+ve or -ve) in %\n", - "del_A=(A/100)*fsd \n", - "As=15.0 #in V\n", - "e1=del_A/As \n", - "e=e1*100 \n", - "print \"Limiting error, e = \",round(e,4),\" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Limiting error, e = 6.6667 %\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6.8 - page : 2-27 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# limiting value of current and % limiting error\n", - "#given data :\n", - "As=2.5 # in A\n", - "fsd=10 #full scale reading in A\n", - "A=1.5/100 \n", - "del_A=A*fsd \n", - "At1=As+del_A \n", - "At2=As-del_A \n", - "print \"Limiting value of current, At1 = \",At1,\" A\"\n", - "print \"Limiting value of current, At2 = \",At2,\" A\"\n", - "e=(del_A/As)*100 \n", - "print \"Percentage limiting error, e = \",e,\" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Limiting value of current, At1 = 2.65 A\n", - "Limiting value of current, At2 = 2.35 A\n", - "Percentage limiting error, e = 6.0 %\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.1.i - page : 2-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN\n", - "import numpy\n", - "q=[49.7,50.1,50.2,49.6,49.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "print \"Arithematic mean is \",AM\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 49.86\n" - ] - } - ], - "prompt_number": 57 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.1.ii - page : 2-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#deviation\n", - "import numpy\n", - "q=[49.7,50.1,50.2,49.6,49.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "print \"Deviations of each value are : \"\n", - "for dev in d:\n", - " print dev\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Deviations of each value are : \n", - "-0.16\n", - "0.24\n", - "0.34\n", - "-0.26\n", - "-0.16\n" - ] - } - ], - "prompt_number": 58 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.1.iii - page : 2-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#algebric sum of deviation\n", - "import numpy\n", - "q=[49.7,50.1,50.2,49.6,49.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "dtotal=sum(d)\n", - "print \"Algebric sum of deviation is\", round(dtotal,4)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Algebric sum of deviation is 0.0\n" - ] - } - ], - "prompt_number": 59 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.1.iv - page : 2-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#standard deviation\n", - "import numpy\n", - "q=[49.7,50.1,50.2,49.6,49.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "sigma=0\n", - "n=5 # no. of measurements\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2)\n", - "print \"Standard Deviation is \",round(sigma,2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Standard Deviation is 0.27\n" - ] - } - ], - "prompt_number": 60 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.2.i - page : 2-31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN\n", - "import numpy\n", - "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "print \"Arithematic mean is \",AM,\" V\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 101.3 V\n" - ] - } - ], - "prompt_number": 61 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.2.ii - page : 2-31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Deviation from mean\n", - "import numpy\n", - "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "print \"Deviations of each value are : \"\n", - "for dev in d:\n", - " print dev\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Deviations of each value are : \n", - "-0.1\n", - "0.1\n", - "0.4\n", - "0.0\n", - "0.0\n", - "-0.1\n", - "-0.3\n", - "0.0\n", - "0.2\n", - "-0.2\n" - ] - } - ], - "prompt_number": 62 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.2.iii - page : 2-31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#standard deviation\n", - "import numpy\n", - "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] \n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "sigma=0\n", - "n=10 # no. of measurements\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2)\n", - "print \"Standard Deviation is \",round(sigma,2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Standard Deviation is 0.2\n" - ] - } - ], - "prompt_number": 63 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.2.iv - page : 2-31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#probable error\n", - "import numpy\n", - "q=[101.2,101.4,101.7,101.3,101.3,101.2,101.0,101.3,101.5,101.1] \n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "sigma=0\n", - "n=10 # no. of measurements\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2)\n", - "pe1=0.6745*sigma # Probable error of one reading\n", - "print \"Probable error of one reading is \",pe1,\" V\"\n", - "pm=pe1/(n-1)**(1.0/2)\n", - "print \"Probable error of mean is \",round(pm,5)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Probable error of one reading is 0.1349 V\n", - "Probable error of mean is 0.04497\n" - ] - } - ], - "prompt_number": 64 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.3.i - page : 2-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Arithmetic mean\n", - "#given data :\n", - "X1=147.2 # in nF\n", - "X2=147.4 # in nF\n", - "X3=147.9 # in nF\n", - "X4=148.1 # in nF\n", - "X5=148.1 # in nF\n", - "X6=147.5 # in nF\n", - "X7=147.6 # in nF\n", - "X8=147.4 # in nF\n", - "X9=147.6 # in nF\n", - "X10=147.5 # in nF\n", - "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/10 \n", - "print \"Arithmetic mean, AM = \",AM,\" nF\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithmetic mean, AM = 147.63 nF\n" - ] - } - ], - "prompt_number": 77 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.3.ii - page : 2-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Average deviation\n", - "#given data :\n", - "n=10 \n", - "X1=147.2 # in nF\n", - "X2=147.4 # in nF\n", - "X3=147.9 # in nF\n", - "X4=148.1 # in nF\n", - "X5=148.1 # in nF\n", - "X6=147.5 # in nF\n", - "X7=147.6 # in nF\n", - "X8=147.4 # in nF\n", - "X9=147.6 # in nF\n", - "X10=147.5 # in nF\n", - "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", - "d1=X1-AM \n", - "d2=X2-AM \n", - "d3=X3-AM \n", - "d4=X4-AM \n", - "d5=X5-AM \n", - "d6=X6-AM \n", - "d7=X7-AM \n", - "d8=X8-AM \n", - "d9=X9-AM \n", - "d10=X10-AM \n", - "Average_deviation=(abs(d1)+abs(d2)+abs(d3)+abs(d4)+abs(d5)+abs(d5)+abs(d6)+abs(d7)+abs(d8)+abs(d9)+abs(d10))/n \n", - "print \"Average deviation = \",Average_deviation,\" nF\"\n", - "# answer is wrong in book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Average deviation = 0.289 nF\n" - ] - } - ], - "prompt_number": 79 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.3.iii - page : 2-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Standard deviation\n", - "#given data :\n", - "n=10 \n", - "X1=147.2 # in nF\n", - "X2=147.4 # in nF\n", - "X3=147.9 # in nF\n", - "X4=148.1 # in nF\n", - "X5=148.1 # in nF\n", - "X6=147.5 # in nF\n", - "X7=147.6 # in nF\n", - "X8=147.4 # in nF\n", - "X9=147.6 # in nF\n", - "X10=147.5 # in nF\n", - "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", - "d1=X1-AM \n", - "d2=X2-AM \n", - "d3=X3-AM \n", - "d4=X4-AM \n", - "d5=X5-AM \n", - "d6=X6-AM \n", - "d7=X7-AM \n", - "d8=X8-AM \n", - "d9=X9-AM \n", - "d10=X10-AM \n", - "sigma=((d1**2+d2**2+d3**2+d4**2+d5**2+d6**2+d7**2+d8**2+d9**2+d10**2)/(n-1))**(1.0/2) \n", - "print \"Standard deviation = \",round(sigma,4),\" nF\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Standard deviation = 0.3057 nF\n" - ] - } - ], - "prompt_number": 82 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.3.iv - page : 2-32" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#: Probable error\n", - "#given data :\n", - "n=10 \n", - "X1=147.2 # in nF\n", - "X2=147.4 # in nF\n", - "X3=147.9 # in nF\n", - "X4=148.1 # in nF\n", - "X5=148.1 # in nF\n", - "X6=147.5 # in nF\n", - "X7=147.6 # in nF\n", - "X8=147.4 # in nF\n", - "X9=147.6 # in nF\n", - "X10=147.5 # in nF\n", - "AM=(X1+X2+X3+X4+X5+X6+X7+X8+X9+X10)/n \n", - "d1=X1-AM \n", - "d2=X2-AM \n", - "d3=X3-AM \n", - "d4=X4-AM \n", - "d5=X5-AM \n", - "d6=X6-AM \n", - "d7=X7-AM \n", - "d8=X8-AM \n", - "d9=X9-AM \n", - "d10=X10-AM \n", - "sigma=((d1**2+d2**2+d3**2+d4**2+d5**2+d6**2+d7**2+d8**2+d9**2+d10**2)/(n-1))**(1.0/2)\n", - "Pe1=0.6745*sigma # probable error of one reading\n", - "probable_error=Pe1/(n-1)**(1.0/2)\n", - "print \"Probable error of one reading = \",round(Pe1,4),\" nF\"\n", - "print \"Probable error of mean = \",round(probable_error,4),\" nF\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Probable error of one reading = 0.2062 nF\n", - "Probable error of mean = 0.0687 nF\n" - ] - } - ], - "prompt_number": 86 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.4.i - page : 2-34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN\n", - "import numpy\n", - "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "print \"Arithematic mean is \",AM,\" kg/cm2\"\n", - "#answer is wrong in textbook\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 10.2875 kg/cm2\n" - ] - } - ], - "prompt_number": 65 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.4.ii - page : 2-34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#average deviation\n", - "import numpy\n", - "n=8 # NO. OF MEASUREMENTS\n", - "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM # deviation\n", - "davg=sum(abs(d))/n # average deviation\n", - "print \"Average deviation = \",round(davg,4),\" kg/cm2\"\n", - "#answer is wrong in textbook" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Average deviation = 0.6156 kg/cm2\n" - ] - } - ], - "prompt_number": 66 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.4.iii - page : 2-34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#standard deviation\n", - "import numpy\n", - "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "sigma=0\n", - "n=8 # no. of measurements\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2)\n", - "print \"Standard Deviation is \",round(sigma,4),\" kg/cm2\"\n", - "#answer is wrong in textbook\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Standard Deviation is 0.8184 kg/cm2\n" - ] - } - ], - "prompt_number": 95 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7.4.iv - page : 2-34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#probable error\n", - "n=8 # no. of measurements\n", - "q=[10.3,10.7,10.9,9.7,9.5,9.2,10.3,11.7] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "d=q-AM\n", - "sigma=0\n", - "n=10 # no. of measurements\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2)\n", - "pe1=0.6745*sigma # Probable error of one reading\n", - "print \"Probable error of one reading is \",round(pe1,4),\" kg/cm2\"\n", - "pm=pe1/(n-1)**(1.0/2)\n", - "print \"Probable error of mean is \",round(pm,4),\" kg/cm2\"\n", - "#answer is wrong in textbook\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Probable error of one reading is 0.4868 kg/cm2\n", - "Probable error of mean is 0.1623 kg/cm2\n" - ] - } - ], - "prompt_number": 67 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8.1 - page : 2-34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN ,median value ,standard deviation and variance\n", - "q=[25.5,30.3,31.1,29.6,32.4,39.4,28.9,30.0,33.3,31.4,29.5,30.5,31.7,33.0,29.2] #\n", - "AM= numpy.mean(q) #arithematic mean in mm\n", - "n=len(q) # no. of measurements\n", - "Q=q-AM\n", - "mv=sorted(q)[n/2] # get the median value from sorted q\n", - "d=q-AM\n", - "sigma=0\n", - "for dev in d:\n", - " sigma+=dev**2\n", - "sigma/=(n-1)\n", - "sigma**=(1.0/2) #standard deviation\n", - "V=sigma**2 #variance\n", - "print \"Arithematic mean is \",round(AM,4),\" V\"\n", - "print \"Median value is\",round(mv,1)\n", - "\n", - "print \"Standard Deviation is \",round(sigma,2)\n", - "\n", - "print \"Variance is \",round(V,0)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 31.0533 V\n", - "Median value is 30.5\n", - "Standard Deviation is 3.0\n", - "Variance is 9.0\n" - ] - } - ], - "prompt_number": 116 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8.2 - page : 2-37" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN\n", - "#from __future__ import division\n", - "v=[10,11,12,13,14] #\n", - "f=[03,12,18,12,03] #\n", - "xn=[a*b for a,b in zip(v,f)]\n", - "am=sum(xn)/sum(f) # arithmetic mean\n", - "print \"Arithematic mean is \",am,\" V\"\n", - "dn=[x-am for x in v] # deviation\n", - "n_dn=[a*b for a,b in zip(f,dn)]\n", - "dn2=[a*b for a,b in zip(dn,dn)]\n", - "n_dn2=[a*b for a,b in zip(f,dn2)]\n", - "absn_dn=[abs(a) for a in n_dn]\n", - "mean_dev=sum(absn_dn)/sum(f)\n", - "print \"Mean deviation = \",mean_dev\n", - "sigma=(sum(n_dn2)/sum(f))**(1.0/2)\n", - "print \"Standard deviation is \", sigma\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 12.0 V\n", - "Mean deviation = 0.75\n", - "Standard deviation is 1.0\n" - ] - } - ], - "prompt_number": 46 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8.3 - page : 2-37" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#ARITHEMATIC MEAN ,median value ,standard deviation \n", - "import numpy\n", - "q=[29.2,29.5,29.6,30.0,30.5,31.4,31.7,32.4,33.0,33.3,39.4,28.9] #\n", - "AM= numpy.mean(q)#arithematic mean in mm\n", - "print \"Arithematic mean is \",round(AM,2)\n", - "mv=sorted(q)[int(len(q)/2-1)]\n", - "print \"Median value = \",mv\n", - "d=[x-AM for x in q]\n", - "d2=[x**2 for x in d]\n", - "sigma=(sum(d2)/(len(q)-1))**(1.0/2)\n", - "print \"Standard Deviation = \",round(sigma,3)\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Arithematic mean is 31.57\n", - "Median value = 30.5\n", - "Standard Deviation = 2.886\n" - ] - } - ], - "prompt_number": 97 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8.4 - page:2-39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Unknown resistor \n", - "#given data :\n", - "S=1000.0 # ohm/V\n", - "V=100.0 #in V\n", - "I=5*10**-3 # in A\n", - "# part (i)\n", - "R_app=(V/I)*10**-3 \n", - "print \"(i) Apparent Resistor, R_app = \",R_app, \" kohm\"\n", - "# part (ii)\n", - "V1=150 #in V\n", - "Rv=S*V1*10**-3 \n", - "Rx=Rv/6.5 #actual resistance in kohm\n", - "print \"(ii) Actual resistance is \",round(Rx,2),\" kohm.\"\n", - "# part(iii)\n", - "per=(Rx-R_app)/Rx*100 # in %\n", - "print \"(iii) Percentage error due to loading effect of voltmeter is \",round(per,1), \" %\" \n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Apparent Resistor, R_app = 20.0 kohm\n", - "(ii) Actual resistance is 23.08 kohm.\n", - "(iii) Percentage error due to loading effect of voltmeter is 13.3 %\n" - ] - } - ], - "prompt_number": 103 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8.5 - page : 2-40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# limiting error\n", - "#given data :\n", - "del_A=2.5 # may be +ve or-ve in %\n", - "As=400.0 \n", - "FSD=600.0 # in V\n", - "del_A1=(del_A/100)*FSD \n", - "e=(del_A1/As)*100 # in %\n", - "print \"Limiting error, e = \",e, \" %\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Limiting error, e = 3.75 %\n" - ] - } - ], - "prompt_number": 104 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/MohdAsif_version_backup/ch2.ipynb b/sample_notebooks/MohdAsif/MohdAsif_version_backup/ch2.ipynb new file mode 100755 index 00000000..66270ccb --- /dev/null +++ b/sample_notebooks/MohdAsif/MohdAsif_version_backup/ch2.ipynb @@ -0,0 +1,387 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 Casting Processes" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 2.1 on page no. 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import sqrt\n", + "# Given that\n", + "h=15 # Height of spur in cm\n", + "l= 50 # Length of cast in cm\n", + "w= 25 # weidth of cast in cm\n", + "h1= 15 # Height of cast in cm\n", + "g= 981 # Acceleration due to gravity in cm/sec**2\n", + "Ag= 5 # Cross sectional area of the grate in cm**2\n", + "v3= sqrt(2* g * h)\n", + "V = l*w*h1\n", + "tf1= V/(Ag*v3)\n", + "Am = l*w\n", + "tf2 = (Am/Ag)*(1/sqrt(2*g))*2*(sqrt(h) - sqrt(h-h1))\n", + "print \" Filling time for first design = %f sec, \\n Filling time for second design = %f sec\"% (tf1, tf2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Filling time for first design = 21.859294 sec, \n", + " Filling time for second design = 43.718589 sec\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 2 on page no. 53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi, sqrt\n", + "# Given that\n", + "h=15 # Height of spur in cm\n", + "l= 50 # Length of cast in cm\n", + "w= 25 # weidth of cast in cm\n", + "h1= 15 # Height of cast in cm\n", + "g= 981 # Acceleration due to gravity in cm/sec**2\n", + "Ag= 5 # Cross sectional area of the grate in cm**2\n", + "Dm = 7800 # Density of molten Fe in Kg/m**3\n", + "Neta = 0.00496 # Kinetic viscosity in Kg/m-sec\n", + "theta = 90 # Angle in degree\n", + "Eq = 25 # (L/D) Equivalent \n", + "v3= sqrt(2* g * h)*(10**(-2))\n", + "d= sqrt((Ag*4)/(pi))*(10**(-2))\n", + "Re = Dm*v3*d/Neta\n", + "f = 0.0791*(Re)**(-1/4)\n", + "L=0.12 # in meter\n", + "Cd= (1+0.45+4*f*((L/d)+Eq))**(-1/2)\n", + "v3_ = Cd*v3\n", + "Re_ = (v3_/v3)*(Re)\n", + "f_ = 0.0791 *(Re_)**(-1/4)\n", + "Cd_ = (1+0.46+4*f_*(L/d + Eq))**(-1/2)\n", + "v3__ = Cd_*v3\n", + "V = l*w*h1\n", + "tf= (V/(Ag*v3__))*(10**-2)\n", + "print \" Filling time for first design = %f sec. \"% tf " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Filling time for first design = 31.918954 sec. \n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem on page no. 56" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given that\n", + "Hi=1.2 # Initial height in m\n", + "H= 0.05 # Height in m\n", + "g= 9.81 # Acceleration due to gravity in m/sec**2\n", + "Dm = 2700 # Density of molten metal in Kg/m**3\n", + "Neta = 0.00273 # Kinetic viscosity in Kg/m-sec \n", + "d= 0.075 # Diameter in m\n", + "D = 1 # Internal diameter of ladle in m\n", + "v3= sqrt(2* g * Hi)\n", + "Re = Dm*v3*d/Neta\n", + "ef=0.075\n", + "Cd= (1+ef)**(-1/2)\n", + "ef_=0.82\n", + "Re_ = (2+ef_)**(-1/2)\n", + "v3_ = sqrt(2*g*H)\n", + "Re_ = Dm*v3_*d/Neta\n", + "At = (pi/4)*D**2\n", + "An = (pi/4)*d**2\n", + "Cd= 0.96\n", + "tf= (sqrt(2/g))*(At/An)*(1/Cd)*sqrt(Hi)\n", + "m = Dm*An*Cd*sqrt(2*g*Hi)\n", + "m_ = Dm*An*Cd*sqrt(2*g*Hi*0.25)\n", + "print \"\"\"Time required to empty the ladle = %f sec,\n", + "Discharge rate are -\n", + "Initially = %f Kg/sec \n", + "When the ladle is 75 percent empty = %f Kg/sec. \"\"\"%(tf,m,m_)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time required to empty the ladle = 91.596179 sec,\n", + "Discharge rate are -\n", + "Initially = 55.563236 Kg/sec \n", + "When the ladle is 75 percent empty = 27.781618 Kg/sec. \n" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 5 on page no. 66" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from sympy import symbols, solve\n", + "# Given that\n", + "thetaF= 1540 # Temperature of mould face in degree centigrade\n", + "Theta0 = 28 # Initial temperature of mould in Degree centigrade\n", + "L= 272e3 # Latent heat of liquid metal in J/Kg\n", + "Dm = 7850 # Density of liquid metal in Kg/m**3\n", + "c = 1.17e+3 #Specific heat of sand in J/Kg-K\n", + "k = 0.8655 # Conductivity of sand in W/m-K\n", + "D= 1600 # Density of sand in Kg/m**3\n", + "h = 0.1 # Height in m\n", + "b = 10 # Thickness of slab in cm\n", + "r =h/2# V/A in meter\n", + "lamda = (thetaF - Theta0)*(D*c)/(Dm*L)\n", + "Beta1 = 2*lamda/sqrt(pi)\n", + "Alpha = k /(D*c)\n", + "ts1 = r**2 /((Beta1**2)*Alpha)#In sec\n", + "ts1_=ts1/3600 # In hour\n", + "Beta= symbols('Beta') \n", + "p=Beta**2 - lamda*(2/sqrt(pi))*Beta -lamda/3\n", + "Beta2 = solve(p)[0]\n", + "print \"The value of Beta2 is %f \"%Beta2\n", + "print \"We only take the positive value of Beta2 ,\\nHence Beta2=1.75\" \n", + "r1 = r/3\n", + "ts2 = (r1**2)/((1.75**2)*Alpha) # in sec\n", + "ts2_=ts2/3600#in Hour\n", + "print \"Solidification time for slab-shaped casting = %f hr,\\nSolidification time for sphere = %f hr\"%(ts1_,ts2_)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of Beta2 is -0.252713 \n", + "We only take the positive value of Beta2 ,\n", + "Hence Beta2=1.75\n", + "Solidification time for slab-shaped casting = 0.671318 hr,\n", + "Solidification time for sphere = 0.054495 hr\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 7 on page no. 75" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given that\n", + "thetaF= 1540 # Temperature of mould face in degree centigrade\n", + "thetaO = 28 # Initial temperature of mould in Degree centigrade\n", + "L= 272e3 # Latent heat of iron in J/Kg\n", + "Dm = 7850 # Density of iron in Kg/m**3\n", + "Cs = 0.67e+3 #Specific heat of iron in J/Kg-K\n", + "C = 0.376e3 #Specific heat of copper in J/Kg-K\n", + "Ks = 83 # Conductivity of iron in W/m-K\n", + "K = 398 # Conductivity of copper in W/m-K\n", + "D= 8960 # Density of copper in Kg/m**3\n", + "h = .1 # Height in m\n", + "hF = 1420 # Total heat transfer coefficient across the casting-mould interface in W/m**2-\u00b0C\n", + "AlphaS = K /(D*C)\n", + "thetaS = 982 #In \u00b0C as in example 2.6\n", + "h1= (1+(sqrt((Ks*Dm*Cs)/(K*D*C))))*hF\n", + "a = 1/2 + (sqrt((1/4)+Cs*(thetaF-thetaS)/(3*L)))\n", + "delta=h/2\n", + "ts = (delta+((h1*delta**2)/(2*Ks)))/((h1*(thetaF-thetaS))/(Dm*L*a)) # in sec\n", + "ts_ = ts/3600 # in hours\n", + "h2= (1+(sqrt((K*D*C)/(Ks*Dm*Cs))))*hF\n", + "gama= ((h2**2)/(K**2))*AlphaS*ts\n", + "thetaS_ = thetaO + (thetaS-thetaO)*(1-((exp(gama))))\n", + "print \" Solidification time = %f hr,\\n The surface temperature of the mould = %f \u00b0 C\"%(ts_,thetaS_)\n", + "# The value of the surface temperature of the mould in the book is given as 658.1\u00b0 C, Which is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Solidification time = 0.026965 hr,\n", + " The surface temperature of the mould = -1901.439242 \u00b0 C\n" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 8 on page no. 77" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given that\n", + "A= 60*7.5 # Cross sectional area in cm**2\n", + "v=0.05 # Withdrawal rate in m/sec\n", + "t = 0.0125 # Thickness in m\n", + "thetaF= 1500 # Temperature of mould face in degree centigrate\n", + "thetaP = 1550 # \n", + "thetaO = 20 # Initial temperature of mould in Degree centigrate\n", + "L= 268e3 # Latent heat of molten metal in J/Kg\n", + "Dm = 7680 # Density of molten metal in Kg/m**3\n", + "Cs = 0.67e+3 #Specific heat of molten metal in J/Kg-K\n", + "Cm = 0.755e3 #Specific heat of mould in J/Kg-K\n", + "Ks = 76 # Conductivity of molten metal in W/m-K\n", + "hF = 1420 # Heat transfer coefficient at the casting-mould interface in W/m**2-\u00b0C\n", + "Dtheta = 10 # Maximum temperature of cooling water in \u00b0 C\n", + "L_ = L+Cm*(thetaP-thetaF)\n", + "x=L_ / (Cs*(thetaF-thetaO))\n", + "y= hF*t/Ks\n", + "print \"L_/(Cs(thetaF-thetaO)) = %f,\\nhF*t/Ks = %f\"%(x,y)\n", + "z=0.11 # Where z=hF**2 * lm / (v*Ks*Dm*Cs)\n", + "lm= (z*v*Ks*Dm*Cs)/(hF**2)\n", + "Z=0.28 # Where Z=Q/(lm*(thetaF-thetaO)*sqrt(lm*v*Dm*Cs*Ks))\n", + "Q = Z*lm*(thetaF-thetaO)*sqrt(lm*v*Dm*Cs*Ks)\n", + "m = Q / (4.2e3*Dtheta)\n", + "print \"The mould length = %f meter,\\nThe cooling water requirement = %f Kg/sec\"%(lm,m)\n", + "# Answer for The cooling water requirement in the book is given as 5.05 Kg/sec, Which is wrong." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "L_/(Cs(thetaF-thetaO)) = 0.308340,\n", + "hF*t/Ks = 0.233553\n", + "The mould length = 1.066684 meter,\n", + "The cooling water requirement = 48.065525 Kg/sec\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 9 on page no. 81" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import floor\n", + "# Given that\n", + "a = 15 # Side of the aluminium cube in cm\n", + "Sh = 0.065 # Volume shrinkage of aluminium during solidification\n", + "Vc = a**3\n", + "Vr = 3*Sh*Vc\n", + "h = ((4*Vr)/pi)**(1/3)\n", + "Rr = 6.0/h # Where Rr= (A/V)r\n", + "Rc = 6.0/a # Where Rc = (A/V)c\n", + "print \"(A/V)r=%f, (A/V)c=%f\\n Hence Rr is greater than Rc\"%(Rr,Rc)\n", + "dmin = 6.0/Rc\n", + "Vr_ = (pi/4)*dmin**3\n", + "print \"\"\" With minimum value of d Vr=%d cm**3 .\n", + "This valume is much more than the minimum Vr necessary. \n", + "Let us now consider the top riser when the optimum cylindrical shape is obtained with h=d/2 \n", + "and again (A/V)r = 6/d. However, with a large top riser,\\n the cube loses its top surface for the purpose of heat dissipation.\"\"\"%Vr_\n", + "Rc_ = 5.0/a\n", + "dmin_=6.0/Rc_\n", + "print \" d should be greater than or equal to %d cm\"%dmin_\n", + "Vr__ = (pi/4)*dmin_**2 *floor(h)\n", + "print \" The riser volume with minimum diameter is %d cm**3\"%Vr__" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(A/V)r=6.000000, (A/V)c=0.400000\n", + " Hence Rr is greater than Rc\n", + " With minimum value of d Vr=2650 cm**3 .\n", + "This valume is much more than the minimum Vr necessary. \n", + "Let us now consider the top riser when the optimum cylindrical shape is obtained with h=d/2 \n", + "and again (A/V)r = 6/d. However, with a large top riser,\n", + " the cube loses its top surface for the purpose of heat dissipation.\n", + " d should be greater than or equal to 18 cm\n", + " The riser volume with minimum diameter is 254 cm**3\n" + ] + } + ], + "prompt_number": 40 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter1.ipynb b/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter1.ipynb new file mode 100755 index 00000000..aa2a3025 --- /dev/null +++ b/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter1.ipynb @@ -0,0 +1,389 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 - Linear Algebraic Equations" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.1 Page 24" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the solution of ex 1.1 by TDMA method is\n", + "317.5\n", + "395.0\n", + "432.5\n", + "430.0\n", + "387.5\n", + "305.0\n", + "182.5\n" + ] + } + ], + "source": [ + "from numpy import zeros\n", + "from __future__ import division\n", + "a=[0];b=[];c=[]\n", + "for i in range(1,7):\n", + " a.append(1) #sub diagonal assignment\n", + "\n", + "for j in range(0,7):\n", + " b.append(-2) #main diagonal assignment\n", + "\n", + "for k in range(0,6):\n", + " c.append(1) #super diagonal assignment\n", + "\n", + "d=[-240] #given values assignment\n", + "for l in range(1,6):\n", + " d.append(-40) \n", + "\n", + "d.append(-60)\n", + "i=1#\n", + "n=7#\n", + "beta1=[b[i-1]]# #initial b is equal to beta since a1=0\n", + "gamma1=[d[i-1]/beta1[i-1]]# #since c7=0\n", + "m=i+1\n", + "for j in range(m,n+1):\n", + " beta1.append(b[j-1]-a[j-1]*c[j-1-1]/beta1[j-1-1])\n", + " gamma1.append((d[j-1]-a[j-1]*gamma1[j-1-1])/beta1[j-1])\n", + "\n", + "#x(n)=gamma1(n)# #since c7=0\n", + "x=zeros(n-1)\n", + "#x[n-1]=gamma1[n-1]\n", + "x=list(x)\n", + "x.append(gamma1[-1])\n", + "n1=n-i# \n", + "\n", + "for k in range(0,n1):\n", + " j=n-k-1\n", + " x[j-1]=gamma1[j-1]-c[j-1]*x[j+1-1]/beta1[j-1]\n", + "\n", + "\n", + "print \"the solution of ex 1.1 by TDMA method is\"\n", + "for i in range(0,7):\n", + " print x[i]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.2 Page 24" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the solution using gauss elimination method is 3, 4 and 5\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "a1=10; a2=1; a3=2; #1st row\n", + "b1=2; b2=10; b3=1; #2nd row\n", + "c1=1; c2=2; c3=10; #3rd row \n", + "d1=44; d2=51; d3=61; #given values\n", + "\n", + "b3=b3-(b1/a1)*a3 # for making b1=0\n", + "b2=b2-(b1/a1)*a2\n", + "d2=d2-(b1/a1)*d1\n", + "b1=b1-(b1/a1)*a1\n", + "\n", + "c3=c3-(c1/a1)*a3 # for making c1=0\n", + "c2=c2-(c1/a1)*a2\n", + "d3=d3-(c1/a1)*d1\n", + "c1=c1-(c1/a1)*a1\n", + "\n", + "c3=c3-(c2/b2)*b3 # for making c2=0\n", + "d3=d3-(c2/b2)*d2\n", + "c2=c2-(c2/b2)*b2\n", + "\n", + "x3=d3/c3# # final values of x\n", + "x2=(d2-(b3*x3))/b2#\n", + "x1=(d1-(x3*a3)-(x2*a2))/a1#\n", + "print \"the solution using gauss elimination method is %d, %d and %d\"%(x1,x2,x3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.3 Page 26" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the solution using gauss elimination method is 3, -2 and 0\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "a1=3; a2=1; a3=-2; #1st row\n", + "b1=-1; b2=4; b3=-3; #2nd row\n", + "c1=1; c2=-1; c3=4; #3rd row \n", + "d1=9; d2=-8; d3=1; #given values\n", + "\n", + "b3=b3-(b1/a1)*a3 # for making b1=0\n", + "b2=b2-(b1/a1)*a2\n", + "d2=d2-(b1/a1)*d1\n", + "b1=b1-(b1/a1)*a1\n", + "\n", + "c3=c3-(c1/a1)*a3 # for making c1=0\n", + "c2=c2-(c1/a1)*a2\n", + "d3=d3-(c1/a1)*d1\n", + "c1=c1-(c1/a1)*a1\n", + "\n", + "c3=c3-(c2/b2)*b3 # for making c2=0\n", + "d3=d3-(c2/b2)*d2\n", + "c2=c2-(c2/b2)*b2\n", + "\n", + "x3=d3/c3# # final values of x\n", + "x2=(d2-(b3*x3))/b2#\n", + "x1=(d1-(x3*a3)-(x2*a2))/a1#\n", + "print \"the solution using gauss elimination method is %d, %d and %d\"%(x1,x2,x3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.4 Page 27" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the values of MOLAR FLOW RATES of D1, B1, D2, B2 respectively are : 26, 18, 9 and 17\n", + "the composition of stream B is 0.077, 0.247, 0.467 & 0.210\n", + "the composition of stream D is 0.274 0.492 0.12 0.114\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "\n", + "a1=.35; a2=.16; a3=.21; a4=.01 #1st row \n", + "b1=.54; b2=.42; b3=.54; b4=.1 #2nd row\n", + "c1=.04; c2=.24; c3=.1; c4=.65 #3rd row\n", + "d1=.07; d2=.18; d3=.15; d4=.24 #4th row \n", + "r1=14; r2=28; r3=17.5; r4=10.5 #given values\n", + "\n", + "b4=b4-(b1/a1)*a4 # for making b1=0\n", + "b3=b3-(b1/a1)*a3\n", + "b2=b2-(b1/a1)*a2\n", + "r2=r2-(b1/a1)*r1\n", + "b1=b1-(b1/a1)*a1\n", + "\n", + "c4=c4-(c1/a1)*a4 # for making c1=0\n", + "c3=c3-(c1/a1)*a3\n", + "c2=c2-(c1/a1)*a2\n", + "r3=r3-(c1/a1)*r1\n", + "c1=c1-(c1/a1)*a1\n", + "\n", + "d4=d4-(d1/a1)*a4 # for making d1=0\n", + "d3=d3-(d1/a1)*a3\n", + "d2=d2-(d1/a1)*a2\n", + "r4=r4-(d1/a1)*r1\n", + "d1=d1-(d1/a1)*a1\n", + "\n", + "c4=c4-(c2/b2)*b4 # for making c2=0\n", + "c3=c3-(c2/b2)*b3\n", + "r3=r3-(c2/b2)*r2\n", + "c2=c2-(c2/b2)*b2\n", + "\n", + "d4=d4-(d2/b2)*b4 # for making d2=0\n", + "d3=d3-(d2/b2)*b3\n", + "r4=r4-(d2/b2)*r2\n", + "d2=d2-(d2/b2)*b2\n", + "\n", + "d4=d4-(d3/c3)*c4 #for making d3=0\n", + "r4=r4-(d3/c3)*r3\n", + "d3=d3-(d3/c3)*c3\n", + "\n", + "B2=r4/d4#\n", + "D2=(r3-(c4*B2))/c3#\n", + "B1=(r2-(D2*b3)-(B2*b4))/b2#\n", + "D1=(r1-(B2*a4)-(D2*a3)-(B1*a2))/a1#\n", + "print \"the values of MOLAR FLOW RATES of D1, B1, D2, B2 respectively are : %.f, %.f, %.f and %.f\"%(D1,B1,D2,B2)\n", + "\n", + "B=D2+B2#\n", + "x1B=(.21*D2 + .01*B2)/B#\n", + "x2B=(.54*D2 + .1*B2)/B#\n", + "x3B=(.1*D2 + .65*B2)/B#\n", + "x4B=(.15*D2 + .24*B2)/B#\n", + "print \"the composition of stream B is %.3f, %.3f, %.3f & %.3f\"%(x1B,x2B,x3B,x4B)\n", + "\n", + "D=D1+B1#\n", + "x1D=(.35*D1 + .16*B1)/D#\n", + "x2D=(.54*D1 + .42*B1)/D#\n", + "x3D=(.04*D1 + .24*B1)/D#\n", + "x4D=(.07*D1 + .18*B1)/D#\n", + "print \"the composition of stream D is\",x1D,x2D,x3D,x4D" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.5 Page 28" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the values of x1,x2,x3 respectively is\n", + "3\n", + "4\n", + "5\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "xnew=[];e=[]\n", + "for i in range(0,3):\n", + " xnew.append(2)\n", + " e.append(1)\n", + "\n", + "x=1e-6\n", + "while e[0]>x and e[1]>x and e[2]>x:\n", + " xold=[]\n", + " for i in range(0,3):\n", + " xold.append(xnew[i])\n", + " \n", + " xnew[0]=(44-xold[1]-2*xold[2])/10\n", + " xnew[1]=(-2*xnew[0]+51-xold[2])/10\n", + " xnew[2]=(-2*xnew[1]-xnew[0]+61)/10\n", + " e=[]\n", + " for i in range(0,3):\n", + " e.append(abs(xnew[i]-xold[i]))\n", + " \n", + "print \"the values of x1,x2,x3 respectively is\"\n", + "for i in range(0,3):\n", + " print '%.f'%xnew[i]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa1.6 Page 28" + ] + }, + { + "cell_type": "code", + "execution_count": 75, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the values of x1,x2,x3 respectively is\n", + "3\n", + "-2\n", + "-1\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "xnew=[];e=[];\n", + "for i in range(0,3):\n", + " xnew.append(2)\n", + " e.append(1)\n", + "\n", + "x=1e-6\n", + "while e[0]>x and e[1]>x and e[2]>x:\n", + " xold=[]\n", + " for i in range(0,3):\n", + " xold.append(xnew[i])\n", + " \n", + " xnew[0]=(9-xold[1]+2*xold[2])/3\n", + " xnew[1]=(xnew[0]-8+3*xold[2])/4\n", + " xnew[2]=(xnew[1]-xnew[0]+1)/4\n", + " e=[]\n", + " for i in range(0,3):\n", + " e.append(abs(xnew[i]-xold[i]))\n", + " \n", + "print \"the values of x1,x2,x3 respectively is\"\n", + "for i in range(0,3):\n", + " print '%.f'%xnew[i]" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter2.ipynb b/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter2.ipynb new file mode 100755 index 00000000..5856d478 --- /dev/null +++ b/sample_notebooks/MohdAsif/MohdAsif_version_backup/chapter2.ipynb @@ -0,0 +1,349 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:7252e18079dddfe390b8ba1aeebeccc0ce63f41488e78d7d5f7b5e2c14af82fb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter2 - Semiconductor Devices" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex-2.1 Pg-2.18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Vf=0.2 #voltage in volts\n", + "Vr=60 #voltage in volts\n", + "If=60*10**(-3) #current in ampere\n", + "I0=0.025*10**(-3) #current in ampere\n", + "Rf=Vf/If #forward resistance\n", + "Rr=Vr/I0 #reverse resistance\n", + "Rr=Rr*1e-6\n", + "print \"the equivalent resistance are Rf=%.3f ohm and Rr=%-.1f M ohm\"%(Rf,Rr)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the equivalent resistance are Rf=3.333 ohm and Rr=2.4 M ohm\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Chapter-2 Ex-2.2 Pg-2.18" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Vf=0.7 \n", + "If=0.06 \n", + "Rf=Vf/If #DC forward resistance\n", + "print \"\\n DC forward resistance Rf : %.2f ohm\\n\"%(Rf)\n", + "print \"as the forward voltage changes from P to Q\"\n", + "delta_Vf=0.77-.7 \n", + "delta_If=(120-60)*10**(-3) \n", + "rf=delta_Vf/delta_If #dynamic forward resistance\n", + "print \"\\n Dynamic forward resistance rf : %.3f ohm\"%(rf)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " DC forward resistance Rf : 11.67 ohm\n", + "\n", + "as the forward voltage changes from P to Q\n", + "\n", + " Dynamic forward resistance rf : 1.167 ohm\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex2_3 Pg-2-22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "V=10 #supply voltage\n", + "Rf=0 #forward resistance\n", + "Rl=1 #load resistance in k ohm\n", + "Vin=0.7 #cut in voltage\n", + "Il=(V-Vin)/Rl #applying KVL to the loop\n", + "If=Il \n", + "print \"\\n \\n current through the resistance Il=If = is %.1f mA\"%(If)\n", + "Vl=Il*Rl \n", + "print \"\\n \\n voltage across Rl is %.1f V\"%(Vl)\n", + "Pd=If*Vin \n", + "print \"\\n \\n diode power Pd = %.2f mW\"%(Pd)\n", + "Pl=Il*Vl \n", + "print \"\\n \\n load power Pl = %.2f mW\"%(Pl)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " \n", + " current through the resistance Il=If = is 9.3 mA\n", + "\n", + " \n", + " voltage across Rl is 9.3 V\n", + "\n", + " \n", + " diode power Pd = 6.51 mW\n", + "\n", + " \n", + " load power Pl = 86.49 mW\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EX2_4 PG-2.23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "Vf=0.7 #cut-in voltage\n", + "V=10 #supply voltage\n", + "Rl=500 #load resistance\n", + "If=(V-Vf)/Rl #applying KVL to the circuit\n", + "If=If*1e3\n", + "print \"\\n Forward current is %.2f mA\\n\"%(If)\n", + "print \"When forward resistance is Rf is 3.2 Ohm then\"\n", + "print \"the equivalent circuit is as shown in fig-2.25(b)\"\n", + "Rf=3.2 \n", + "If=(V-Vf)/(Rl+Rf) #applying KVL to the circuit\n", + "If=If*1e3\n", + "print \"\\n therefore Forward current is %.4f mA\"%(If)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " Forward current is 18.60 mA\n", + "\n", + "When forward resistance is Rf is 3.2 Ohm then\n", + "the equivalent circuit is as shown in fig-2.25(b)\n", + "\n", + " therefore Forward current is 18.4817 mA\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EX2_5 PG-2.23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy as np\n", + "%matplotlib inline\n", + "from matplotlib.pyplot import plot, xlabel, ylabel, show, grid, title\n", + "If=80e-3 #maximum forward current\n", + "Rf=0.4 #dynamic resistance\n", + "Vin=0.3 #cut-in voltage for germanium\n", + "print \"when forward current is zero then\"\n", + "Vf=Vin #voltage across the diode\n", + "print \" voltage across the diode is %1.1f V\\n\"%(Vf)\n", + "print \"when forward current is 80mA then\"\n", + "Vf=Vin+If*Rf \n", + "print \" voltage across the diode is %1.3f V\"%(Vf)\n", + "x=np.array([0,.1, .2, .3, .332]) #x-coordinate\n", + "y=np.array([0, 0, 0, 0, 80]) #y-coordinate\n", + "plot(x,y)\n", + "xlabel('voltage across the diode (V) ') \n", + "ylabel('current (mA)') \n", + "title('Piecewise linear characteristic')\n", + "grid()\n", + "show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when forward current is zero then\n", + " voltage across the diode is 0.3 V\n", + "\n", + "when forward current is 80mA then\n", + " voltage across the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yL5lV3uebAikYguyb5YAM6rm30T2IYuk15JdqzbIvkkfIGnXdN9YSa/uJd/m\nwLJU1/hY1fzrgBPSshtJ2qKXZXt9HpJ2Ap6KiB+RnTF0H2Xntd8oIq4g+4Dcp5f1rUrPcyC/AT4t\naXTKt7ukzXo85rfAeyRtouwXQYf3uD/IhoHaK68R8HGgE7gvza/UOT7cY9vrr+wlae9e8lWG1Kp1\nArsD/4esk6g2OS1jTcIdg/UrIu4h+/B9LCKWp3lXkg35LCD7AP7nNBQDG745zgNeWyk+A+cD50i6\nk+zC5pXH/RuwjaS7yfYq7gaei4gVZB3IZZIWAL9nw9Woqn2F7PrCvwPurZp/MnBQGmK6Haj8jLT6\n1z19PY8OoCtlPQa4gKy2Mi8NwVwCnNZLlp8A/5yK5VN6ub+y7R8B9wB3pqG1H9Bj7z0i5pN1ygvI\nLpHZs+MlItaQje//LD3PtcC/p/nHA79MxeflVds+CxiTitV/As7sZb3LyC7yMrZqXpB9MZgQETf0\nWGQ/so7MmoRPu22FkjQKGBMRa9I337nA7hGxtuBoLU3SGcC9EfHTAR43iqx+8ga/Z83DNQYr2ljg\n+jQUJOAEf8A0hO+TFbP77RjIhrgu93vWXLzHYGZm3bjGYGZm3bhjMDOzbtwxmJlZN+4YzMysG3cM\nZmbWjTsGMzPr5v8Ds1Mla6CkMg8AAAAASUVORK5CYII=\n", + "text": [ + "" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EX2_6 PG-2.28" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy as np\n", + "%matplotlib inline\n", + "from matplotlib.pyplot import plot, xlabel, ylabel, show, grid, title, subplot\n", + "If=25e-3 #current at Q-point\n", + "x=np.array([ 0, 0.5, 0.6, 1, 1.1 ]) #x-coordinate\n", + "y=np.array([ 0 , 1 , 5, 25, 30 ]) #y-coordinate\n", + "subplot(1,3,1)\n", + "plot(x,y)\n", + "x1=np.array([0.5, 1 , 3]) #x-coordinate\n", + "y1=np.array([ 31, 25, 0]) #y-coordinate\n", + "subplot(1,3,2)\n", + "plot(x1,y1)\n", + "x2=np.array([ 0, 1] )\n", + "y2=np.array([25 ,25] )\n", + "subplot(1,3,3)\n", + "plot(x2,y2)\n", + "xlabel('Vf (volts)') \n", + "ylabel('If (mA)') \n", + "title(\"Piece-wise linear characteristic\")\n", + "grid()\n", + "show()\n", + "print \"Q-point is denoted by the intersection of two lines as shown in the plot\"\n", + "delta_If=10e-3 #from the graph plotted\n", + "delta_Vf=0.9 #from the graph plotted\n", + "s=delta_If/delta_Vf #slope\n", + "print \"Therefore load resistance is the reciprocal of the slope \"\n", + "Rl=1/s #load resistance\n", + "print \"\\n required load resistance is %.0f ohm\"%(Rl)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAEZCAYAAACq1zMoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXmYFNXVuN/DqogKuLArLgHZB1EUURyNQVxZ9EONghCU\nmBgUP0kAN1AS10TELCZB/LkQUROVaIiCCySADEFkC8iHCyOjMiCCkVGDMHN+f9waaJqe3qa7q7r6\nvM/TT9dy76lTdev26XvOXURVMQzDMIxMU8dvBQzDMIxwYgbGMAzDyApmYAzDMIysYAbGMAzDyApm\nYAzDMIysYAbGMAzDyApmYAzDJ0Rkh4i081uPaETkKE83yaDMdiJSJSJ1vP2/i8jQTMnPBiIySUSe\n8luPTCAiZ4jIujTzpl1W9dLJZBhGcohIKXAkUAl8BbwC/ERVv1LVg/3UrSZUdSOQVd1U9fxsys8Q\ngRgkKCLDgZGqeka6MlR1AXBCEteaBBynqnsMSm3KylowhpFdFLjQMyYnAicBt/mrUmEiIqn+oc5k\nC65upmSlcW3fGhJmYAwjR6jqp8CrQGcAz2V0rLfdUER+KSIfiUi5iDwiIgdU5xWRASKyQkT+IyLv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uk/Iy0F9EmuLWdXkzQfqYqOoXQDdgPnAdbpLOyPw2aWMamIExDMMX\n1C3ENg/njno6QfJqPgJaRMlYCjwMvKyO/wDbReR0L9lQnOGIZgfeEscichhQT1VfAG7HGatqWgKl\nSepnRFDbFS0NwzBqw0zgBWBI1PGaWgyLgBuijj0LPAcURxy7Gvi9iDTCub9GxJD1R+BVEfkEuAn4\nfyJS/ad7fES6HjGuaSSBTddvGEZeISJvAleq6qaEiWt/rfbAL72OB0aKmIvMMIx845e4OEkuuA64\nP0fXCh3WgjEMwzCygrVgDMMwjKxgBsYwDMPICmZgDMMwjKxgBsYwDMPICmZgDMMwjKxgBsYwDMPI\nCv8fFIeXAyYn0X4AAAAASUVORK5CYII=\n", + "text": [ + "" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Q-point is denoted by the intersection of two lines as shown in the plot\n", + "Therefore load resistance is the reciprocal of the slope \n", + "\n", + " required load resistance is 90 ohm\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EX2_7 PG-2.29" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import exp\n", + "V=0.22 #forward bias voltage\n", + "T=25+273 #room temperature in degree kelvin\n", + "I0=2e-3 #reverse saturation current\n", + "n=1 #for germanium diode\n", + "k=8.62e-5#Boltzmann's constant\n", + "Vt=k*T \n", + "I=I0*(exp(V/(n*Vt))) # diode current\n", + "print \"therefore the P-N junction diode current is %f A\"%(I)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "therefore the P-N junction diode current is 10.483844 A\n" + ] + } + ], + "prompt_number": 7 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MohdAsif/ch2.ipynb b/sample_notebooks/MohdAsif/ch2.ipynb deleted file mode 100755 index 66270ccb..00000000 --- a/sample_notebooks/MohdAsif/ch2.ipynb +++ /dev/null @@ -1,387 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 Casting Processes" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 2.1 on page no. 46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import sqrt\n", - "# Given that\n", - "h=15 # Height of spur in cm\n", - "l= 50 # Length of cast in cm\n", - "w= 25 # weidth of cast in cm\n", - "h1= 15 # Height of cast in cm\n", - "g= 981 # Acceleration due to gravity in cm/sec**2\n", - "Ag= 5 # Cross sectional area of the grate in cm**2\n", - "v3= sqrt(2* g * h)\n", - "V = l*w*h1\n", - "tf1= V/(Ag*v3)\n", - "Am = l*w\n", - "tf2 = (Am/Ag)*(1/sqrt(2*g))*2*(sqrt(h) - sqrt(h-h1))\n", - "print \" Filling time for first design = %f sec, \\n Filling time for second design = %f sec\"% (tf1, tf2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Filling time for first design = 21.859294 sec, \n", - " Filling time for second design = 43.718589 sec\n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 2 on page no. 53" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import pi, sqrt\n", - "# Given that\n", - "h=15 # Height of spur in cm\n", - "l= 50 # Length of cast in cm\n", - "w= 25 # weidth of cast in cm\n", - "h1= 15 # Height of cast in cm\n", - "g= 981 # Acceleration due to gravity in cm/sec**2\n", - "Ag= 5 # Cross sectional area of the grate in cm**2\n", - "Dm = 7800 # Density of molten Fe in Kg/m**3\n", - "Neta = 0.00496 # Kinetic viscosity in Kg/m-sec\n", - "theta = 90 # Angle in degree\n", - "Eq = 25 # (L/D) Equivalent \n", - "v3= sqrt(2* g * h)*(10**(-2))\n", - "d= sqrt((Ag*4)/(pi))*(10**(-2))\n", - "Re = Dm*v3*d/Neta\n", - "f = 0.0791*(Re)**(-1/4)\n", - "L=0.12 # in meter\n", - "Cd= (1+0.45+4*f*((L/d)+Eq))**(-1/2)\n", - "v3_ = Cd*v3\n", - "Re_ = (v3_/v3)*(Re)\n", - "f_ = 0.0791 *(Re_)**(-1/4)\n", - "Cd_ = (1+0.46+4*f_*(L/d + Eq))**(-1/2)\n", - "v3__ = Cd_*v3\n", - "V = l*w*h1\n", - "tf= (V/(Ag*v3__))*(10**-2)\n", - "print \" Filling time for first design = %f sec. \"% tf " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Filling time for first design = 31.918954 sec. \n" - ] - } - ], - "prompt_number": 35 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem on page no. 56" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given that\n", - "Hi=1.2 # Initial height in m\n", - "H= 0.05 # Height in m\n", - "g= 9.81 # Acceleration due to gravity in m/sec**2\n", - "Dm = 2700 # Density of molten metal in Kg/m**3\n", - "Neta = 0.00273 # Kinetic viscosity in Kg/m-sec \n", - "d= 0.075 # Diameter in m\n", - "D = 1 # Internal diameter of ladle in m\n", - "v3= sqrt(2* g * Hi)\n", - "Re = Dm*v3*d/Neta\n", - "ef=0.075\n", - "Cd= (1+ef)**(-1/2)\n", - "ef_=0.82\n", - "Re_ = (2+ef_)**(-1/2)\n", - "v3_ = sqrt(2*g*H)\n", - "Re_ = Dm*v3_*d/Neta\n", - "At = (pi/4)*D**2\n", - "An = (pi/4)*d**2\n", - "Cd= 0.96\n", - "tf= (sqrt(2/g))*(At/An)*(1/Cd)*sqrt(Hi)\n", - "m = Dm*An*Cd*sqrt(2*g*Hi)\n", - "m_ = Dm*An*Cd*sqrt(2*g*Hi*0.25)\n", - "print \"\"\"Time required to empty the ladle = %f sec,\n", - "Discharge rate are -\n", - "Initially = %f Kg/sec \n", - "When the ladle is 75 percent empty = %f Kg/sec. \"\"\"%(tf,m,m_)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time required to empty the ladle = 91.596179 sec,\n", - "Discharge rate are -\n", - "Initially = 55.563236 Kg/sec \n", - "When the ladle is 75 percent empty = 27.781618 Kg/sec. \n" - ] - } - ], - "prompt_number": 36 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 5 on page no. 66" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from sympy import symbols, solve\n", - "# Given that\n", - "thetaF= 1540 # Temperature of mould face in degree centigrade\n", - "Theta0 = 28 # Initial temperature of mould in Degree centigrade\n", - "L= 272e3 # Latent heat of liquid metal in J/Kg\n", - "Dm = 7850 # Density of liquid metal in Kg/m**3\n", - "c = 1.17e+3 #Specific heat of sand in J/Kg-K\n", - "k = 0.8655 # Conductivity of sand in W/m-K\n", - "D= 1600 # Density of sand in Kg/m**3\n", - "h = 0.1 # Height in m\n", - "b = 10 # Thickness of slab in cm\n", - "r =h/2# V/A in meter\n", - "lamda = (thetaF - Theta0)*(D*c)/(Dm*L)\n", - "Beta1 = 2*lamda/sqrt(pi)\n", - "Alpha = k /(D*c)\n", - "ts1 = r**2 /((Beta1**2)*Alpha)#In sec\n", - "ts1_=ts1/3600 # In hour\n", - "Beta= symbols('Beta') \n", - "p=Beta**2 - lamda*(2/sqrt(pi))*Beta -lamda/3\n", - "Beta2 = solve(p)[0]\n", - "print \"The value of Beta2 is %f \"%Beta2\n", - "print \"We only take the positive value of Beta2 ,\\nHence Beta2=1.75\" \n", - "r1 = r/3\n", - "ts2 = (r1**2)/((1.75**2)*Alpha) # in sec\n", - "ts2_=ts2/3600#in Hour\n", - "print \"Solidification time for slab-shaped casting = %f hr,\\nSolidification time for sphere = %f hr\"%(ts1_,ts2_)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of Beta2 is -0.252713 \n", - "We only take the positive value of Beta2 ,\n", - "Hence Beta2=1.75\n", - "Solidification time for slab-shaped casting = 0.671318 hr,\n", - "Solidification time for sphere = 0.054495 hr\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 7 on page no. 75" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given that\n", - "thetaF= 1540 # Temperature of mould face in degree centigrade\n", - "thetaO = 28 # Initial temperature of mould in Degree centigrade\n", - "L= 272e3 # Latent heat of iron in J/Kg\n", - "Dm = 7850 # Density of iron in Kg/m**3\n", - "Cs = 0.67e+3 #Specific heat of iron in J/Kg-K\n", - "C = 0.376e3 #Specific heat of copper in J/Kg-K\n", - "Ks = 83 # Conductivity of iron in W/m-K\n", - "K = 398 # Conductivity of copper in W/m-K\n", - "D= 8960 # Density of copper in Kg/m**3\n", - "h = .1 # Height in m\n", - "hF = 1420 # Total heat transfer coefficient across the casting-mould interface in W/m**2-\u00b0C\n", - "AlphaS = K /(D*C)\n", - "thetaS = 982 #In \u00b0C as in example 2.6\n", - "h1= (1+(sqrt((Ks*Dm*Cs)/(K*D*C))))*hF\n", - "a = 1/2 + (sqrt((1/4)+Cs*(thetaF-thetaS)/(3*L)))\n", - "delta=h/2\n", - "ts = (delta+((h1*delta**2)/(2*Ks)))/((h1*(thetaF-thetaS))/(Dm*L*a)) # in sec\n", - "ts_ = ts/3600 # in hours\n", - "h2= (1+(sqrt((K*D*C)/(Ks*Dm*Cs))))*hF\n", - "gama= ((h2**2)/(K**2))*AlphaS*ts\n", - "thetaS_ = thetaO + (thetaS-thetaO)*(1-((exp(gama))))\n", - "print \" Solidification time = %f hr,\\n The surface temperature of the mould = %f \u00b0 C\"%(ts_,thetaS_)\n", - "# The value of the surface temperature of the mould in the book is given as 658.1\u00b0 C, Which is wrong." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Solidification time = 0.026965 hr,\n", - " The surface temperature of the mould = -1901.439242 \u00b0 C\n" - ] - } - ], - "prompt_number": 38 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 8 on page no. 77" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given that\n", - "A= 60*7.5 # Cross sectional area in cm**2\n", - "v=0.05 # Withdrawal rate in m/sec\n", - "t = 0.0125 # Thickness in m\n", - "thetaF= 1500 # Temperature of mould face in degree centigrate\n", - "thetaP = 1550 # \n", - "thetaO = 20 # Initial temperature of mould in Degree centigrate\n", - "L= 268e3 # Latent heat of molten metal in J/Kg\n", - "Dm = 7680 # Density of molten metal in Kg/m**3\n", - "Cs = 0.67e+3 #Specific heat of molten metal in J/Kg-K\n", - "Cm = 0.755e3 #Specific heat of mould in J/Kg-K\n", - "Ks = 76 # Conductivity of molten metal in W/m-K\n", - "hF = 1420 # Heat transfer coefficient at the casting-mould interface in W/m**2-\u00b0C\n", - "Dtheta = 10 # Maximum temperature of cooling water in \u00b0 C\n", - "L_ = L+Cm*(thetaP-thetaF)\n", - "x=L_ / (Cs*(thetaF-thetaO))\n", - "y= hF*t/Ks\n", - "print \"L_/(Cs(thetaF-thetaO)) = %f,\\nhF*t/Ks = %f\"%(x,y)\n", - "z=0.11 # Where z=hF**2 * lm / (v*Ks*Dm*Cs)\n", - "lm= (z*v*Ks*Dm*Cs)/(hF**2)\n", - "Z=0.28 # Where Z=Q/(lm*(thetaF-thetaO)*sqrt(lm*v*Dm*Cs*Ks))\n", - "Q = Z*lm*(thetaF-thetaO)*sqrt(lm*v*Dm*Cs*Ks)\n", - "m = Q / (4.2e3*Dtheta)\n", - "print \"The mould length = %f meter,\\nThe cooling water requirement = %f Kg/sec\"%(lm,m)\n", - "# Answer for The cooling water requirement in the book is given as 5.05 Kg/sec, Which is wrong." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "L_/(Cs(thetaF-thetaO)) = 0.308340,\n", - "hF*t/Ks = 0.233553\n", - "The mould length = 1.066684 meter,\n", - "The cooling water requirement = 48.065525 Kg/sec\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 9 on page no. 81" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import floor\n", - "# Given that\n", - "a = 15 # Side of the aluminium cube in cm\n", - "Sh = 0.065 # Volume shrinkage of aluminium during solidification\n", - "Vc = a**3\n", - "Vr = 3*Sh*Vc\n", - "h = ((4*Vr)/pi)**(1/3)\n", - "Rr = 6.0/h # Where Rr= (A/V)r\n", - "Rc = 6.0/a # Where Rc = (A/V)c\n", - "print \"(A/V)r=%f, (A/V)c=%f\\n Hence Rr is greater than Rc\"%(Rr,Rc)\n", - "dmin = 6.0/Rc\n", - "Vr_ = (pi/4)*dmin**3\n", - "print \"\"\" With minimum value of d Vr=%d cm**3 .\n", - "This valume is much more than the minimum Vr necessary. \n", - "Let us now consider the top riser when the optimum cylindrical shape is obtained with h=d/2 \n", - "and again (A/V)r = 6/d. However, with a large top riser,\\n the cube loses its top surface for the purpose of heat dissipation.\"\"\"%Vr_\n", - "Rc_ = 5.0/a\n", - "dmin_=6.0/Rc_\n", - "print \" d should be greater than or equal to %d cm\"%dmin_\n", - "Vr__ = (pi/4)*dmin_**2 *floor(h)\n", - "print \" The riser volume with minimum diameter is %d cm**3\"%Vr__" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(A/V)r=6.000000, (A/V)c=0.400000\n", - " Hence Rr is greater than Rc\n", - " With minimum value of d Vr=2650 cm**3 .\n", - "This valume is much more than the minimum Vr necessary. \n", - "Let us now consider the top riser when the optimum cylindrical shape is obtained with h=d/2 \n", - "and again (A/V)r = 6/d. However, with a large top riser,\n", - " the cube loses its top surface for the purpose of heat dissipation.\n", - " d should be greater than or equal to 18 cm\n", - " The riser volume with minimum diameter is 254 cm**3\n" - ] - } - ], - "prompt_number": 40 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/MohdAsif/chapter1.ipynb b/sample_notebooks/MohdAsif/chapter1.ipynb deleted file mode 100755 index aa2a3025..00000000 --- a/sample_notebooks/MohdAsif/chapter1.ipynb +++ /dev/null @@ -1,389 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 - Linear Algebraic Equations" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.1 Page 24" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the solution of ex 1.1 by TDMA method is\n", - "317.5\n", - "395.0\n", - "432.5\n", - "430.0\n", - "387.5\n", - "305.0\n", - "182.5\n" - ] - } - ], - "source": [ - "from numpy import zeros\n", - "from __future__ import division\n", - "a=[0];b=[];c=[]\n", - "for i in range(1,7):\n", - " a.append(1) #sub diagonal assignment\n", - "\n", - "for j in range(0,7):\n", - " b.append(-2) #main diagonal assignment\n", - "\n", - "for k in range(0,6):\n", - " c.append(1) #super diagonal assignment\n", - "\n", - "d=[-240] #given values assignment\n", - "for l in range(1,6):\n", - " d.append(-40) \n", - "\n", - "d.append(-60)\n", - "i=1#\n", - "n=7#\n", - "beta1=[b[i-1]]# #initial b is equal to beta since a1=0\n", - "gamma1=[d[i-1]/beta1[i-1]]# #since c7=0\n", - "m=i+1\n", - "for j in range(m,n+1):\n", - " beta1.append(b[j-1]-a[j-1]*c[j-1-1]/beta1[j-1-1])\n", - " gamma1.append((d[j-1]-a[j-1]*gamma1[j-1-1])/beta1[j-1])\n", - "\n", - "#x(n)=gamma1(n)# #since c7=0\n", - "x=zeros(n-1)\n", - "#x[n-1]=gamma1[n-1]\n", - "x=list(x)\n", - "x.append(gamma1[-1])\n", - "n1=n-i# \n", - "\n", - "for k in range(0,n1):\n", - " j=n-k-1\n", - " x[j-1]=gamma1[j-1]-c[j-1]*x[j+1-1]/beta1[j-1]\n", - "\n", - "\n", - "print \"the solution of ex 1.1 by TDMA method is\"\n", - "for i in range(0,7):\n", - " print x[i]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.2 Page 24" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the solution using gauss elimination method is 3, 4 and 5\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "a1=10; a2=1; a3=2; #1st row\n", - "b1=2; b2=10; b3=1; #2nd row\n", - "c1=1; c2=2; c3=10; #3rd row \n", - "d1=44; d2=51; d3=61; #given values\n", - "\n", - "b3=b3-(b1/a1)*a3 # for making b1=0\n", - "b2=b2-(b1/a1)*a2\n", - "d2=d2-(b1/a1)*d1\n", - "b1=b1-(b1/a1)*a1\n", - "\n", - "c3=c3-(c1/a1)*a3 # for making c1=0\n", - "c2=c2-(c1/a1)*a2\n", - "d3=d3-(c1/a1)*d1\n", - "c1=c1-(c1/a1)*a1\n", - "\n", - "c3=c3-(c2/b2)*b3 # for making c2=0\n", - "d3=d3-(c2/b2)*d2\n", - "c2=c2-(c2/b2)*b2\n", - "\n", - "x3=d3/c3# # final values of x\n", - "x2=(d2-(b3*x3))/b2#\n", - "x1=(d1-(x3*a3)-(x2*a2))/a1#\n", - "print \"the solution using gauss elimination method is %d, %d and %d\"%(x1,x2,x3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.3 Page 26" - ] - }, - { - "cell_type": "code", - "execution_count": 59, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the solution using gauss elimination method is 3, -2 and 0\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "a1=3; a2=1; a3=-2; #1st row\n", - "b1=-1; b2=4; b3=-3; #2nd row\n", - "c1=1; c2=-1; c3=4; #3rd row \n", - "d1=9; d2=-8; d3=1; #given values\n", - "\n", - "b3=b3-(b1/a1)*a3 # for making b1=0\n", - "b2=b2-(b1/a1)*a2\n", - "d2=d2-(b1/a1)*d1\n", - "b1=b1-(b1/a1)*a1\n", - "\n", - "c3=c3-(c1/a1)*a3 # for making c1=0\n", - "c2=c2-(c1/a1)*a2\n", - "d3=d3-(c1/a1)*d1\n", - "c1=c1-(c1/a1)*a1\n", - "\n", - "c3=c3-(c2/b2)*b3 # for making c2=0\n", - "d3=d3-(c2/b2)*d2\n", - "c2=c2-(c2/b2)*b2\n", - "\n", - "x3=d3/c3# # final values of x\n", - "x2=(d2-(b3*x3))/b2#\n", - "x1=(d1-(x3*a3)-(x2*a2))/a1#\n", - "print \"the solution using gauss elimination method is %d, %d and %d\"%(x1,x2,x3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.4 Page 27" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the values of MOLAR FLOW RATES of D1, B1, D2, B2 respectively are : 26, 18, 9 and 17\n", - "the composition of stream B is 0.077, 0.247, 0.467 & 0.210\n", - "the composition of stream D is 0.274 0.492 0.12 0.114\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "\n", - "a1=.35; a2=.16; a3=.21; a4=.01 #1st row \n", - "b1=.54; b2=.42; b3=.54; b4=.1 #2nd row\n", - "c1=.04; c2=.24; c3=.1; c4=.65 #3rd row\n", - "d1=.07; d2=.18; d3=.15; d4=.24 #4th row \n", - "r1=14; r2=28; r3=17.5; r4=10.5 #given values\n", - "\n", - "b4=b4-(b1/a1)*a4 # for making b1=0\n", - "b3=b3-(b1/a1)*a3\n", - "b2=b2-(b1/a1)*a2\n", - "r2=r2-(b1/a1)*r1\n", - "b1=b1-(b1/a1)*a1\n", - "\n", - "c4=c4-(c1/a1)*a4 # for making c1=0\n", - "c3=c3-(c1/a1)*a3\n", - "c2=c2-(c1/a1)*a2\n", - "r3=r3-(c1/a1)*r1\n", - "c1=c1-(c1/a1)*a1\n", - "\n", - "d4=d4-(d1/a1)*a4 # for making d1=0\n", - "d3=d3-(d1/a1)*a3\n", - "d2=d2-(d1/a1)*a2\n", - "r4=r4-(d1/a1)*r1\n", - "d1=d1-(d1/a1)*a1\n", - "\n", - "c4=c4-(c2/b2)*b4 # for making c2=0\n", - "c3=c3-(c2/b2)*b3\n", - "r3=r3-(c2/b2)*r2\n", - "c2=c2-(c2/b2)*b2\n", - "\n", - "d4=d4-(d2/b2)*b4 # for making d2=0\n", - "d3=d3-(d2/b2)*b3\n", - "r4=r4-(d2/b2)*r2\n", - "d2=d2-(d2/b2)*b2\n", - "\n", - "d4=d4-(d3/c3)*c4 #for making d3=0\n", - "r4=r4-(d3/c3)*r3\n", - "d3=d3-(d3/c3)*c3\n", - "\n", - "B2=r4/d4#\n", - "D2=(r3-(c4*B2))/c3#\n", - "B1=(r2-(D2*b3)-(B2*b4))/b2#\n", - "D1=(r1-(B2*a4)-(D2*a3)-(B1*a2))/a1#\n", - "print \"the values of MOLAR FLOW RATES of D1, B1, D2, B2 respectively are : %.f, %.f, %.f and %.f\"%(D1,B1,D2,B2)\n", - "\n", - "B=D2+B2#\n", - "x1B=(.21*D2 + .01*B2)/B#\n", - "x2B=(.54*D2 + .1*B2)/B#\n", - "x3B=(.1*D2 + .65*B2)/B#\n", - "x4B=(.15*D2 + .24*B2)/B#\n", - "print \"the composition of stream B is %.3f, %.3f, %.3f & %.3f\"%(x1B,x2B,x3B,x4B)\n", - "\n", - "D=D1+B1#\n", - "x1D=(.35*D1 + .16*B1)/D#\n", - "x2D=(.54*D1 + .42*B1)/D#\n", - "x3D=(.04*D1 + .24*B1)/D#\n", - "x4D=(.07*D1 + .18*B1)/D#\n", - "print \"the composition of stream D is\",x1D,x2D,x3D,x4D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.5 Page 28" - ] - }, - { - "cell_type": "code", - "execution_count": 69, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the values of x1,x2,x3 respectively is\n", - "3\n", - "4\n", - "5\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "xnew=[];e=[]\n", - "for i in range(0,3):\n", - " xnew.append(2)\n", - " e.append(1)\n", - "\n", - "x=1e-6\n", - "while e[0]>x and e[1]>x and e[2]>x:\n", - " xold=[]\n", - " for i in range(0,3):\n", - " xold.append(xnew[i])\n", - " \n", - " xnew[0]=(44-xold[1]-2*xold[2])/10\n", - " xnew[1]=(-2*xnew[0]+51-xold[2])/10\n", - " xnew[2]=(-2*xnew[1]-xnew[0]+61)/10\n", - " e=[]\n", - " for i in range(0,3):\n", - " e.append(abs(xnew[i]-xold[i]))\n", - " \n", - "print \"the values of x1,x2,x3 respectively is\"\n", - "for i in range(0,3):\n", - " print '%.f'%xnew[i]" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa1.6 Page 28" - ] - }, - { - "cell_type": "code", - "execution_count": 75, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the values of x1,x2,x3 respectively is\n", - "3\n", - "-2\n", - "-1\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "xnew=[];e=[];\n", - "for i in range(0,3):\n", - " xnew.append(2)\n", - " e.append(1)\n", - "\n", - "x=1e-6\n", - "while e[0]>x and e[1]>x and e[2]>x:\n", - " xold=[]\n", - " for i in range(0,3):\n", - " xold.append(xnew[i])\n", - " \n", - " xnew[0]=(9-xold[1]+2*xold[2])/3\n", - " xnew[1]=(xnew[0]-8+3*xold[2])/4\n", - " xnew[2]=(xnew[1]-xnew[0]+1)/4\n", - " e=[]\n", - " for i in range(0,3):\n", - " e.append(abs(xnew[i]-xold[i]))\n", - " \n", - "print \"the values of x1,x2,x3 respectively is\"\n", - "for i in range(0,3):\n", - " print '%.f'%xnew[i]" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/MohdAsif/chapter2.ipynb b/sample_notebooks/MohdAsif/chapter2.ipynb deleted file mode 100755 index 5856d478..00000000 --- a/sample_notebooks/MohdAsif/chapter2.ipynb +++ /dev/null @@ -1,349 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:7252e18079dddfe390b8ba1aeebeccc0ce63f41488e78d7d5f7b5e2c14af82fb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter2 - Semiconductor Devices" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex-2.1 Pg-2.18" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Vf=0.2 #voltage in volts\n", - "Vr=60 #voltage in volts\n", - "If=60*10**(-3) #current in ampere\n", - "I0=0.025*10**(-3) #current in ampere\n", - "Rf=Vf/If #forward resistance\n", - "Rr=Vr/I0 #reverse resistance\n", - "Rr=Rr*1e-6\n", - "print \"the equivalent resistance are Rf=%.3f ohm and Rr=%-.1f M ohm\"%(Rf,Rr)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the equivalent resistance are Rf=3.333 ohm and Rr=2.4 M ohm\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Chapter-2 Ex-2.2 Pg-2.18" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Vf=0.7 \n", - "If=0.06 \n", - "Rf=Vf/If #DC forward resistance\n", - "print \"\\n DC forward resistance Rf : %.2f ohm\\n\"%(Rf)\n", - "print \"as the forward voltage changes from P to Q\"\n", - "delta_Vf=0.77-.7 \n", - "delta_If=(120-60)*10**(-3) \n", - "rf=delta_Vf/delta_If #dynamic forward resistance\n", - "print \"\\n Dynamic forward resistance rf : %.3f ohm\"%(rf)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " DC forward resistance Rf : 11.67 ohm\n", - "\n", - "as the forward voltage changes from P to Q\n", - "\n", - " Dynamic forward resistance rf : 1.167 ohm\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2_3 Pg-2-22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "V=10 #supply voltage\n", - "Rf=0 #forward resistance\n", - "Rl=1 #load resistance in k ohm\n", - "Vin=0.7 #cut in voltage\n", - "Il=(V-Vin)/Rl #applying KVL to the loop\n", - "If=Il \n", - "print \"\\n \\n current through the resistance Il=If = is %.1f mA\"%(If)\n", - "Vl=Il*Rl \n", - "print \"\\n \\n voltage across Rl is %.1f V\"%(Vl)\n", - "Pd=If*Vin \n", - "print \"\\n \\n diode power Pd = %.2f mW\"%(Pd)\n", - "Pl=Il*Vl \n", - "print \"\\n \\n load power Pl = %.2f mW\"%(Pl)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " \n", - " current through the resistance Il=If = is 9.3 mA\n", - "\n", - " \n", - " voltage across Rl is 9.3 V\n", - "\n", - " \n", - " diode power Pd = 6.51 mW\n", - "\n", - " \n", - " load power Pl = 86.49 mW\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EX2_4 PG-2.23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "Vf=0.7 #cut-in voltage\n", - "V=10 #supply voltage\n", - "Rl=500 #load resistance\n", - "If=(V-Vf)/Rl #applying KVL to the circuit\n", - "If=If*1e3\n", - "print \"\\n Forward current is %.2f mA\\n\"%(If)\n", - "print \"When forward resistance is Rf is 3.2 Ohm then\"\n", - "print \"the equivalent circuit is as shown in fig-2.25(b)\"\n", - "Rf=3.2 \n", - "If=(V-Vf)/(Rl+Rf) #applying KVL to the circuit\n", - "If=If*1e3\n", - "print \"\\n therefore Forward current is %.4f mA\"%(If)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " Forward current is 18.60 mA\n", - "\n", - "When forward resistance is Rf is 3.2 Ohm then\n", - "the equivalent circuit is as shown in fig-2.25(b)\n", - "\n", - " therefore Forward current is 18.4817 mA\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EX2_5 PG-2.23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import numpy as np\n", - "%matplotlib inline\n", - "from matplotlib.pyplot import plot, xlabel, ylabel, show, grid, title\n", - "If=80e-3 #maximum forward current\n", - "Rf=0.4 #dynamic resistance\n", - "Vin=0.3 #cut-in voltage for germanium\n", - "print \"when forward current is zero then\"\n", - "Vf=Vin #voltage across the diode\n", - "print \" voltage across the diode is %1.1f V\\n\"%(Vf)\n", - "print \"when forward current is 80mA then\"\n", - "Vf=Vin+If*Rf \n", - "print \" voltage across the diode is %1.3f V\"%(Vf)\n", - "x=np.array([0,.1, .2, .3, .332]) #x-coordinate\n", - "y=np.array([0, 0, 0, 0, 80]) #y-coordinate\n", - "plot(x,y)\n", - "xlabel('voltage across the diode (V) ') \n", - "ylabel('current (mA)') \n", - "title('Piecewise linear characteristic')\n", - "grid()\n", - "show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when forward current is zero then\n", - " voltage across the diode is 0.3 V\n", - "\n", - "when forward current is 80mA then\n", - " voltage across the diode is 0.332 V\n" - ] - }, - { - "metadata": {}, - "output_type": "display_data", - "png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEZCAYAAACTsIJzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xm4HGWd9vHvHRIEQuAkLElYDwEBdRgDKKKgHhAwOizi\ngrsJ44CDL8K84ghuA4jIoqO8LuPMKJAIM+jIQCSKSoAcRGQRyInIFhIIW0gghCUBDYb83j/q6aTP\n4Sx9lurq6r4/19XXqae6q+ru7qSfrufXVaWIwMzMrGJU0QHMzKyxuGMwM7Nu3DGYmVk37hjMzKwb\ndwxmZtaNOwYzM+vGHUOLkLRKUnsD5PiCpB+O8DrPkHRJmt4pPVeN5DZGmqQlkt5RdI6RIOkHkr48\nhOVK8V61otFFB7CRI2kJsC3wMvAC8CvgxIh4ISLGFZmtIiLOyWO1Vet/BGiI5zqAoCp3USR1ApdE\nxIVDXUdEnFDjtpYAfx8R16flyvJetRzvMTSXAA5PncA+wBuAQX+TK6HCv3FKKuRLlpJhrGJYnZOk\nwXyGBA3wXtnA3DE0qYhYCvwaeB2ApHWSpqTpV0n6pqSHJS1LQwGbVJaVdJSkLknPSVok6Z1p/paS\nLpS0VNJjks6qfDCkde2Tpj+atvea1P6kpCvTdPWwzyaSLpW0QtIzkm6TtO1A2+qPpPa07UquTklf\nlfQ7Sc9L+o2kraoev7+k36ftd0l6e9V9x0q6Jy23WNLxVfd1pFyfl/QE0Os3bknHVa3jbklTq+7e\nW9ICSc9K+omkV6Vl2iT9QtKTklZKmiNp+6p1dkr6mqSbyPYMp/SXta/3VNLZwFuB76Uhne+kx+4p\naa6kpyXdJ+kDVeuZmf69XC1pNXBQmndWun/rlP2ZtPxvU991CbATMCdt63O9vFcTJF0s6fH0vK8c\n6P22n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yte4t+fSc1t91Ux6zn9vRDzQz7Z7W+Yy4Ctp/uyIeLnqvlG9ZLES8x6DDeSnwIfJOoef\npXk3ktUPRim78MfbyL5lV3uebAikYguyb5YAM6rm30T2IYuk15JdqzbIvkkfIGnXdN9YSa/uJd/m\nwLJU1/hY1fzrgBPSshtJ2qKXZXt9HpJ2Ap6KiB+RnTF0H2Xntd8oIq4g+4Dcp5f1rUrPcyC/AT4t\naXTKt7ukzXo85rfAeyRtouwXQYf3uD/IhoHaK68R8HGgE7gvza/UOT7cY9vrr+wlae9e8lWG1Kp1\nArsD/4esk6g2OS1jTcIdg/UrIu4h+/B9LCKWp3lXkg35LCD7AP7nNBQDG745zgNeWyk+A+cD50i6\nk+zC5pXH/RuwjaS7yfYq7gaei4gVZB3IZZIWAL9nw9Woqn2F7PrCvwPurZp/MnBQGmK6Haj8jLT6\n1z19PY8OoCtlPQa4gKy2Mi8NwVwCnNZLlp8A/5yK5VN6ub+y7R8B9wB3pqG1H9Bj7z0i5pN1ygvI\nLpHZs+MlItaQje//LD3PtcC/p/nHA79MxeflVds+CxiTitV/As7sZb3LyC7yMrZqXpB9MZgQETf0\nWGQ/so7MmoRPu22FkjQKGBMRa9I337nA7hGxtuBoLU3SGcC9EfHTAR43iqx+8ga/Z83DNQYr2ljg\n+jQUJOAEf8A0hO+TFbP77RjIhrgu93vWXLzHYGZm3bjGYGZm3bhjMDOzbtwxmJlZN+4YzMysG3cM\nZmbWjTsGMzPr5v8Ds1Mla6CkMg8AAAAASUVORK5CYII=\n", - "text": [ - "" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EX2_6 PG-2.28" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import numpy as np\n", - "%matplotlib inline\n", - "from matplotlib.pyplot import plot, xlabel, ylabel, show, grid, title, subplot\n", - "If=25e-3 #current at Q-point\n", - "x=np.array([ 0, 0.5, 0.6, 1, 1.1 ]) #x-coordinate\n", - "y=np.array([ 0 , 1 , 5, 25, 30 ]) #y-coordinate\n", - "subplot(1,3,1)\n", - "plot(x,y)\n", - "x1=np.array([0.5, 1 , 3]) #x-coordinate\n", - "y1=np.array([ 31, 25, 0]) #y-coordinate\n", - "subplot(1,3,2)\n", - "plot(x1,y1)\n", - "x2=np.array([ 0, 1] )\n", - "y2=np.array([25 ,25] )\n", - "subplot(1,3,3)\n", - "plot(x2,y2)\n", - "xlabel('Vf (volts)') \n", - "ylabel('If (mA)') \n", - "title(\"Piece-wise linear characteristic\")\n", - "grid()\n", - "show()\n", - "print \"Q-point is denoted by the intersection of two lines as shown in the plot\"\n", - "delta_If=10e-3 #from the graph plotted\n", - "delta_Vf=0.9 #from the graph plotted\n", - "s=delta_If/delta_Vf #slope\n", - "print \"Therefore load resistance is the reciprocal of the slope \"\n", - "Rl=1/s #load resistance\n", - "print \"\\n required load resistance is %.0f ohm\"%(Rl)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "display_data", - "png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAEZCAYAAACq1zMoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXmYFNXVuN/DqogKuLArLgHZB1EUURyNQVxZ9EONghCU\nmBgUP0kAN1AS10TELCZB/LkQUROVaIiCCySADEFkC8iHCyOjMiCCkVGDMHN+f9waaJqe3qa7q7r6\nvM/TT9dy76lTdev26XvOXURVMQzDMIxMU8dvBQzDMIxwYgbGMAzDyApmYAzDMIysYAbGMAzDyApm\nYAzDMIysYAbGMAzDyApmYAzDJ0Rkh4i081uPaETkKE83yaDMdiJSJSJ1vP2/i8jQTMnPBiIySUSe\n8luPTCAiZ4jIujTzpl1W9dLJZBhGcohIKXAkUAl8BbwC/ERVv1LVg/3UrSZUdSOQVd1U9fxsys8Q\ngRgkKCLDgZGqeka6MlR1AXBCEteaBBynqnsMSm3KylowhpFdFLjQMyYnAicBt/mrUm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+Io7CLexVzbNeXjxZz3rLGhyqblEvcAt39U0g9wPgWG+Z4nOBLyPOfYqbmNJIETMw\nhmH4xUvAd7315hup6vIk80Wuk/Iy0F9EmuLWdXkzQfqYqOoXQDdgPnAdbpLOyPw2aWMamIExDMMX\n1C3ENg/njno6QfJqPgJaRMlYCjwMvKyO/wDbReR0L9lQnOGIZgfeEscichhQT1VfAG7HGatqWgKl\nSepnRFDbFS0NwzBqw0zgBWBI1PGaWgyLgBuijj0LPAcURxy7Gvi9iDTCub9GxJD1R+BVEfkEuAn4\nfyJS/ad7fES6HjGuaSSBTddvGEZeISJvAleq6qaEiWt/rfbAL72OB0aKmIvMMIx845e4OEkuuA64\nP0fXCh3WgjEMwzCygrVgDMMwjKxgBsYwDMPICmZgDMMwjKxgBsYwDMPICmZgDMMwjKxgBsYwDMPI\nCv8fFIeXAyYn0X4AAAAASUVORK5CYII=\n", - "text": [ - "" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Q-point is denoted by the intersection of two lines as shown in the plot\n", - "Therefore load resistance is the reciprocal of the slope \n", - "\n", - " required load resistance is 90 ohm\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EX2_7 PG-2.29" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import exp\n", - "V=0.22 #forward bias voltage\n", - "T=25+273 #room temperature in degree kelvin\n", - "I0=2e-3 #reverse saturation current\n", - "n=1 #for germanium diode\n", - "k=8.62e-5#Boltzmann's constant\n", - "Vt=k*T \n", - "I=I0*(exp(V/(n*Vt))) # diode current\n", - "print \"therefore the P-N junction diode current is %f A\"%(I)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "therefore the P-N junction diode current is 10.483844 A\n" - ] - } - ], - "prompt_number": 7 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MohdGufran/MohdGufran_version_backup/chapter_10.ipynb b/sample_notebooks/MohdGufran/MohdGufran_version_backup/chapter_10.ipynb new file mode 100755 index 00000000..7d0f1d7b --- /dev/null +++ b/sample_notebooks/MohdGufran/MohdGufran_version_backup/chapter_10.ipynb @@ -0,0 +1,355 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter No - 10 : Mass Transfer\n", + " " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.1 - Page No. : 318" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "# Given data\n", + "P1=4 # in bar\n", + "P2=2 # in bar\n", + "T=25 # in degree C\n", + "Dhp=9*10**-8 # in m**2/s\n", + "S=3*10**-3 # in kg mole/m**3 bar\n", + "del_x=0.5*10**-3 # thickness in m\n", + "#(a) The molar concentration of a gas in terms of solubility\n", + "CH1=S*P1 # in kg mole/m**3\n", + "CH2=S*P2 # in kg mole/m**3\n", + "#(b) Molar diffusion flux of hydrogen through plastic memberence is given by Fick's law of diffision\n", + "#N_H= N_h/A = Dhp*(CH1-CH2)/del_x#\n", + "N_H= Dhp*(CH1-CH2)/del_x # in kg mole/s-m**2\n", + "print \"Molar diffusion flux of hydrogen through the membrane = %0.2e kg mole/s-m**2\" %N_H\n", + "#Mass_d_Flux= N_H*Molecular_Weight \n", + "Molecular_Weight=2#\n", + "Mass_d_Flux= N_H*Molecular_Weight \n", + "print \"Molar diffusion flux = %0.3e kg/s-m**2\" %Mass_d_Flux" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Molar diffusion flux of hydrogen through the membrane = 1.08e-06 kg mole/s-m**2\n", + "Molar diffusion flux = 2.160e-06 kg/s-m**2\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.2 - Page No. : 322" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "T=25 # in degree C\n", + "T=T+273 # in K\n", + "P=1#\n", + "V1=12 #Molecular volume of H2 in cm**3/gm mole\n", + "V2=30 #Molecular volume of Air in cm**3/gm mole\n", + "M1=2 # Molecular weight of H2\n", + "M2=29 # Molecular weight of Air\n", + "#The diffusion coefficient for gases in terms of molecular volumes may be express as\n", + "D_AB= .0043*T**(3/2)/(P*(V1**(1/3)+V2**(1/3)))*(1/M1+1/M2)**(1/2)#\n", + "print \"The diffusion coefficient for gases in terms of molecular volumes = %0.3f cm**2/sec\" %D_AB" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffusion coefficient for gases in terms of molecular volumes = 2.997 cm**2/sec\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.3 - Page No. : 322" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "T=300 # temp of gas mixture in K\n", + "D_HN2=18*10**-6 # in m**2/s at 300 K, 1 bar\n", + "T1=300 # in K\n", + "D_HO2=16*10**-6 # in m**2/s at 273 K, 1 bar\n", + "T2=273 # in K\n", + "O_2=0.2#\n", + "N_2=0.7#\n", + "H_2=0.1#\n", + "#The diffusivity at the mixture temperature and pressure are calculated as \n", + "# D1/D2 = (T1/T2)**(3/2)*(P2/P1)\n", + "D_HO2= (T/T2)**(3/2)*1/4*D_HO2#\n", + "D_HN2= (T/T1)**(3/2)*1/4*D_HN2#\n", + "#The composition of oxygen and nitrogen on a H2 free basis is \n", + "x_O= O_2/(1-H_2)#\n", + "x_N= N_2/(1-H_2)#\n", + "\n", + "# The effective diffusivity for the gas mixture at given temperature and pressure is\n", + "D= 1/(x_O/D_HO2+x_N/D_HN2) # in m**2/s\n", + "print \"Effective diffusivity = %0.3e m**2/s\" %D" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Effective diffusivity = 4.524e-06 m**2/s\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.4 - Page No. : 323" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from numpy import pi\n", + "# Given data\n", + "d=3 # in mm\n", + "d=d*10**-3 # in meter\n", + "T=25 # in \u00b0C\n", + "T=T+273 # in K\n", + "D= 0.4*10**-4 # in m**2/s\n", + "R= 8314#\n", + "P_A1=1 # in atm\n", + "P_A1=P_A1*10**5 # in w/m**2\n", + "P_A2=0#\n", + "C_A2=0#\n", + "x2= 15 # in meter\n", + "x1= 0#\n", + "A= pi/4*d**2#\n", + "M_A= D*A/(R*T)*(P_A1-P_A2)/(x2-x1) # in kg mole/sec\n", + "N_B= M_A#\n", + "M_B= M_A*29 # in kg/sec\n", + "print \"Value of N_B = %0.3e kg mole/sec\" %N_B\n", + "print \"Value of M_B = %0.3e kg /sec\" %M_B" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of N_B = 7.608e-13 kg mole/sec\n", + "Value of M_B = 2.206e-11 kg /sec\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.5 - Page No. : 325" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import log\n", + "# Given data\n", + "P=3 # in atm\n", + "P=P*10**5 # in N/m**2\n", + "r1=10 # in mm\n", + "r1=r1*10**-3 # in m\n", + "r2=20 # in mm\n", + "r2=r2*10**-3 # in m\n", + "R=4160 # in J/kg-K\n", + "T=303 # in K\n", + "D=3*10**-8 # in m**2/s\n", + "S=3*0.05# # Solubility of hydrogen at a pressure of 3 atm in m**3/m**3 of rubber tubing\n", + "del_x=r2-r1 # in m\n", + "L=1 # in m\n", + "Am=2*pi*L*del_x/log(r2/r1)#\n", + "#Formula P*V= m*R*T\n", + "V=S#\n", + "m=P*V/(R*T) # in kg/m**3 of rubber tubing at the inner surface of the pipe\n", + "C_A1=m#\n", + "C_A2=0#\n", + "#Diffusion flux through the cylinder is given\n", + "M=D*(C_A1-C_A2)*Am/del_x#\n", + "print \"Diffusion flux through the cylinder = %0.2e kg/sm\" %M" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diffusion flux through the cylinder = 9.71e-09 kg/sm\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.6 - Page No. : 329" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "R=4160 # in J/kg-K\n", + "M=2#\n", + "D_AB=1.944*10**-8 # in m**2/s\n", + "R_H2=R/M#\n", + "S=2*0.0532# # Solubility of hydrogen at a pressure of 2 atm in cm**3/cm**3 of pipe\n", + "P=2 # in atm\n", + "P=P*1.03*10**5 # N/m**2\n", + "T=25 # in degree C\n", + "T=T+273 # in K\n", + "r1=2.5 # in mm\n", + "r1=r1*10**-3 # in m\n", + "r2=5 # in mm\n", + "r2=r2*10**-3 # in m\n", + "del_x=r2-r1 # in m\n", + "L=1 # in m\n", + "#Formula P*V= m*R*T\n", + "V=S#\n", + "m=P*V/(R*T) # in kg/m**3 of pipe\n", + "# So, Concentration of H2 at inner surface of the pipe\n", + "C_A1=0.0176 # in kg/m**3\n", + "# The resistance of diffusion of H2 away from the outer surface is negligible i.e.\n", + "C_A2=0#\n", + "Am=2*pi*L*del_x/log(r2/r1)#\n", + "# Loss of H2 by diffusion \n", + "M_A= D_AB*(C_A1-C_A2)*Am/del_x#\n", + "print \"Loss of H2 by diffusion = %0.2ef kg/s\" %M_A" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Loss of H2 by diffusion = 3.10e-09f kg/s\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example No : 10.7 - Page No. : 330" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Px1= 0.14 # in bar\n", + "Px2= 0#\n", + "P=1.013 # in bar\n", + "Py1=P-Px1# # in bar\n", + "Py2=P-Px2# # in bar\n", + "D=8.5*10**-6 # in m**2/s\n", + "d=5 # diameter in meter\n", + "L=1 # in mm\n", + "L=L*10**-3 #in meter\n", + "M=78 # molecular weight\n", + "Am_x= 1/4*pi*d**2*M#\n", + "R=8314#\n", + "del_x=3 # thickness in mm\n", + "del_x=del_x*10**-3 # in m\n", + "T=20 # in degree C\n", + "T=T+273 # in K\n", + "P=P*10**5 # in N/m**2\n", + "m_x= D*Am_x*P*log(Py2/Py1)/(R*T*del_x)#\n", + "# The mass of the benzene to be evaporated\n", + "mass= 1/4*pi*d**2*L#\n", + "density=880 # in kg/m**3\n", + "m_b= mass*density#\n", + "toh=m_b/m_x # in sec\n", + "print \"Time taken for the entire organic compound to evaporate = %0.0f seconds\" %toh\n", + "\n", + "\n", + "# Note: Answer in the book is wrong" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Time taken for the entire organic compound to evaporate = 644 seconds\n" + ] + } + ], + "prompt_number": 25 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MohdGufran/chapter_10.ipynb b/sample_notebooks/MohdGufran/chapter_10.ipynb deleted file mode 100755 index 7d0f1d7b..00000000 --- a/sample_notebooks/MohdGufran/chapter_10.ipynb +++ /dev/null @@ -1,355 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter No - 10 : Mass Transfer\n", - " " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.1 - Page No. : 318" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "# Given data\n", - "P1=4 # in bar\n", - "P2=2 # in bar\n", - "T=25 # in degree C\n", - "Dhp=9*10**-8 # in m**2/s\n", - "S=3*10**-3 # in kg mole/m**3 bar\n", - "del_x=0.5*10**-3 # thickness in m\n", - "#(a) The molar concentration of a gas in terms of solubility\n", - "CH1=S*P1 # in kg mole/m**3\n", - "CH2=S*P2 # in kg mole/m**3\n", - "#(b) Molar diffusion flux of hydrogen through plastic memberence is given by Fick's law of diffision\n", - "#N_H= N_h/A = Dhp*(CH1-CH2)/del_x#\n", - "N_H= Dhp*(CH1-CH2)/del_x # in kg mole/s-m**2\n", - "print \"Molar diffusion flux of hydrogen through the membrane = %0.2e kg mole/s-m**2\" %N_H\n", - "#Mass_d_Flux= N_H*Molecular_Weight \n", - "Molecular_Weight=2#\n", - "Mass_d_Flux= N_H*Molecular_Weight \n", - "print \"Molar diffusion flux = %0.3e kg/s-m**2\" %Mass_d_Flux" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Molar diffusion flux of hydrogen through the membrane = 1.08e-06 kg mole/s-m**2\n", - "Molar diffusion flux = 2.160e-06 kg/s-m**2\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.2 - Page No. : 322" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "T=25 # in degree C\n", - "T=T+273 # in K\n", - "P=1#\n", - "V1=12 #Molecular volume of H2 in cm**3/gm mole\n", - "V2=30 #Molecular volume of Air in cm**3/gm mole\n", - "M1=2 # Molecular weight of H2\n", - "M2=29 # Molecular weight of Air\n", - "#The diffusion coefficient for gases in terms of molecular volumes may be express as\n", - "D_AB= .0043*T**(3/2)/(P*(V1**(1/3)+V2**(1/3)))*(1/M1+1/M2)**(1/2)#\n", - "print \"The diffusion coefficient for gases in terms of molecular volumes = %0.3f cm**2/sec\" %D_AB" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The diffusion coefficient for gases in terms of molecular volumes = 2.997 cm**2/sec\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.3 - Page No. : 322" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "T=300 # temp of gas mixture in K\n", - "D_HN2=18*10**-6 # in m**2/s at 300 K, 1 bar\n", - "T1=300 # in K\n", - "D_HO2=16*10**-6 # in m**2/s at 273 K, 1 bar\n", - "T2=273 # in K\n", - "O_2=0.2#\n", - "N_2=0.7#\n", - "H_2=0.1#\n", - "#The diffusivity at the mixture temperature and pressure are calculated as \n", - "# D1/D2 = (T1/T2)**(3/2)*(P2/P1)\n", - "D_HO2= (T/T2)**(3/2)*1/4*D_HO2#\n", - "D_HN2= (T/T1)**(3/2)*1/4*D_HN2#\n", - "#The composition of oxygen and nitrogen on a H2 free basis is \n", - "x_O= O_2/(1-H_2)#\n", - "x_N= N_2/(1-H_2)#\n", - "\n", - "# The effective diffusivity for the gas mixture at given temperature and pressure is\n", - "D= 1/(x_O/D_HO2+x_N/D_HN2) # in m**2/s\n", - "print \"Effective diffusivity = %0.3e m**2/s\" %D" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Effective diffusivity = 4.524e-06 m**2/s\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.4 - Page No. : 323" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from numpy import pi\n", - "# Given data\n", - "d=3 # in mm\n", - "d=d*10**-3 # in meter\n", - "T=25 # in \u00b0C\n", - "T=T+273 # in K\n", - "D= 0.4*10**-4 # in m**2/s\n", - "R= 8314#\n", - "P_A1=1 # in atm\n", - "P_A1=P_A1*10**5 # in w/m**2\n", - "P_A2=0#\n", - "C_A2=0#\n", - "x2= 15 # in meter\n", - "x1= 0#\n", - "A= pi/4*d**2#\n", - "M_A= D*A/(R*T)*(P_A1-P_A2)/(x2-x1) # in kg mole/sec\n", - "N_B= M_A#\n", - "M_B= M_A*29 # in kg/sec\n", - "print \"Value of N_B = %0.3e kg mole/sec\" %N_B\n", - "print \"Value of M_B = %0.3e kg /sec\" %M_B" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Value of N_B = 7.608e-13 kg mole/sec\n", - "Value of M_B = 2.206e-11 kg /sec\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.5 - Page No. : 325" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import log\n", - "# Given data\n", - "P=3 # in atm\n", - "P=P*10**5 # in N/m**2\n", - "r1=10 # in mm\n", - "r1=r1*10**-3 # in m\n", - "r2=20 # in mm\n", - "r2=r2*10**-3 # in m\n", - "R=4160 # in J/kg-K\n", - "T=303 # in K\n", - "D=3*10**-8 # in m**2/s\n", - "S=3*0.05# # Solubility of hydrogen at a pressure of 3 atm in m**3/m**3 of rubber tubing\n", - "del_x=r2-r1 # in m\n", - "L=1 # in m\n", - "Am=2*pi*L*del_x/log(r2/r1)#\n", - "#Formula P*V= m*R*T\n", - "V=S#\n", - "m=P*V/(R*T) # in kg/m**3 of rubber tubing at the inner surface of the pipe\n", - "C_A1=m#\n", - "C_A2=0#\n", - "#Diffusion flux through the cylinder is given\n", - "M=D*(C_A1-C_A2)*Am/del_x#\n", - "print \"Diffusion flux through the cylinder = %0.2e kg/sm\" %M" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diffusion flux through the cylinder = 9.71e-09 kg/sm\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.6 - Page No. : 329" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "R=4160 # in J/kg-K\n", - "M=2#\n", - "D_AB=1.944*10**-8 # in m**2/s\n", - "R_H2=R/M#\n", - "S=2*0.0532# # Solubility of hydrogen at a pressure of 2 atm in cm**3/cm**3 of pipe\n", - "P=2 # in atm\n", - "P=P*1.03*10**5 # N/m**2\n", - "T=25 # in degree C\n", - "T=T+273 # in K\n", - "r1=2.5 # in mm\n", - "r1=r1*10**-3 # in m\n", - "r2=5 # in mm\n", - "r2=r2*10**-3 # in m\n", - "del_x=r2-r1 # in m\n", - "L=1 # in m\n", - "#Formula P*V= m*R*T\n", - "V=S#\n", - "m=P*V/(R*T) # in kg/m**3 of pipe\n", - "# So, Concentration of H2 at inner surface of the pipe\n", - "C_A1=0.0176 # in kg/m**3\n", - "# The resistance of diffusion of H2 away from the outer surface is negligible i.e.\n", - "C_A2=0#\n", - "Am=2*pi*L*del_x/log(r2/r1)#\n", - "# Loss of H2 by diffusion \n", - "M_A= D_AB*(C_A1-C_A2)*Am/del_x#\n", - "print \"Loss of H2 by diffusion = %0.2ef kg/s\" %M_A" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Loss of H2 by diffusion = 3.10e-09f kg/s\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example No : 10.7 - Page No. : 330" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "Px1= 0.14 # in bar\n", - "Px2= 0#\n", - "P=1.013 # in bar\n", - "Py1=P-Px1# # in bar\n", - "Py2=P-Px2# # in bar\n", - "D=8.5*10**-6 # in m**2/s\n", - "d=5 # diameter in meter\n", - "L=1 # in mm\n", - "L=L*10**-3 #in meter\n", - "M=78 # molecular weight\n", - "Am_x= 1/4*pi*d**2*M#\n", - "R=8314#\n", - "del_x=3 # thickness in mm\n", - "del_x=del_x*10**-3 # in m\n", - "T=20 # in degree C\n", - "T=T+273 # in K\n", - "P=P*10**5 # in N/m**2\n", - "m_x= D*Am_x*P*log(Py2/Py1)/(R*T*del_x)#\n", - "# The mass of the benzene to be evaporated\n", - "mass= 1/4*pi*d**2*L#\n", - "density=880 # in kg/m**3\n", - "m_b= mass*density#\n", - "toh=m_b/m_x # in sec\n", - "print \"Time taken for the entire organic compound to evaporate = %0.0f seconds\" %toh\n", - "\n", - "\n", - "# Note: Answer in the book is wrong" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Time taken for the entire organic compound to evaporate = 644 seconds\n" - ] - } - ], - "prompt_number": 25 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/MohdRizwan/Chapter8.ipynb b/sample_notebooks/MohdRizwan/Chapter8.ipynb deleted file mode 100755 index 0017f769..00000000 --- a/sample_notebooks/MohdRizwan/Chapter8.ipynb +++ /dev/null @@ -1,253 +0,0 @@ -{ - "metadata": { - "name": "Rijwan", - "signature": "sha256:ccfeb26b31d807a5210cb280c22c39e23c0906566f59b1bedfeb5dfebe856c36" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Ch-8 Oscillators" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.1, page 272 " - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#Given data\n", - "A=50 #unitless\n", - "criteria = \"Barkhausen criterion for oscillator : Beta*A=1\"\n", - "Beta=1/A #unitless\n", - "print criteria,\"\\nFeedback Factor for oscillator : \",Beta" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Barkhausen criterion for oscillator : Beta*A=1 \n", - "Feedback Factor for oscillator : 0.02\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.2, page 279" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "#Given data\n", - "L=100 #in uH\n", - "L=L*10**-6 #in H\n", - "f1=500 #in kHz\n", - "f1=f1*10**3 #in Hz\n", - "f2=1500 #in kHz\n", - "f2=f2*10**3 #in Hz\n", - "#Formula : f=1/(2*%pi*sqrt(L*C))\n", - "C1=1/(4*pi**2*f1**2*L) #in F\n", - "C2=1/(4*pi**2*f2**2*L) #in F\n", - "C1*=10**12 #pF\n", - "C2*=10**12 #pF\n", - "print \"Range of capacitor : %0.2f pf to %0.2f pf\" %(C2, C1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Range of capacitor : 112.58 pf to 1013.21 pf\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.3, page 285" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "#Given data\n", - "R=100 #in kOhm\n", - "R=R*10**3 #in Ohm\n", - "C=0.01 #in uF\n", - "C=C*10**-6 #in F\n", - "fo=sqrt(6)/(2*pi*R*C) #in Hz\n", - "print \"Frequency of oscillation is %0.3f Hz\" %fo" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Frequency of oscillation is 389.848 Hz\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.4, page 288" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "from math import sqrt\n", - "#Given data\n", - "assumed = \"Assume alfa=sqrt(6) to find the gain.\"\n", - "alfa=sqrt(6) #unitless\n", - "Beta=1/(1-5*alfa**2) \n", - "criteria = \"Barkhausen critera : A*|Beta|>=1\"\n", - "Beta=-Beta #\n", - "A=1/Beta #unitless\n", - "print assumed,\"\\n\",criteria,\"\\nMinimum Gain of Amplifier must be \",A" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Assume alfa=sqrt(6) to find the gain. \n", - "Barkhausen critera : A*|Beta|>=1 \n", - "Minimum Gain of Amplifier must be 29.0\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.6, page 289" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "from math import pi, sqrt\n", - "#Given data :\n", - "R1=50 #in kohm\n", - "R1=R1*10**3 #in ohm\n", - "C1=0.001 #in uF\n", - "C1=C1*10**-6 #in F\n", - "R2=1 #in kohm\n", - "R2=R2*10**3 #in ohm\n", - "C2=0.01 #in uF\n", - "C2=C2*10**-6 #in F\n", - "#Part (i)\n", - "#Formula : f=1/(2*pi*sqrt(C1*C2*R1*R2))\n", - "f=1/(2*pi*sqrt(C1*C2*R1*R2)) #in Hz\n", - "f/=1000 #kHz\n", - "print \"(i) Frequency of oscillations is %0.3f kHz\" %f\n", - "#Part (ii)\n", - "CurrentGain=1+C2/C1+R1/R2 #unitless\n", - "print \"(ii) Current Gain : \",CurrentGain" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Frequency of oscillations is 7.118 kHz\n", - "(ii) Current Gain : 61.0\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 8.7, page 295" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "from math import sqrt, pi\n", - "#Given data :\n", - "fmin=20 #in Hz\n", - "fmax=20 #in kHz\n", - "Cmin=30 #in pF\n", - "Cmax=300 #in pF\n", - "#Formula : fo=1/(2*pi*R*C))\n", - "R=1/(2*pi*fmin*Cmax*10**-12) # ohm\n", - "R/=10**6 # Mohm\n", - "print \"Required resistance is %0.3f Mohm\" %R" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Required resistance is 26.526 Mohm\n" - ] - } - ], - "prompt_number": 21 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/MohdRizwan/MohdRizwan_version_backup/Chapter8.ipynb b/sample_notebooks/MohdRizwan/MohdRizwan_version_backup/Chapter8.ipynb new file mode 100755 index 00000000..0017f769 --- /dev/null +++ b/sample_notebooks/MohdRizwan/MohdRizwan_version_backup/Chapter8.ipynb @@ -0,0 +1,253 @@ +{ + "metadata": { + "name": "Rijwan", + "signature": "sha256:ccfeb26b31d807a5210cb280c22c39e23c0906566f59b1bedfeb5dfebe856c36" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Ch-8 Oscillators" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.1, page 272 " + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#Given data\n", + "A=50 #unitless\n", + "criteria = \"Barkhausen criterion for oscillator : Beta*A=1\"\n", + "Beta=1/A #unitless\n", + "print criteria,\"\\nFeedback Factor for oscillator : \",Beta" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Barkhausen criterion for oscillator : Beta*A=1 \n", + "Feedback Factor for oscillator : 0.02\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.2, page 279" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "#Given data\n", + "L=100 #in uH\n", + "L=L*10**-6 #in H\n", + "f1=500 #in kHz\n", + "f1=f1*10**3 #in Hz\n", + "f2=1500 #in kHz\n", + "f2=f2*10**3 #in Hz\n", + "#Formula : f=1/(2*%pi*sqrt(L*C))\n", + "C1=1/(4*pi**2*f1**2*L) #in F\n", + "C2=1/(4*pi**2*f2**2*L) #in F\n", + "C1*=10**12 #pF\n", + "C2*=10**12 #pF\n", + "print \"Range of capacitor : %0.2f pf to %0.2f pf\" %(C2, C1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Range of capacitor : 112.58 pf to 1013.21 pf\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.3, page 285" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "#Given data\n", + "R=100 #in kOhm\n", + "R=R*10**3 #in Ohm\n", + "C=0.01 #in uF\n", + "C=C*10**-6 #in F\n", + "fo=sqrt(6)/(2*pi*R*C) #in Hz\n", + "print \"Frequency of oscillation is %0.3f Hz\" %fo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Frequency of oscillation is 389.848 Hz\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.4, page 288" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "from math import sqrt\n", + "#Given data\n", + "assumed = \"Assume alfa=sqrt(6) to find the gain.\"\n", + "alfa=sqrt(6) #unitless\n", + "Beta=1/(1-5*alfa**2) \n", + "criteria = \"Barkhausen critera : A*|Beta|>=1\"\n", + "Beta=-Beta #\n", + "A=1/Beta #unitless\n", + "print assumed,\"\\n\",criteria,\"\\nMinimum Gain of Amplifier must be \",A" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Assume alfa=sqrt(6) to find the gain. \n", + "Barkhausen critera : A*|Beta|>=1 \n", + "Minimum Gain of Amplifier must be 29.0\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.6, page 289" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "from math import pi, sqrt\n", + "#Given data :\n", + "R1=50 #in kohm\n", + "R1=R1*10**3 #in ohm\n", + "C1=0.001 #in uF\n", + "C1=C1*10**-6 #in F\n", + "R2=1 #in kohm\n", + "R2=R2*10**3 #in ohm\n", + "C2=0.01 #in uF\n", + "C2=C2*10**-6 #in F\n", + "#Part (i)\n", + "#Formula : f=1/(2*pi*sqrt(C1*C2*R1*R2))\n", + "f=1/(2*pi*sqrt(C1*C2*R1*R2)) #in Hz\n", + "f/=1000 #kHz\n", + "print \"(i) Frequency of oscillations is %0.3f kHz\" %f\n", + "#Part (ii)\n", + "CurrentGain=1+C2/C1+R1/R2 #unitless\n", + "print \"(ii) Current Gain : \",CurrentGain" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Frequency of oscillations is 7.118 kHz\n", + "(ii) Current Gain : 61.0\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 8.7, page 295" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "from math import sqrt, pi\n", + "#Given data :\n", + "fmin=20 #in Hz\n", + "fmax=20 #in kHz\n", + "Cmin=30 #in pF\n", + "Cmax=300 #in pF\n", + "#Formula : fo=1/(2*pi*R*C))\n", + "R=1/(2*pi*fmin*Cmax*10**-12) # ohm\n", + "R/=10**6 # Mohm\n", + "print \"Required resistance is %0.3f Mohm\" %R" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Required resistance is 26.526 Mohm\n" + ] + } + ], + "prompt_number": 21 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/MukteshChaudhary/MukteshChaudhary_version_backup/ch2.ipynb b/sample_notebooks/MukteshChaudhary/MukteshChaudhary_version_backup/ch2.ipynb new file mode 100755 index 00000000..ebb803c6 --- /dev/null +++ b/sample_notebooks/MukteshChaudhary/MukteshChaudhary_version_backup/ch2.ipynb @@ -0,0 +1,150 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:8575441dfc9f46104394a83a9c4613d36928a495b4284fab191e2ca7cb407033" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2: Introduction to Quantum Mechanics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1, Page 47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "lamda=0.708*10**-8# cm\n", + "h=6.625*10**-34# J*s Plank's constant\n", + "c=3.0*10**10# cm/s\n", + "e=1.6*10**-19# eV\n", + "\n", + "#Calculations&Results\n", + "E=(h*c)/lamda# E=hv=hc/lamda\n", + "print \"The value of E is %.2e J\"%E\n", + "E=E/e\n", + "print \"The value of E is %.2e eV\"%E" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of E is 2.81e-15 J\n", + "The value of E is 1.75e+04 eV\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2,Page 49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "m=9.11*10**-31# kg*m/s\n", + "v=10**5#m/s\n", + "h=6.625*10**-34#js\n", + "\n", + "#Calculations&Results\n", + "p=m*v\n", + "print \"momentum is %.2e\"%p\n", + "lamda=h/p\n", + "print \"de broglie wavelength in meter is %.2e\"%(lamda)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "momentum is 9.11e-26\n", + "de broglie wavelength in meter is 7.27e-09\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3, Page 58" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "a=5*10**-10# a=5A = 5*10**-8cm\n", + "h=1.054*10**-34# J*s Planck's constant \n", + "m=9.11*10**-31# kg*m/s\n", + "e=1.6*10**-19# eV\n", + "\n", + "#Calculations&Results\n", + "print \"The energy levels are:\"\n", + "for n in range(1,4):\n", + " En=((h**2*n**2*math.pi**2)/(2*m*a**2))/e\n", + " print \"For n = %d, E = %.2f eV\"%(n,En)\n", + "\n", + " " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy levels are:\n", + "For n = 1, E = 1.50 eV\n", + "For n = 2, E = 6.02 eV\n", + "For n = 3, E = 13.54 eV\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/MukteshChaudhary/ch2.ipynb b/sample_notebooks/MukteshChaudhary/ch2.ipynb deleted file mode 100755 index ebb803c6..00000000 --- a/sample_notebooks/MukteshChaudhary/ch2.ipynb +++ /dev/null @@ -1,150 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:8575441dfc9f46104394a83a9c4613d36928a495b4284fab191e2ca7cb407033" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2: Introduction to Quantum Mechanics" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1, Page 47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "lamda=0.708*10**-8# cm\n", - "h=6.625*10**-34# J*s Plank's constant\n", - "c=3.0*10**10# cm/s\n", - "e=1.6*10**-19# eV\n", - "\n", - "#Calculations&Results\n", - "E=(h*c)/lamda# E=hv=hc/lamda\n", - "print \"The value of E is %.2e J\"%E\n", - "E=E/e\n", - "print \"The value of E is %.2e eV\"%E" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of E is 2.81e-15 J\n", - "The value of E is 1.75e+04 eV\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2,Page 49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "m=9.11*10**-31# kg*m/s\n", - "v=10**5#m/s\n", - "h=6.625*10**-34#js\n", - "\n", - "#Calculations&Results\n", - "p=m*v\n", - "print \"momentum is %.2e\"%p\n", - "lamda=h/p\n", - "print \"de broglie wavelength in meter is %.2e\"%(lamda)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "momentum is 9.11e-26\n", - "de broglie wavelength in meter is 7.27e-09\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3, Page 58" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "a=5*10**-10# a=5A = 5*10**-8cm\n", - "h=1.054*10**-34# J*s Planck's constant \n", - "m=9.11*10**-31# kg*m/s\n", - "e=1.6*10**-19# eV\n", - "\n", - "#Calculations&Results\n", - "print \"The energy levels are:\"\n", - "for n in range(1,4):\n", - " En=((h**2*n**2*math.pi**2)/(2*m*a**2))/e\n", - " print \"For n = %d, E = %.2f eV\"%(n,En)\n", - "\n", - " " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The energy levels are:\n", - "For n = 1, E = 1.50 eV\n", - "For n = 2, E = 6.02 eV\n", - "For n = 3, E = 13.54 eV\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb b/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb deleted file mode 100755 index e025dd86..00000000 --- a/sample_notebooks/NIKHILESH DAMLE/ANTENNAS_AND_WAVE_PROPAGATION_BY_U.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Radiation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7.1, PAGE NO.-30" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "I_m = 15 #Current in Ampere\n", - "P_rad = 6 #Power radiated in kW\n", - "\n", - "#Calculation\n", - "\n", - "# By formula\n", - "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", - "\n", - "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", - "\n", - "#Result\n", - "\n", - "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The radiation resistance of Antenna is 53.33 kW\n" - ] - } - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.1,PAGE NO.-42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt \n", - "from sympy import Symbol\n", - "\n", - "# Variable Declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = Lm/25 # Length of dipole for Hertian dipole\n", - "H_phi = 5 # Magnetic field strength in uA/m\n", - "theta = pi/2\n", - "r = 2 # Distance in Km\n", - "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", - "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", - "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", - "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", - "\n", - "# Calculation\n", - "\n", - "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", - "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", - "I_rms = I_m/sqrt(2)\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", - "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", - "I_rms1 = I_m1/sqrt(2)\n", - "P_rad1 = (I_rms1**2)*R_rad\n", - "P_rad2 = (I_rms1**2)*R_rad1\n", - "\n", - "# Result\n", - "\n", - "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", - "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", - "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.2,PAGE NO.-43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sin,cos,pi,sqrt\n", - "\n", - "\n", - "\n", - "#variable declaration \n", - "\n", - "\n", - "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", - "theta = pi/2 #observation angle\n", - "r = 500*(10**3) #distance in metrs\n", - "f = 50*(10**6) #frequency in Hertz\n", - "c = 3*(10**8) #speed of light in m/sec\n", - "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", - "\n", - "\n", - "# calculation\n", - "lamda = c/f\n", - "L = lamda/2 #L is the length of half wave dipole\n", - "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", - "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", - "I_rms = I_m/sqrt(2)\n", - "P_avg = (R_rad*(I_m**2))/2\n", - "\n", - "#Result\n", - "\n", - "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", - "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", - "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.3,PAGE NO.-44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 100 #effective hieght in m\n", - "f = 60*(10**3) #frequency in Hertz\n", - "r = 100*(10**3) #Distance in m\n", - "c = 3*(10**8) #Speed of light in m/sec\n", - "P_rad = 100*(10**3) #radiated power\n", - "\n", - "# calculation\n", - "\n", - "lamda = c/f\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "I_rms = sqrt(P_rad/R_rad)\n", - "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", - "\n", - "# Results\n", - "\n", - "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.4,PAGE NO.-45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "l_eff = 113.3 #Effective length in metres\n", - "lamda = 18.8 #Wavelength in metres\n", - "I_rms = 725 #Base current in Ampere\n", - "r = 175 #Distance in metre\n", - "Eta_o = 120*pi\n", - "\n", - "#Calculation\n", - "\n", - "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", - "H = E/Eta_o\n", - "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", - "P_rad = (I_rms**2)*(R_rad)\n", - "\n", - "#Result\n", - "\n", - "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", - "print \"The H field is\",round(H,2),\"uA/m\"\n", - "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.5,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin\n", - "\n", - "# variable declaration\n", - "\n", - "lamda = 10*(10**(-2)) # In cm\n", - "r = 200*(10**(-2)) # In cm\n", - "theta = 90 # In Degrees\n", - "phi = 0 # In Degrees\n", - "IdL = 3*(10**(-4)) # current distribution in Am\n", - "\n", - "#Calculation\n", - "\n", - "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", - "\n", - "#Result\n", - "\n", - "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.6,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi\n", - "\n", - "# variable declaration\n", - "\n", - "dL = lamda/12\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.7,PAGE NO.-46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "I_m = 100 # uniform current in ampere\n", - "Lm = Symbol('Lm') #Taking Lm as lamda\n", - "dL = Lm/16\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", - "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.8,PAGE NO.-47" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# variable declaration\n", - "\n", - "f = 30*(10**6) #Frequency in Hz\n", - "c = 3*(10**8) #speed of light in m/s\n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "\n", - "#Result\n", - "\n", - "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.10,PAGE NO.-48" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi,sin,sqrt \n", - "from sympy import Symbol\n", - "# variable declaration\n", - "\n", - "Lm = Symbol('Lm') # Taking lamda as Lm\n", - "dL = 0.01*Lm # Length of dipole \n", - "theta = 45\n", - "P_rad = 1 # Power radiated in kW\n", - "phi = 90\n", - "r = 1 # Distance in Km\n", - "Eta_o=120*pi\n", - "\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", - "I_m = sqrt(2*P_rad*R_rad)\n", - "\n", - "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", - "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Power density is \",P,\"Watt/m^2\"\n", - "\n", - "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.9.11,PAGE NO.-49" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import pi \n", - "\n", - "# variable declaration\n", - "\n", - "dL = 75 #Length of dipole in m\n", - "f = 800 # Frequency in kHz\n", - "I_rms = 10 #rms Current in Amp\n", - "c = 3*(10**8) #Speed of light in m/s \n", - "\n", - "#Calculation\n", - "\n", - "lamda = c/f\n", - "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", - "\n", - "#Result\n", - "\n", - "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_1.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_10.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_11.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_12.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_2.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_3.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_4.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_5.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_6.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_7.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_8.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb new file mode 100755 index 00000000..e025dd86 --- /dev/null +++ b/sample_notebooks/NIKHILESH DAMLE/NIKHILESH DAMLE_version_backup/ANTENNAS_AND_WAVE_PROPAGATION_BY.A_BAKSHI,_A.V_BAKSHI,_K.A_BAKSHI_9.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:02197244985b7dfa2823dacf9fac72c0a7536b50c383ffa1801ccf3066222ec3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Radiation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7.1, PAGE NO.-30" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "I_m = 15 #Current in Ampere\n", + "P_rad = 6 #Power radiated in kW\n", + "\n", + "#Calculation\n", + "\n", + "# By formula\n", + "I_rms = I_m/math.sqrt(2) #I_rms is r.m.s. current\n", + "\n", + "R_rad = P_rad/(I_rms**2) #R_rad is radiation resistance\n", + "\n", + "#Result\n", + "\n", + "print \"The radiation resistance of Antenna is\",round(R_rad*1000,2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The radiation resistance of Antenna is 53.33 kW\n" + ] + } + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.1,PAGE NO.-42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt \n", + "from sympy import Symbol\n", + "\n", + "# Variable Declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = Lm/25 # Length of dipole for Hertian dipole\n", + "H_phi = 5 # Magnetic field strength in uA/m\n", + "theta = pi/2\n", + "r = 2 # Distance in Km\n", + "dL_1 = Lm/2 # Length of dipole for Half wave dipole \n", + "R_rad = 73 # Radiation resistance for half wave dipole in ohm\n", + "R_rad1 = 36.5 # Radiation resistance for quarter wave monopole in ohm\n", + "dL_2 = Lm/4 # Length of dipole for quarter wave monopole \n", + "\n", + "# Calculation\n", + "\n", + "# By formula : H_phi = I_m*dL*sin(theta)/2*Lm*r\n", + "I_m = (H_phi*2*Lm*r)/(dL*sin(theta))\n", + "I_rms = I_m/sqrt(2)\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*(I_rms**2)\n", + "I_m1 = (H_phi*2*pi*r*sin(theta))/(cos(pi/2*cos(theta)))\n", + "I_rms1 = I_m1/sqrt(2)\n", + "P_rad1 = (I_rms1**2)*R_rad\n", + "P_rad2 = (I_rms1**2)*R_rad1\n", + "\n", + "# Result\n", + "\n", + "print \" The power radiated by hertzian dipole is \",round(P_rad*10**-3,2),\"mW\"\n", + "print \" The power radiated by half wave dipole is \",round(P_rad1*10**-3,2),\"mW\"\n", + "print \" The power radiated by Quarter wave monopole is \",round(P_rad2*10**-3,2),\"mW\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.2,PAGE NO.-43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sin,cos,pi,sqrt\n", + "\n", + "\n", + "\n", + "#variable declaration \n", + "\n", + "\n", + "E_theta = 10*(10**(-6)) #Electric field strength in V/m\n", + "theta = pi/2 #observation angle\n", + "r = 500*(10**3) #distance in metrs\n", + "f = 50*(10**6) #frequency in Hertz\n", + "c = 3*(10**8) #speed of light in m/sec\n", + "R_rad = 73 #for half wave dipole Radiation resistance in ohms\n", + "\n", + "\n", + "# calculation\n", + "lamda = c/f\n", + "L = lamda/2 #L is the length of half wave dipole\n", + "# formula : E=((60*I_m)/r)*((cos(pi/2*cos(theta)))*sin(theta))\n", + "I_m = (E_theta*r*sin(theta))/(60*cos(pi/2*cos(theta)))\n", + "I_rms = I_m/sqrt(2)\n", + "P_avg = (R_rad*(I_m**2))/2\n", + "\n", + "#Result\n", + "\n", + "print \"Length of Dipole is\" ,round(L,2),\"metres\"\n", + "print \"Current fed to Antenna\",round(I_rms*1000,2),\"mA\"\n", + "print \"Average Power\",round(P_avg*1000,2),\"mW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.3,PAGE NO.-44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 100 #effective hieght in m\n", + "f = 60*(10**3) #frequency in Hertz\n", + "r = 100*(10**3) #Distance in m\n", + "c = 3*(10**8) #Speed of light in m/sec\n", + "P_rad = 100*(10**3) #radiated power\n", + "\n", + "# calculation\n", + "\n", + "lamda = c/f\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "I_rms = sqrt(P_rad/R_rad)\n", + "E_rms = (120*pi*l_eff*(I_rms**2))/(lamda*r)\n", + "\n", + "# Results\n", + "\n", + "print \"Strength of Electric field\",round(E_rms,2),\"V/m\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.4,PAGE NO.-45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "l_eff = 113.3 #Effective length in metres\n", + "lamda = 18.8 #Wavelength in metres\n", + "I_rms = 725 #Base current in Ampere\n", + "r = 175 #Distance in metre\n", + "Eta_o = 120*pi\n", + "\n", + "#Calculation\n", + "\n", + "E = (120*pi*l_eff*I_rms)/(lamda*r)\n", + "H = E/Eta_o\n", + "R_rad = 160*(pi**2)*((l_eff/lamda)**2)\n", + "P_rad = (I_rms**2)*(R_rad)\n", + "\n", + "#Result\n", + "\n", + "print \"The electric field at a distance r is \",round(E*0.001,2),\"mV/m\"\n", + "print \"The H field is\",round(H,2),\"uA/m\"\n", + "print \"The power radiated by Antenna is \",round(P_rad*(10**(-9)),2),\"kW\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.5,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin\n", + "\n", + "# variable declaration\n", + "\n", + "lamda = 10*(10**(-2)) # In cm\n", + "r = 200*(10**(-2)) # In cm\n", + "theta = 90 # In Degrees\n", + "phi = 0 # In Degrees\n", + "IdL = 3*(10**(-4)) # current distribution in Am\n", + "\n", + "#Calculation\n", + "\n", + "E_theta = (60*pi*IdL*sin(theta))/(lamda*r)\n", + "\n", + "#Result\n", + "\n", + "print \"The magnitude of component E_theta is \",round(E_theta,2),\"V/m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.6,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi\n", + "\n", + "# variable declaration\n", + "\n", + "dL = lamda/12\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 80*(pi**2)*((dL/lamda)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole antenna is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.7,PAGE NO.-46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "I_m = 100 # uniform current in ampere\n", + "Lm = Symbol('Lm') #Taking Lm as lamda\n", + "dL = Lm/16\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "P_rad = 80*(pi**2)*((dL/Lm)**2)*((I_m/sqrt(2))**2)\n", + "R_rad = 80*(pi**2)*((dL/Lm)**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Radiation resistance of dipole is \",round(R_rad,2),\"ohm\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.8,PAGE NO.-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# variable declaration\n", + "\n", + "f = 30*(10**6) #Frequency in Hz\n", + "c = 3*(10**8) #speed of light in m/s\n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "\n", + "#Result\n", + "\n", + "print \"The Length of Half wave dipole is \",round((lamda/2),2),\"m\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.10,PAGE NO.-48" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi,sin,sqrt \n", + "from sympy import Symbol\n", + "# variable declaration\n", + "\n", + "Lm = Symbol('Lm') # Taking lamda as Lm\n", + "dL = 0.01*Lm # Length of dipole \n", + "theta = 45\n", + "P_rad = 1 # Power radiated in kW\n", + "phi = 90\n", + "r = 1 # Distance in Km\n", + "Eta_o=120*pi\n", + "\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "R_rad = 20*(pi**2)*((dL/Lm)**2)\n", + "I_m = sqrt(2*P_rad*R_rad)\n", + "\n", + "# formula : P = (Eta_o/2)*(((Omega*I_m*dL*sin(theta))/(4*pi*r*v))**2)\n", + "P = (Eta_o/2)*(((I_m*dL*sin(theta))/(4*pi*(r**2)))**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Power density is \",P,\"Watt/m^2\"\n", + "\n", + "# Note : The Solving in the book is wrong they put 0.1 instead of 0.1*lamda \n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.9.11,PAGE NO.-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import pi \n", + "\n", + "# variable declaration\n", + "\n", + "dL = 75 #Length of dipole in m\n", + "f = 800 # Frequency in kHz\n", + "I_rms = 10 #rms Current in Amp\n", + "c = 3*(10**8) #Speed of light in m/s \n", + "\n", + "#Calculation\n", + "\n", + "lamda = c/f\n", + "P_rad = 80*(pi**2)*((dL/lamda)**2)*(I_rms**2)\n", + "\n", + "#Result\n", + "\n", + "print \"The Total Power radiated by Antenna is \",round(P_rad*1000,2),\"kW\"\n", + "\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NagadeviPriya/NagadeviPriya_version_backup/Sample.ipynb b/sample_notebooks/NagadeviPriya/NagadeviPriya_version_backup/Sample.ipynb new file mode 100755 index 00000000..1dd45ca5 --- /dev/null +++ b/sample_notebooks/NagadeviPriya/NagadeviPriya_version_backup/Sample.ipynb @@ -0,0 +1,67 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:f1e1a22845431a7c624f15fdfe1d12cb897973438c34ee8b3af7b1acede6209e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 24: Laws of Motion" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 24.11, Page no.490" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Variable declaration\n", + "m=50 #mass in kg\n", + "a=1.2 #acceleration in m/s**2\n", + "g=9.8 #gravity in m/s**2\n", + "\n", + "#Calculation\n", + "F=m*(g+a)\n", + "\n", + "#Result\n", + "print\"F=\",int(F),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "F= 550 N\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NagadeviPriya/Sample_Notebook.ipynb b/sample_notebooks/NagadeviPriya/Sample_Notebook.ipynb deleted file mode 100755 index 1dd45ca5..00000000 --- a/sample_notebooks/NagadeviPriya/Sample_Notebook.ipynb +++ /dev/null @@ -1,67 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:f1e1a22845431a7c624f15fdfe1d12cb897973438c34ee8b3af7b1acede6209e" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 24: Laws of Motion" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 24.11, Page no.490" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Variable declaration\n", - "m=50 #mass in kg\n", - "a=1.2 #acceleration in m/s**2\n", - "g=9.8 #gravity in m/s**2\n", - "\n", - "#Calculation\n", - "F=m*(g+a)\n", - "\n", - "#Result\n", - "print\"F=\",int(F),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "F= 550 N\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Namratha Reddy/chapter3.ipynb b/sample_notebooks/Namratha Reddy/chapter3.ipynb index 41fd06af..8580f761 100755 --- a/sample_notebooks/Namratha Reddy/chapter3.ipynb +++ b/sample_notebooks/Namratha Reddy/chapter3.ipynb @@ -11,7 +11,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# #Example 3.1:Page number-158\n" + "# Example 3.1:Page number-158\n" ] }, { @@ -58,7 +58,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# #Example 3.2:Page number-158" + "# Example 3.2:Page number-158" ] }, { diff --git a/sample_notebooks/Namratha Reddy/chapter3_(1).ipynb b/sample_notebooks/Namratha Reddy/chapter3_(1).ipynb deleted file mode 100755 index 8580f761..00000000 --- a/sample_notebooks/Namratha Reddy/chapter3_(1).ipynb +++ /dev/null @@ -1,907 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# #Chapter 3:Magnetic Circuits" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.1:Page number-158\n" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The reluctance of steel ring is= 1250000.0 AT/Wb\n", - "The magnetomotive force is= 625.0 AT\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "pi=3.14\n", - "l=pi*0.2 #l=mean length of the ring=pi*mean diameter of the ring\n", - "A=400*10**-6 #A=cross sectional area of ring\n", - "u1=1000 #u1=relative permeability of steel\n", - "u2=4*pi*10**-7 #relative permeability of air\n", - "\n", - "R=l/(A*u1*u2) #reluctance of steel ring\n", - "\n", - "print \"The reluctance of steel ring is=\",round(R,0),\"AT/Wb\"\n", - "\n", - "#case b\n", - "\n", - "flux=500*10**-6\n", - "f=flux*R\n", - "\n", - "print \"The magnetomotive force is=\",round(f,0),\"AT\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.2:Page number-158" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The flux density is= 0.625 Wb/m**2\n", - "The magnetomotive force is= 375.0 AT\n", - "The magnetic field strength is= 750.0 AT/m\n", - "The relative permeability is= 663.0\n", - "The flux density is= 1.5 Wb/m**2\n", - "The magnetomotive force is= 1250.0 AT\n", - "Magnetic field strength= 2500.0 AT/m\n", - "The relative permeability is= 477.7\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "l=0.5\n", - "A=4*10**-4\n", - "N=250\n", - "I=1.5\n", - "flux=0.25*10**-3\n", - "fluxdensity=flux/A \n", - "\n", - "f=N*I #magnetomotive force\n", - "\n", - "H=(N*I)/l #magnetic field strength\n", - "\n", - "pi=3.14\n", - "u1=4*pi*10**-7\n", - "u2=fluxdensity/(u1*H)\n", - "\n", - "print \"The flux density is=\",round(fluxdensity,3),\"Wb/m**2\"\n", - "print \"The magnetomotive force is=\",round(f,0),\"AT\"\n", - "print \"The magnetic field strength is=\",round(H,0),\"AT/m\"\n", - "print \"The relative permeability is=\",round(u2,0)\n", - "\n", - "#case b\n", - "\n", - "#given\n", - "I=5\n", - "flux=0.6*10**-3\n", - "A=4*10**-4\n", - "N=250\n", - "l=0.5\n", - "\n", - "fluxdensity=flux/A\n", - "\n", - "print \"The flux density is=\",round(fluxdensity,1),\"Wb/m**2\"\n", - "\n", - "f=N*I #magnetomotive force\n", - "\n", - "print \"The magnetomotive force is=\",round(f,0),\"AT\"\n", - "\n", - "H=(N*I)/l #magnetic field stength\n", - "\n", - "print \"Magnetic field strength=\",round(H,0),\"AT/m\"\n", - "pi=3.14\n", - "u1=4*pi*10**-7\n", - "u2=fluxdensity/(u1*H)\n", - "\n", - "print \"The relative permeability is=\",round(u2,1)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.3: Page number-159" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Magnetomotive force= 1250.0 AT\n", - "The reluctance of air gap is= 162154.449 AT/Wb\n", - "The flux is= 0.006475308 Wb\n", - "The flux density is= 13.188 Wb/m**2\n", - "The reluctance of steel string is= 69494.763801 AT/Wb\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "pi=3.14\n", - "ls=0.627 #mean length of steel string\n", - "\n", - "la=0.0001 #length of air gap\n", - "\n", - "A=4.91*10**-4 #cross sectional area of magnetic circuit\n", - "\n", - "f=N*I #magnetomotive force\n", - "print \"Magnetomotive force=\",round(f,0),\"AT\"\n", - "\n", - "fa=1050 #fa=mmf of air gap=1050AT\n", - "\n", - "fs=450 #fs=mmf of steel ring=450\n", - "\n", - "#case b\n", - "\n", - "u1=4*pi*10**-7\n", - "ra=la/(u1*A) #reluctance of air gap\n", - "\n", - "print \"The reluctance of air gap is=\",round(ra,3),\"AT/Wb\"\n", - "\n", - "flux=fa/ra\n", - "\n", - "print \"The flux is= \",round(flux,20),\"Wb\"\n", - "\n", - "\n", - "#case c\n", - "\n", - "fluxdensity=flux/A\n", - "\n", - "print \"The flux density is=\",round(fluxdensity,5),\"Wb/m**2\"\n", - "\n", - "#case d\n", - "\n", - "rs=fs/flux #reluctance of steel string\n", - "\n", - "print \"The reluctance of steel string is=\",round(rs,6),\"AT/Wb\"\n", - "\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.4: Page number-160" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The air gap= 955414.01274 AT/m\n", - "The magnetomotive force is= 5.0 AT\n", - "hs= 1061.57 AT/m\n", - "The magnetomotive force for air gap is= 318.47 AT\n", - "Total mmf= 323.47 AT\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "la=2*10**-3 #length of the air gap\n", - "ls=0.3 #lentgh of the cast steel core\n", - "B=1.2\n", - "\n", - "ha=B/u1\n", - "\n", - "print \"The air gap=\",round(ha,5),\"AT/m\"\n", - "\n", - "fa=H*la #magnetomotive ofrce for air gap\n", - "\n", - "print \"The magnetomotive force is=\",round(fa,0),\"AT\"\n", - "\n", - "u2=900\n", - "hs=B/(u1*u2)\n", - "\n", - "print \"hs=\",round(hs,2),\"AT/m\"\n", - "\n", - "fs=hs*ls #magnetomotive force for air gap\n", - "\n", - "print \"The magnetomotive force for air gap is=\",round(fs,2),\"AT\"\n", - "\n", - "totmmf=fa+fs\n", - "\n", - "print \"Total mmf=\",round(totmmf,2),\"AT\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.5-Page number-161 " - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "flux density is= 2.15844 mWb/m**2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "f=200 #total mmf\n", - "#ra=2*10**-3/(u1*a) #reluctance of air gap\n", - "#ri=10**-3/(u1*a) #reluctance of iron core\n", - "#r=3*10**-3/(u1*a) #reluctance of magnetic circuit\n", - "\n", - "#flux=f/r\n", - "\n", - "a=3*10**-3\n", - "fluxdensity=flux/a\n", - "\n", - "print \"flux density is=\",round(fluxdensity,5),\"mWb/m**2\"\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.6-Page number-161" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The relucatance of air gap is= 497611.464968 AT/wb\n", - "The flux density in central limb is= 0.1125 Wb/m**2\n", - "The mmf drop in central limb is= 300.0 AT\n", - "fabh= 500.0 AT\n", - "The total mmf required is= 1695.0 AT\n", - "The required current is= 2.825 A\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "fluxa=0.00018 #flux in the air gap\n", - "la=0.1*10**-2 #length of the air gap\n", - "ac=16*10**-4 #area of cross section\n", - "u1=4*3.14*10**-7\n", - "\n", - "ra=la/(u1*ac) #reluctance of the air gap\n", - "\n", - "print \"The relucatance of air gap is=\",round(ra,10),\"AT/wb\"\n", - "\n", - "#fa=fluxa*ra #mmf required to set up flux in air gap\n", - "\n", - "#print \"The mmf required to set up flux in air gap is=\",round(fa,10),\"AT\" --> This rounds to 895\n", - "\n", - "fa=895\n", - "\n", - "B=fluxa/ac #flux density in central limb\n", - "\n", - "print \"The flux density in central limb is=\",round(B,10),\"Wb/m**2\"\n", - "\n", - "#given from B-H curve, when B=1.125 the field density required is hc=1000 AT/m\n", - "#given\n", - "\n", - "hc=1000 #as above\n", - "\n", - "lc=30*10**-2 #length of central limb\n", - "\n", - "fc=hc*lc #mmf drop in central limb\n", - "\n", - "print \"The mmf drop in central limb is=\",round(fc,0),\"AT\"\n", - "\n", - "#from the diagram the flux density in parallel path fabh is flux(a)/2 =0.5625 Wb/m**2 and field intensity H=625 AT/m\n", - "\n", - "#given\n", - "\n", - "lp=80*10**-2 #length of parallel path\n", - "\n", - "H=625 #from above\n", - "\n", - "fabh=H*lp\n", - "\n", - "print \"fabh=\",round(fabh,0),\"AT\"\n", - "\n", - "F=fa+fc+fabh\n", - "\n", - "print \"The total mmf required is=\",round(F,0),\"AT\"\n", - "\n", - "#given\n", - "N=600 #number of turns\n", - "I=F/N\n", - "\n", - "print \"The required current is=\",round(I,5),\"A\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.7:Page number-163" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "B= 0.7 Wb/m**2\n", - "mmf= 111.4 AT\n", - "totmmf= 223.85 AT\n", - "h2= 298.46667 AT\n", - "flux2= 0.0014 Wb\n", - "total mmf in fabc= 2250.0 Wb/m**2\n", - "totmmfm= 2473.85 AT\n", - "The total current required to set up flux in air gap is= 4.9477 A\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "fluxa=1.4*10**-3\n", - "area=0.002\n", - "\n", - "B=fluxa/area #flux density in air gap \n", - "\n", - "print \"B=\",round(B,3),\"Wb/m**2\"\n", - "\n", - "#u1=4*3.14*10**-7\n", - "#ha=B/u1 in AT/m #magnetic field in air gap\n", - "ha=55.7\n", - "\n", - "la=2 #length of air gap in m\n", - "mmf=ha*la #mmf of air gap\n", - "print \"mmf=\",round(mmf,3),\"AT\"\n", - "\n", - "#since the flux density of central limb is 0.7 the corresponding field srength is h1=250AT/m\n", - "h1=250\n", - "mmfl=112.45 #mmf for magnetic central limb-->mmf=250*(450-0.2)*10**-3\n", - "\n", - "totmmf=mmf+mmfl\n", - "\n", - "print \"totmmf=\",round(totmmf,5),\"AT\"\n", - "\n", - "#mean length of core CGHF=0.75m\n", - "\n", - "ml=0.75 #as above\n", - "\n", - "#since the central limb and magnetic core are in parallel they have same mmf that is 223.86AT\n", - "\n", - "\n", - "h2=totmmf/ml #magnetic intensity in CGHF\n", - "\n", - "print \"h2=\",round(h2,5),\"AT\"\n", - "\n", - "flux2=B*area \n", - "print \"flux2=\",round(flux2,5),\"Wb\"\n", - "\n", - "totflux=fluxa+flux2 #Wb\n", - "Bfabc=totflux/area #flux density in magnetic core fabc in Wb/m**2\n", - "\n", - "H=3000 #AT/m\n", - "totmmffabc=H*ml #total mmf in fabc in AT\n", - "print \"total mmf in fabc=\",round(totmmffabc,5),\"Wb/m**2\"\n", - "\n", - "totmmfm=totmmffabc+totmmf #total mmf in magnetic core in AT\n", - "\n", - "print \"totmmfm=\",round(totmmfm,5),\"AT\"\n", - "\n", - "N=500\n", - "I=totmmfm/N #The required current to set up flux in air gap\n", - "\n", - "print \"The total current required to set up flux in air gap is=\",round(I,5),\"A\"\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 3.8:Page number-171" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "l1= 0.004 mH\n", - "m12= 0.003 mH\n", - "l2= 0.006 mH\n", - "m21= 0.003 mH\n", - "Work done= 7.7 J\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "r1=3.98*10**6 #reluctance of air gap in AT/Wb and the value is same for r2\n", - "r3=5.97*10**6 #reluctance of air gap in AT/Wb\n", - "\n", - "#assume that current of 1A flows through 150 turns coil,for assumed directions of fluxes application of mesh current leads to matrix equations that can be simplified to:\n", - "#[flux1 flux2]=[2.36 1.41]*10**-5 Wb\n", - "\n", - "#The self inductance and mutual inductance are obtained as follows:\n", - "\n", - "n1=150 #number of turns\n", - "i1=1 #A\n", - "flux1=2.36*10**-5 #Wb\n", - "l1=(n1*flux1)/i1 #self inductance\n", - "\n", - "print \"l1=\",round(l1,3),\"mH\"\n", - "\n", - "n2=200 #number of turns\n", - "flux2=1.41*10**-5\n", - "m12=(n2*flux2)/i1 #mutual inductance\n", - "\n", - "print \"m12=\",round(m12,3),\"mH\"\n", - "\n", - "#assume that 1A of current flows through 200 turns coil\n", - "#The self inductance of the coil is determined as above using the matrix and the result is as follows\n", - "#[flux1 flux2]=[1.89 3.14]*10**-5 Wb\n", - "#Hence self and mutual inductance are computed as follows\n", - "\n", - "n2=200 #number of turns\n", - "flux2=3.14*10**-5 #Wb\n", - "i2=1 #A\n", - "l2=(n2*flux2)/i2 #self inductance\n", - "\n", - "print \"l2=\",round(l2,3),\"mH\"\n", - "\n", - "flux1=1.89*10**-5\n", - "m21=(n1*flux1)/i2 #mutual inductance\n", - "print \"m21=\",round(m21,3),\"mH\"\n", - "\n", - "#case b\n", - "#When the air gap l3 is closed the reluctance of the limb is zero since the permeability of the magnetic material is infinity.Thus,the limb behaves like short circuit and the entire flux passes through it.Thus,the flux linking 200 turns coil is zero and mutual inductance is zero\n", - "\n", - "#case 3\n", - "\n", - "W=((3.5)/2)+((6.3)/2)+2.8 #work equation in joules\n", - "print \"Work done=\",round(W,5),\"J\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.9:Page number-174" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "i= 7.85 A\n", - "l= 0.20382 H\n", - "rair= 3184713.3758 AT/Wb\n", - "fair= 6369.42675 AT\n", - "total mmf= 12602.60675 AT\n", - "L= 0.10157 H\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "\n", - "B=0.8 #Wb/m**2\n", - "A=25*10**-4 #m**2\n", - "flux=20*10**-4 #Wb\n", - "l=3.14*40*10**-2 #m\n", - "f=2000*3.14 #AT\n", - "n=800 #number of turns\n", - "\n", - "#case a\n", - "i=f/n #A exciting current\n", - "\n", - "print \"i=\",round(i,3),\"A\"\n", - "\n", - "l=(n*flux)/i #self inductance in H\n", - "\n", - "print \"l=\",round(l,5),\"H\"\n", - "\n", - "#case b\n", - "\n", - "fluxa=20*10**-4 #Wb\n", - "\n", - "gap=1*10**-2\n", - "u1=4*3.14*10**-7\n", - "rair=gap/(u1*A) #reluctance of air in AT/Wb\n", - "\n", - "print \"rair=\",round(rair,5),\"AT/Wb\"\n", - "\n", - "fair=rair*flux #mmf for air gap in AT\n", - "\n", - "print \"fair=\",round(fair,5),\"AT\"\n", - "\n", - "fcore=6233.18 #AT--> 5000*((0.4*3.14)-0.01)=6233.18\n", - "\n", - "totmmf=fcore+fair\n", - "\n", - "print \"total mmf=\",round(totmmf,5),\"AT\"\n", - "\n", - "I=totmmf/n #A exciting current\n", - "\n", - "#self inductance\n", - "L=(n*flux)/I\n", - "print \"L=\",round(L,5),\"H\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.10:Page number-175" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "lx= 0.01 H\n", - "m= 0.015 H\n", - "The induced emf in coil Y= 30.0 V\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "n=2000 #number of turns\n", - "flux=0.05*10**-3 #Wb\n", - "i=10 #A\n", - "\n", - "lx=(n*flux)/i #self inductance in X\n", - "\n", - "print \"lx=\",round(lx,5),\"H\"\n", - "\n", - "#since coils are identical self inductance in Y=self inductance in x\n", - "\n", - "fluxlinkingX=0.75*0.05*10**-3 #Wb flux linking due to current in coil X\n", - "fluxlinkingY=2000*0.05*0.75*10**-3 #Wb flux linkages in coil Y\n", - "\n", - "m=fluxlinkingY/5 #mutual inductance\n", - "\n", - "print \"m=\",round(m,5),\"H\"\n", - "\n", - "#The rate of change in current di/dt=2000A/sec --> di/dt=(10-(-10))/0.01\n", - "\n", - "rate=2000\n", - "ey=m*rate\n", - "\n", - "print \"The induced emf in coil Y=\",round(ey,0),\"V\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.11:Page number-175" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "k=0.72168\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "#when currents are in same direction the total induction is:\n", - "#lt=l1+l2+2m\n", - "#when currents are in opposite direction the total emf is:\n", - "#lt=l1+l2-2m\n", - "#According to this problem\n", - "#l1+l2+2m=1.2\n", - "#l1+l2-2m=0.2\n", - "#Solving the above equations we get l1=0.4H M=0.25H\n", - "#on substituting we get l2=0.3H\n", - "#k=m/squareroot(l1*l2)\n", - "print \"k=0.72168\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.12:Page number-176" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "flux 0.0001 Wb\n", - "i 0.3125 A\n", - "l= 0.08 H\n", - "w= 0.00391 J\n", - "796.178343949\n", - "exciting current= 6.3 A\n", - "l= 0.00397 H\n", - "e= 0.07881 J\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "#case a\n", - "B=1 #Wb/m**2\n", - "A=10**-4 #cm**2\n", - "per=800 #permeability\n", - "n=250 #number of turns\n", - "\n", - "flux=B*A\n", - "\n", - "print \"flux\",round(flux,5),\"Wb\"\n", - "\n", - "r=781250 #AT/Wb calculated using formula for reluctance\n", - "\n", - "mmf=flux*r #AT\n", - "\n", - "i=mmf/n #exciting current required in A\n", - "\n", - "print \"i\",round(i,5),\"A\"\n", - "\n", - "l=(n*flux)/i #self inductance of the coil\n", - "\n", - "print \"l=\",round(l,5),\"H\"\n", - "\n", - "w=(l*i*i)/2 #energy stored\n", - "\n", - "print \"w=\",round(w,5),\"J\"\n", - "\n", - "#case b\n", - "\n", - "airgap=1*10**-3 #air gap is assumed \n", - "rair=airgap/(u1*A) #reluctance of air gap in AT/Wb\n", - "mmfa=flux*rair #mmf of air in AT\n", - "print mmfa\n", - "#rcore=((2.5*3.14)-0.1)/(32*3.14*10**-6) #reluctance of core \n", - "#mmfc=flux*rcore\n", - "mmfc=780 #AT\n", - "F=mmfc+mmfa\n", - "\n", - "I=F/n #A\n", - "\n", - "print \"exciting current=\",round(I,2),\"A\"\n", - "\n", - "n=250 #number of turns\n", - "L=(n*flux)/I #self inductanc eof coil with air gap \n", - "\n", - "print \"l=\",round(L,5),\"H\"\n", - "\n", - "e=(L*I*I)/2 #energy stored in coil\n", - "\n", - "print \"e=\",round(e,5),\"J\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 3.13:Page number:178" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "force= 39808.9172 N\n", - "W= 796.17834 J\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#given\n", - "A=10**-1 #area\n", - "flux=0.1 #Wb\n", - "\n", - "#case a\n", - "\n", - "B=flux/A #flux density Wb/m**2\n", - "\n", - "u1=4*3.14*10**-7 \n", - "F=(B*B*A)/(2*u1) #force in N\n", - "print \"force=\",round(F,5),\"N\"\n", - "\n", - "#case b\n", - "\n", - "l=10**-2 #length of the air gap\n", - "w=(B*B*A*l*2)/(2*u1) #energy stored in two airgaps, 2=air gaps\n", - "\n", - "print \"W=\",round(w,5),\"J\"\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/NarasimhaMamidala/Chapter_4_BJT_Fundamentals.ipynb b/sample_notebooks/NarasimhaMamidala/Chapter_4_BJT_Fundamentals.ipynb deleted file mode 100755 index c7db6367..00000000 --- a/sample_notebooks/NarasimhaMamidala/Chapter_4_BJT_Fundamentals.ipynb +++ /dev/null @@ -1,544 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4 BJT Fundamentals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−1 in page 208" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)The value of the Base Current is 3.85e-04 A\n", - "\n", - "(b)The value of the Collector Current is 3.615e-03 A \n", - "\n" - ] - } - ], - "source": [ - "#Calculate Base and Collector Currents\n", - "# Given Data\n", - "alpha=0.90; # Current Gain in CB mode\n", - "Ico=15*10**-6; # Reverse saturation Current in micro−A\n", - "Ie=4*10**-3; # Emitter Current in mA\n", - "# Calculations\n", - "Ic=Ico+(alpha*Ie);\n", - "Ib=Ie-Ic;\n", - "print \"(a)The value of the Base Current is %0.2e A\\n\" %Ib;\n", - "print \"(b)The value of the Collector Current is %0 .3e A \\n\" %Ic" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−2 in page 209" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)The Current gain alpha for BJT is 0.989 \n", - "\n", - "(b)The value of the base Current is 4.44e-05 A\n", - "\n", - "(c)The value of the Emitter Current is 4.04e-03 A \n", - "\n" - ] - } - ], - "source": [ - "#Calculate alpha using beta\n", - "# Given Data\n", - "\n", - "beta_bjt=90.; # beta gain for the BJT\n", - "Ic=4*10**-3; # Collector Current in mA\n", - "# Calculations\n", - "alpha=beta_bjt/(1.+beta_bjt);\n", - "Ib=Ic/beta_bjt;\n", - "Ie=Ic+Ib;\n", - "print \"(a)The Current gain alpha for BJT is %0.3f \\n\"%alpha\n", - "print \"(b)The value of the base Current is %0.2e A\\n\"%Ib\n", - "print \"(c)The value of the Emitter Current is %0.2e A \\n\"%Ie" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−3 in page 20" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)The value of Current gain beta for BJT is 9 \n", - "\n", - "(b)The value of the Collector Current is 4.65e-03 A \n", - "\n" - ] - } - ], - "source": [ - "#Collector Current in C E mode\n", - "# Given Data\n", - "alpha=0.90; # Current Gain of BJT\n", - "Ico=15*10**-6; # Reverse Saturation Current of BJT in micro−A\n", - "Ib=0.5*10**-3; # Base Current in C−E mode in mA\n", - "# Calculations\n", - "beta_bjt=alpha/(1-alpha);\n", - "Ic=(beta_bjt*Ib)+(beta_bjt+1)*Ico;\n", - "print \"(a)The value of Current gain beta for BJT is %0.0f \\n\"%beta_bjt\n", - "print \"(b)The value of the Collector Current is %0.2e A \\n\"%Ic" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−4 in page 20" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Current gain beta for the Device is 250 \n", - "\n" - ] - } - ], - "source": [ - "#Calculate beta for the BJT\n", - "Ib=20*10**-6; # Base current in micro−A\n", - "Ic=5*10**-3; # Collector Current in mA\n", - "# Calculations\n", - "beta_bjt=Ic/Ib;\n", - "print \"The Current gain beta for the Device is %0.0f \\n\"%beta_bjt;\n", - "# The Current Gain beta for the Device is 250" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−5 in page 209" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)The value of the Emitter Current is 5.05e-03A \n", - "\n", - "(b)The value of beta gain of the BJT is 100 \n", - "\n", - "(c)The value of alpha gain of the BJT is 0.990 \n", - "\n" - ] - } - ], - "source": [ - "#To Compute Alpha Beta and Emitter Current\n", - "# Given Data\n", - "Ib=50*10**-6; # Base Current in mu−A\n", - "Ic=5*10**-3; # Collector Current in mA\n", - "# Calculations\n", - "Ie=Ic+Ib;\n", - "beta_bjt=Ic/Ib;\n", - "alpha=Ic/Ie;\n", - "print \"(a)The value of the Emitter Current is %0.2eA \\n\"%Ie\n", - "print \"(b)The value of beta gain of the BJT is %0.0f \\n\"%beta_bjt\n", - "print \"(c)The value of alpha gain of the BJT is %0.3f \\n\"%alpha" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−6 in page 210" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of inverse beta of the BJT is 1 \n", - "\n", - "The value of inverse alpha of the BJT is 2 \n", - "\n" - ] - } - ], - "source": [ - "#Calculate alpha reverse and beta reverse\n", - "# Given Data\n", - "Ie=10.*10**-3; # Emitter Current in mA\n", - "Ib=5*10**-3; # Base Current in mu−A\n", - "# Calculations\n", - "Ic=Ie-Ib;\n", - "beta_reverse=Ib/Ic;\n", - "alpha_reverse=Ie/Ic;\n", - "print \"The value of inverse beta of the BJT is %0.0f \\n\"%beta_reverse\n", - "print \"The value of inverse alpha of the BJT is %0.0f \\n\"%alpha_reverse" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−7 in page 210" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Circuit 1:\n", - "(a)Emitter Current=9.30e-04 A\n", - "(b)Base Current=9.21e-06 A\n", - "(c)Collector Voltage=0.792 V\n", - "\n", - "\n", - "Circuit 2:\n", - "(a)Emitter Current=1.86e-03 A\n", - "(b) Collector Current=1.842e-03 A\n", - "(c)Collector Voltage=-5.700 V\n", - "\n" - ] - } - ], - "source": [ - "# Calculate Labeled Currents and Voltages\n", - "# Given Data\n", - "beta_bjt=100.; # beta gain of BJT\n", - "Vbe=0.7; # Base−Emitter voltage of BJT in V\n", - "#Calculation\n", - "Vcc1=10.;\n", - "Vee1=-10.;\n", - "Ve1=-0.7;\n", - "R1=10*10**3;\n", - "Ie1=(Vcc1-Vbe)/R1;\n", - "Ib1=Ie1/(beta_bjt+1);\n", - "Vc1=Vcc1-R1*(Ie1-Ib1);\n", - "Vcc2=10.;\n", - "Vee2=-15.;\n", - "Ve2=-0.7;\n", - "R2 =5*10**3;\n", - "Ie2=(Vcc2-Vbe)/R2;\n", - "Ic2=(beta_bjt/(beta_bjt+1.))*Ie2;\n", - "Vc2=Vee2+R2*(Ie2);\n", - "print \"Circuit 1:\\n(a)Emitter Current=%0.2e A\\n(b)Base Current=%0.2e A\\n(c)Collector Voltage=%0.3f V\\n\\n\"%(Ie1,Ib1,Vc1);\n", - "print \"Circuit 2:\\n(a)Emitter Current=%0.2e A\\n(b) Collector Current=%0.3e A\\n(c)Collector Voltage=%0.3f V\\n\"%(Ie2,Ic2,Vc2);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−8 in page 211" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Circuit 1:\n", - "(a)Base Voltage = 0.0 V\n", - "(b)Emitter Voltage = -0.7 V\n", - "\n", - "Circuit 2:\n", - "(a)Emitter Voltage = 0.7 V\n", - "(b) Collector Voltage = -5.7 V\n", - "\n" - ] - } - ], - "source": [ - "#Calculate labeled Voltages\n", - "# Given Data\n", - "Vbe=0.7; # Base−Emitter voltage of BJT in V\n", - "Vcc2=10; # DC voltage across Collector in V\n", - "Vee2=-15; # DC voltage across Emitter in V\n", - "Rc2=5*10**3; # Collector Resistance in K−ohms\n", - "# Beta Current Gain of BJT is Infinity\n", - "# Calculations\n", - "Vb1=0;\n", - "Ve1=-0.7;\n", - "Ve2=0.7;\n", - "Vc2=Vee2+Rc2*((Vcc2-Vbe)/Rc2);\n", - "print \"Circuit 1:\\n(a)Base Voltage = %0.1f V\\n(b)Emitter Voltage = %0.1f V\\n\"%(Vb1,Ve1);\n", - "print \"Circuit 2:\\n(a)Emitter Voltage = %0.1f V\\n(b) Collector Voltage = %0.1f V\\n\"%(Ve2,Vc2);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−9 in page 211" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Circuit Parameters:\n", - "(a)Base Voltage = 0.300V\n", - "(b)Base Current = 1.500e-05 A\n", - "(c)Emitter Current= 8.000e-04 A\n", - "(d)Collector Current = 7.850e-04 A\n", - "(e) Collector Voltage = -1.075 V\n", - "(f) beta gain = 52.333\n", - "(g)alpha gain = 0.981\n", - "\n" - ] - } - ], - "source": [ - "#Calculating BJT parameters assuming Vbe\n", - "# Given Data\n", - "Ve=1.; # Emitter Voltage of BJT in V\n", - "Vbe=0.7; # Base−Emitter Voltage of BJT in V\n", - "Rb=20*10**3; # Base Resistance of Circuit in K−ohms\n", - "Rc=5*10**3; # Collector Resistance of Circuit in K−ohms\n", - "Re=5*10**3; # Emitter Resistance of Circuit in K−ohms\n", - "Vcc=5.; # DC voltage across Collector in V\n", - "Vee=-5; # DC voltage across Emitter in V\n", - "# Calculations\n", - "Vb=Ve-Vbe;\n", - "Ib=Vb/Rb;\n", - "Ie=(Vcc -1)/Re;\n", - "Ic=Ie-Ib;\n", - "Vc=(Rc*Ic)-Vcc;\n", - "beta_bjt=Ic/Ib;\n", - "alpha=Ic/Ie;\n", - "print \"Circuit Parameters:\\n(a)Base Voltage = %0.3fV\\n(b)Base Current = %0.3e A\\n(c)Emitter Current= %0.3e A\\n(d)Collector Current = %0.3e A\\n(e) Collector Voltage = %0.3f V\\n(f) beta gain = %0.3f\\n(g)alpha gain = %0.3f\\n\"%(Vb,Ib,Ie,Ic,Vc, beta_bjt ,alpha);" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−10 in page 211" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)Change in Emitter voltage is +0.40 V\n", - "\n", - "(b)Change in Collector Voltage is 0.00 V\n", - "\n" - ] - } - ], - "source": [ - "# Measurement of Circuit Voltage changes\n", - "# Given Data\n", - "Vb=-5; # Base Voltage of BJT in V\n", - "Rc=1*10**3; # Collector Resistance in K−ohms\n", - "Ie=2*10**-3; # Emitter Current of BJT in mA\n", - "delB=+0.4; # Change in Base Voltage\n", - "# Calculations\n", - "delE =+0.4;\n", - "delC=0;\n", - "print \"(a)Change in Emitter voltage is +%0.2f V\\n\"%delE\n", - "print \"(b)Change in Collector Voltage is %0.2f V\\n\"%delC" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4−11 in page 212" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Assume active mode for circuit 1\n", - "(a)Ve = 1.30 V\n", - "(b)Ic = 0.00e+00 A\n", - "(c)Ve = 3.03 V\n", - "\n", - "Thus the circuit operates in an active mode\n", - "\n", - "\n", - "For circuit 2,assume active mode\n", - "\n", - "(a)Ve = 1.7 V\n", - "(b)Ie = 4.30e-04 A\n", - "(c)Vc = 4.30 V\n", - "\n", - "This circuit operates in a saturated mode\n", - "\n", - "\n", - "For circuit 3,assume active mode\n", - "\n", - "(a)Ve = -4.3 V\n", - "(b)Ie = 6.9000e-05 A\n", - "(c)Ic = 0.000e+00 A\n", - "(d)Vc = -40.2 V\n", - "\n", - "The circuit operates in an active mode\n", - "\n", - "\n", - "For circuit 4,assume active mode\n", - "\n", - "(a)Ie = 1.86e-03 A\n", - "(b)Vc = -10.00 V\n", - "\n", - "The circuit operates in an active mode\n" - ] - } - ], - "source": [ - "# Determine mode of operation of BJT\n", - "# Given Data\n", - "Vbe=0.7; # Base−Emitter Voltage in V\n", - "beta_bjt=100; # beta gain of BJ\n", - "# Calculation\n", - "print \"Assume active mode for circuit 1\"\n", - "Vb1=2;\n", - "Ve_1=Vb1-Vbe;\n", - "Ie1 =1*10** -3;\n", - "Ic1=Ie1*(beta_bjt/(1+beta_bjt));\n", - "Ve1=6-(3*0.99);\n", - "print \"(a)Ve = %0.2f V\\n(b)Ic = %0.2e A\\n(c)Ve = %0.2f V\\n\"%(Ve_1,Ic1,Ve1);\n", - "print \"Thus the circuit operates in an active mode\\n\\n\"\n", - "print \"For circuit 2,assume active mode\\n\"\n", - "Vcc=1;\n", - "Ve2=Vcc+Vbe;\n", - "Ie2=(6-Ve2)/(10*10**3);\n", - "Vc=0+(10*0.43);\n", - "print \"(a)Ve = %0.1f V\\n(b)Ie = %0.2e A\\n(c)Vc = %0.2f V\\n\"%(Ve2,Ie2,Vc);\n", - "print \"This circuit operates in a saturated mode\\n\\n\"\n", - "print \"For circuit 3,assume active mode\\n\"\n", - "Ve3=-5+Vbe;\n", - "Ie3=(9.5-Ve3)/(200*10**3);\n", - "Ic=Ie3*(beta_bjt/(1+beta_bjt));\n", - "Vc3=-50+(0.492*20);\n", - "print \"(a)Ve = %0.1f V\\n(b)Ie = %0.4e A\\n(c)Ic = %0.3e A\\n(d)Vc = %0.1f V\\n\"%(Ve3,Ie3,Ic,Vc3);\n", - "print \"The circuit operates in an active mode\\n\\n\"\n", - "print \"For circuit 4,assume active mode\\n\"\n", - "Ve4 = -20.7;\n", - "Ie4=(30+Ve4)/(5*10**3);\n", - "Vc4=(-Ie4*(beta_bjt/(1+beta_bjt))*(2*10**3))-10;\n", - "print \"(a)Ie = %0.2e A\\n(b)Vc = %0.2f V\\n\"%(Ie4,Vc4)\n", - "print \"The circuit operates in an active mode\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/NarasimhaMamidala/NarasimhaMamidala_version_backup/Chapter_4_BJT.ipynb b/sample_notebooks/NarasimhaMamidala/NarasimhaMamidala_version_backup/Chapter_4_BJT.ipynb new file mode 100755 index 00000000..c7db6367 --- /dev/null +++ b/sample_notebooks/NarasimhaMamidala/NarasimhaMamidala_version_backup/Chapter_4_BJT.ipynb @@ -0,0 +1,544 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4 BJT Fundamentals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−1 in page 208" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)The value of the Base Current is 3.85e-04 A\n", + "\n", + "(b)The value of the Collector Current is 3.615e-03 A \n", + "\n" + ] + } + ], + "source": [ + "#Calculate Base and Collector Currents\n", + "# Given Data\n", + "alpha=0.90; # Current Gain in CB mode\n", + "Ico=15*10**-6; # Reverse saturation Current in micro−A\n", + "Ie=4*10**-3; # Emitter Current in mA\n", + "# Calculations\n", + "Ic=Ico+(alpha*Ie);\n", + "Ib=Ie-Ic;\n", + "print \"(a)The value of the Base Current is %0.2e A\\n\" %Ib;\n", + "print \"(b)The value of the Collector Current is %0 .3e A \\n\" %Ic" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−2 in page 209" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)The Current gain alpha for BJT is 0.989 \n", + "\n", + "(b)The value of the base Current is 4.44e-05 A\n", + "\n", + "(c)The value of the Emitter Current is 4.04e-03 A \n", + "\n" + ] + } + ], + "source": [ + "#Calculate alpha using beta\n", + "# Given Data\n", + "\n", + "beta_bjt=90.; # beta gain for the BJT\n", + "Ic=4*10**-3; # Collector Current in mA\n", + "# Calculations\n", + "alpha=beta_bjt/(1.+beta_bjt);\n", + "Ib=Ic/beta_bjt;\n", + "Ie=Ic+Ib;\n", + "print \"(a)The Current gain alpha for BJT is %0.3f \\n\"%alpha\n", + "print \"(b)The value of the base Current is %0.2e A\\n\"%Ib\n", + "print \"(c)The value of the Emitter Current is %0.2e A \\n\"%Ie" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−3 in page 20" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)The value of Current gain beta for BJT is 9 \n", + "\n", + "(b)The value of the Collector Current is 4.65e-03 A \n", + "\n" + ] + } + ], + "source": [ + "#Collector Current in C E mode\n", + "# Given Data\n", + "alpha=0.90; # Current Gain of BJT\n", + "Ico=15*10**-6; # Reverse Saturation Current of BJT in micro−A\n", + "Ib=0.5*10**-3; # Base Current in C−E mode in mA\n", + "# Calculations\n", + "beta_bjt=alpha/(1-alpha);\n", + "Ic=(beta_bjt*Ib)+(beta_bjt+1)*Ico;\n", + "print \"(a)The value of Current gain beta for BJT is %0.0f \\n\"%beta_bjt\n", + "print \"(b)The value of the Collector Current is %0.2e A \\n\"%Ic" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−4 in page 20" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Current gain beta for the Device is 250 \n", + "\n" + ] + } + ], + "source": [ + "#Calculate beta for the BJT\n", + "Ib=20*10**-6; # Base current in micro−A\n", + "Ic=5*10**-3; # Collector Current in mA\n", + "# Calculations\n", + "beta_bjt=Ic/Ib;\n", + "print \"The Current gain beta for the Device is %0.0f \\n\"%beta_bjt;\n", + "# The Current Gain beta for the Device is 250" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−5 in page 209" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)The value of the Emitter Current is 5.05e-03A \n", + "\n", + "(b)The value of beta gain of the BJT is 100 \n", + "\n", + "(c)The value of alpha gain of the BJT is 0.990 \n", + "\n" + ] + } + ], + "source": [ + "#To Compute Alpha Beta and Emitter Current\n", + "# Given Data\n", + "Ib=50*10**-6; # Base Current in mu−A\n", + "Ic=5*10**-3; # Collector Current in mA\n", + "# Calculations\n", + "Ie=Ic+Ib;\n", + "beta_bjt=Ic/Ib;\n", + "alpha=Ic/Ie;\n", + "print \"(a)The value of the Emitter Current is %0.2eA \\n\"%Ie\n", + "print \"(b)The value of beta gain of the BJT is %0.0f \\n\"%beta_bjt\n", + "print \"(c)The value of alpha gain of the BJT is %0.3f \\n\"%alpha" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−6 in page 210" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of inverse beta of the BJT is 1 \n", + "\n", + "The value of inverse alpha of the BJT is 2 \n", + "\n" + ] + } + ], + "source": [ + "#Calculate alpha reverse and beta reverse\n", + "# Given Data\n", + "Ie=10.*10**-3; # Emitter Current in mA\n", + "Ib=5*10**-3; # Base Current in mu−A\n", + "# Calculations\n", + "Ic=Ie-Ib;\n", + "beta_reverse=Ib/Ic;\n", + "alpha_reverse=Ie/Ic;\n", + "print \"The value of inverse beta of the BJT is %0.0f \\n\"%beta_reverse\n", + "print \"The value of inverse alpha of the BJT is %0.0f \\n\"%alpha_reverse" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−7 in page 210" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Circuit 1:\n", + "(a)Emitter Current=9.30e-04 A\n", + "(b)Base Current=9.21e-06 A\n", + "(c)Collector Voltage=0.792 V\n", + "\n", + "\n", + "Circuit 2:\n", + "(a)Emitter Current=1.86e-03 A\n", + "(b) Collector Current=1.842e-03 A\n", + "(c)Collector Voltage=-5.700 V\n", + "\n" + ] + } + ], + "source": [ + "# Calculate Labeled Currents and Voltages\n", + "# Given Data\n", + "beta_bjt=100.; # beta gain of BJT\n", + "Vbe=0.7; # Base−Emitter voltage of BJT in V\n", + "#Calculation\n", + "Vcc1=10.;\n", + "Vee1=-10.;\n", + "Ve1=-0.7;\n", + "R1=10*10**3;\n", + "Ie1=(Vcc1-Vbe)/R1;\n", + "Ib1=Ie1/(beta_bjt+1);\n", + "Vc1=Vcc1-R1*(Ie1-Ib1);\n", + "Vcc2=10.;\n", + "Vee2=-15.;\n", + "Ve2=-0.7;\n", + "R2 =5*10**3;\n", + "Ie2=(Vcc2-Vbe)/R2;\n", + "Ic2=(beta_bjt/(beta_bjt+1.))*Ie2;\n", + "Vc2=Vee2+R2*(Ie2);\n", + "print \"Circuit 1:\\n(a)Emitter Current=%0.2e A\\n(b)Base Current=%0.2e A\\n(c)Collector Voltage=%0.3f V\\n\\n\"%(Ie1,Ib1,Vc1);\n", + "print \"Circuit 2:\\n(a)Emitter Current=%0.2e A\\n(b) Collector Current=%0.3e A\\n(c)Collector Voltage=%0.3f V\\n\"%(Ie2,Ic2,Vc2);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−8 in page 211" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Circuit 1:\n", + "(a)Base Voltage = 0.0 V\n", + "(b)Emitter Voltage = -0.7 V\n", + "\n", + "Circuit 2:\n", + "(a)Emitter Voltage = 0.7 V\n", + "(b) Collector Voltage = -5.7 V\n", + "\n" + ] + } + ], + "source": [ + "#Calculate labeled Voltages\n", + "# Given Data\n", + "Vbe=0.7; # Base−Emitter voltage of BJT in V\n", + "Vcc2=10; # DC voltage across Collector in V\n", + "Vee2=-15; # DC voltage across Emitter in V\n", + "Rc2=5*10**3; # Collector Resistance in K−ohms\n", + "# Beta Current Gain of BJT is Infinity\n", + "# Calculations\n", + "Vb1=0;\n", + "Ve1=-0.7;\n", + "Ve2=0.7;\n", + "Vc2=Vee2+Rc2*((Vcc2-Vbe)/Rc2);\n", + "print \"Circuit 1:\\n(a)Base Voltage = %0.1f V\\n(b)Emitter Voltage = %0.1f V\\n\"%(Vb1,Ve1);\n", + "print \"Circuit 2:\\n(a)Emitter Voltage = %0.1f V\\n(b) Collector Voltage = %0.1f V\\n\"%(Ve2,Vc2);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−9 in page 211" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Circuit Parameters:\n", + "(a)Base Voltage = 0.300V\n", + "(b)Base Current = 1.500e-05 A\n", + "(c)Emitter Current= 8.000e-04 A\n", + "(d)Collector Current = 7.850e-04 A\n", + "(e) Collector Voltage = -1.075 V\n", + "(f) beta gain = 52.333\n", + "(g)alpha gain = 0.981\n", + "\n" + ] + } + ], + "source": [ + "#Calculating BJT parameters assuming Vbe\n", + "# Given Data\n", + "Ve=1.; # Emitter Voltage of BJT in V\n", + "Vbe=0.7; # Base−Emitter Voltage of BJT in V\n", + "Rb=20*10**3; # Base Resistance of Circuit in K−ohms\n", + "Rc=5*10**3; # Collector Resistance of Circuit in K−ohms\n", + "Re=5*10**3; # Emitter Resistance of Circuit in K−ohms\n", + "Vcc=5.; # DC voltage across Collector in V\n", + "Vee=-5; # DC voltage across Emitter in V\n", + "# Calculations\n", + "Vb=Ve-Vbe;\n", + "Ib=Vb/Rb;\n", + "Ie=(Vcc -1)/Re;\n", + "Ic=Ie-Ib;\n", + "Vc=(Rc*Ic)-Vcc;\n", + "beta_bjt=Ic/Ib;\n", + "alpha=Ic/Ie;\n", + "print \"Circuit Parameters:\\n(a)Base Voltage = %0.3fV\\n(b)Base Current = %0.3e A\\n(c)Emitter Current= %0.3e A\\n(d)Collector Current = %0.3e A\\n(e) Collector Voltage = %0.3f V\\n(f) beta gain = %0.3f\\n(g)alpha gain = %0.3f\\n\"%(Vb,Ib,Ie,Ic,Vc, beta_bjt ,alpha);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−10 in page 211" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)Change in Emitter voltage is +0.40 V\n", + "\n", + "(b)Change in Collector Voltage is 0.00 V\n", + "\n" + ] + } + ], + "source": [ + "# Measurement of Circuit Voltage changes\n", + "# Given Data\n", + "Vb=-5; # Base Voltage of BJT in V\n", + "Rc=1*10**3; # Collector Resistance in K−ohms\n", + "Ie=2*10**-3; # Emitter Current of BJT in mA\n", + "delB=+0.4; # Change in Base Voltage\n", + "# Calculations\n", + "delE =+0.4;\n", + "delC=0;\n", + "print \"(a)Change in Emitter voltage is +%0.2f V\\n\"%delE\n", + "print \"(b)Change in Collector Voltage is %0.2f V\\n\"%delC" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4−11 in page 212" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Assume active mode for circuit 1\n", + "(a)Ve = 1.30 V\n", + "(b)Ic = 0.00e+00 A\n", + "(c)Ve = 3.03 V\n", + "\n", + "Thus the circuit operates in an active mode\n", + "\n", + "\n", + "For circuit 2,assume active mode\n", + "\n", + "(a)Ve = 1.7 V\n", + "(b)Ie = 4.30e-04 A\n", + "(c)Vc = 4.30 V\n", + "\n", + "This circuit operates in a saturated mode\n", + "\n", + "\n", + "For circuit 3,assume active mode\n", + "\n", + "(a)Ve = -4.3 V\n", + "(b)Ie = 6.9000e-05 A\n", + "(c)Ic = 0.000e+00 A\n", + "(d)Vc = -40.2 V\n", + "\n", + "The circuit operates in an active mode\n", + "\n", + "\n", + "For circuit 4,assume active mode\n", + "\n", + "(a)Ie = 1.86e-03 A\n", + "(b)Vc = -10.00 V\n", + "\n", + "The circuit operates in an active mode\n" + ] + } + ], + "source": [ + "# Determine mode of operation of BJT\n", + "# Given Data\n", + "Vbe=0.7; # Base−Emitter Voltage in V\n", + "beta_bjt=100; # beta gain of BJ\n", + "# Calculation\n", + "print \"Assume active mode for circuit 1\"\n", + "Vb1=2;\n", + "Ve_1=Vb1-Vbe;\n", + "Ie1 =1*10** -3;\n", + "Ic1=Ie1*(beta_bjt/(1+beta_bjt));\n", + "Ve1=6-(3*0.99);\n", + "print \"(a)Ve = %0.2f V\\n(b)Ic = %0.2e A\\n(c)Ve = %0.2f V\\n\"%(Ve_1,Ic1,Ve1);\n", + "print \"Thus the circuit operates in an active mode\\n\\n\"\n", + "print \"For circuit 2,assume active mode\\n\"\n", + "Vcc=1;\n", + "Ve2=Vcc+Vbe;\n", + "Ie2=(6-Ve2)/(10*10**3);\n", + "Vc=0+(10*0.43);\n", + "print \"(a)Ve = %0.1f V\\n(b)Ie = %0.2e A\\n(c)Vc = %0.2f V\\n\"%(Ve2,Ie2,Vc);\n", + "print \"This circuit operates in a saturated mode\\n\\n\"\n", + "print \"For circuit 3,assume active mode\\n\"\n", + "Ve3=-5+Vbe;\n", + "Ie3=(9.5-Ve3)/(200*10**3);\n", + "Ic=Ie3*(beta_bjt/(1+beta_bjt));\n", + "Vc3=-50+(0.492*20);\n", + "print \"(a)Ve = %0.1f V\\n(b)Ie = %0.4e A\\n(c)Ic = %0.3e A\\n(d)Vc = %0.1f V\\n\"%(Ve3,Ie3,Ic,Vc3);\n", + "print \"The circuit operates in an active mode\\n\\n\"\n", + "print \"For circuit 4,assume active mode\\n\"\n", + "Ve4 = -20.7;\n", + "Ie4=(30+Ve4)/(5*10**3);\n", + "Vc4=(-Ie4*(beta_bjt/(1+beta_bjt))*(2*10**3))-10;\n", + "print \"(a)Ie = %0.2e A\\n(b)Vc = %0.2f V\\n\"%(Ie4,Vc4)\n", + "print \"The circuit operates in an active mode\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/NarayaniGurumoorthy/NarayaniGurumoorthy_version_backup/chapter1.ipynb b/sample_notebooks/NarayaniGurumoorthy/NarayaniGurumoorthy_version_backup/chapter1.ipynb new file mode 100755 index 00000000..acf7396e --- /dev/null +++ b/sample_notebooks/NarayaniGurumoorthy/NarayaniGurumoorthy_version_backup/chapter1.ipynb @@ -0,0 +1,78 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:6a31e38d48b33cd2883c4a445f48cd42fa9848c47c13fe5bbf0011e5bf0bde7b" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Simple Stresses and Strains" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.1, Page no.9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given\n", + "#Variable declaration\n", + "L=150 #Length of the rod in cm\n", + "D=20 #Diameter of the rod in mm\n", + "P=20*1000 #Axial pull in N\n", + "E=2.0*(10**5) #Modulus of elasticity in N/(mm**2)\n", + "\n", + "#Calculation\n", + "A=(math.pi/4)*(D**2) #Area in sq.mm\n", + "sigma=P/A #Stress \n", + "e=sigma/E #Strain\n", + "dL=e*L #Elongation\n", + "\n", + "#Result\n", + "print \"sigma =\",round(sigma,3),\"N/mm^2\"\n", + "print \"Strain,e =\",round(e,6)\n", + "print \"Elongation,dL =\",round(dL,4),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "sigma = 63.662 N/mm^2\n", + "Strain,e = 0.000318\n", + "Elongation,dL = 0.0477 cm\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NarayaniGurumoorthy/chapter1.ipynb b/sample_notebooks/NarayaniGurumoorthy/chapter1.ipynb deleted file mode 100755 index acf7396e..00000000 --- a/sample_notebooks/NarayaniGurumoorthy/chapter1.ipynb +++ /dev/null @@ -1,78 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:6a31e38d48b33cd2883c4a445f48cd42fa9848c47c13fe5bbf0011e5bf0bde7b" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Simple Stresses and Strains" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.1, Page no.9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given\n", - "#Variable declaration\n", - "L=150 #Length of the rod in cm\n", - "D=20 #Diameter of the rod in mm\n", - "P=20*1000 #Axial pull in N\n", - "E=2.0*(10**5) #Modulus of elasticity in N/(mm**2)\n", - "\n", - "#Calculation\n", - "A=(math.pi/4)*(D**2) #Area in sq.mm\n", - "sigma=P/A #Stress \n", - "e=sigma/E #Strain\n", - "dL=e*L #Elongation\n", - "\n", - "#Result\n", - "print \"sigma =\",round(sigma,3),\"N/mm^2\"\n", - "print \"Strain,e =\",round(e,6)\n", - "print \"Elongation,dL =\",round(dL,4),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "sigma = 63.662 N/mm^2\n", - "Strain,e = 0.000318\n", - "Elongation,dL = 0.0477 cm\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NeerajBaunthiyal/NeerajBaunthiyal_version_backup/chapter1.ipynb b/sample_notebooks/NeerajBaunthiyal/NeerajBaunthiyal_version_backup/chapter1.ipynb new file mode 100755 index 00000000..2d6f6ded --- /dev/null +++ b/sample_notebooks/NeerajBaunthiyal/NeerajBaunthiyal_version_backup/chapter1.ipynb @@ -0,0 +1,570 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter1 : Introduction" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.1 : 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from numpy import *\n", + "B=100 #W(8Bulb)\n", + "F=60 #W(2Fan)\n", + "L=100 #W(2Light)\n", + "LoadConnected=8*B+2*F+2*L #W\n", + "print \"(a) Connected Load =\",LoadConnected,\"W\"\n", + "#12 midnight to 5am\n", + "demand1=1*F #W\n", + "#5am to 7am\n", + "demand2=2*F+1*L #W\n", + "#7am to 9am\n", + "demand3=0 #W\n", + "#9am to 6pm\n", + "demand4=2*F #W\n", + "#6pm to midnight\n", + "demand5=2*F+4*B #W\n", + "DEMAND=array([demand1, demand2, demand3, demand4, demand5])\n", + "max_demand=max(DEMAND) \n", + "print \"(b) Maximum demand =\",max_demand,\"W\" \n", + "df=max_demand/LoadConnected #demand factor\n", + "print \"(c) Demand factor =\",df \n", + "E=demand1*5+demand2*2+demand3*2+demand4*9+demand5*6 #Wh\n", + "E=E/1000 #kWh\n", + "print \"(d) Energy consumed during 24 hours =\",E,\"kWh \"\n", + "Edash=LoadConnected*24/1000 #kWh\n", + "print \"(e) Energy consumed during 24 hours if all devices are used =\",Edash,\"kWh\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Connected Load = 1120 W\n", + "(b) Maximum demand = 520 W\n", + "(c) Demand factor = 0.464285714286\n", + "(d) Energy consumed during 24 hours = 4.94 kWh \n", + "(e) Energy consumed during 24 hours if all devices are used = 26.88 kWh\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.2 : page 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "LoadA=2.5*1000 #W\n", + "#12 midnight to 5am\n", + "d1A=100 #W\n", + "#5am to 6am\n", + "d2A=1.1*1000 #W\n", + "#6am to 8am\n", + "d3A=200 #W\n", + "#8am to 5pm\n", + "d4A=0 #W\n", + "#5pm to 12 midnight\n", + "d5A=500 #W\n", + "LoadB=3*1000 #W\n", + "#11 pm to 7am\n", + "d1B=0 #W\n", + "#7 am to 8 am\n", + "d2B=300 #W\n", + "#8 am to 10 am\n", + "d3B=1*1000 #W\n", + "#10 am to 6 pm\n", + "d4B=200 #W\n", + "#6 pm to 11 pm\n", + "d5B=600 #W\n", + "DEMAND_A=array([d1A, d2A, d3A, d4A, d5A]) #W\n", + "DEMAND_B=array([d1B, d2B, d3B, d4B, d5B]) #W\n", + "max_demand_A=max(DEMAND_A) #W\n", + "max_demand_B=max(DEMAND_B) #W\n", + "df_A=max_demand_A/LoadA #demand factor\n", + "df_B=max_demand_B/LoadB #demand factor\n", + "print \"Demand factor of consumer A & B are :\",round(df_A,2),\"&\",round(df_B ,2)\n", + "gd_factor=(max_demand_A+max_demand_B)/max_demand_A \n", + "print \"Group diversity factor :\",round(gd_factor,2)\n", + "E_A=d1A*5+d2A*1+d3A*2+d4A*9+d5A*7 #Wh\n", + "E_B=d1B*8+d2B*1+d3B*2+d4B*8+d5B*5 #Wh\n", + "E_A=E_A/1000 #kWh\n", + "E_B=E_B/1000 #kWh\n", + "print \"Energy consumed by A & B during 24 hours =\",E_A,\"&\",E_B,\"kWh\"\n", + "Emax_A=max_demand_A*24/1000 #kWh\n", + "Emax_B=max_demand_B*24/1000 #kWh\n", + "print \"Maximum energy consumer A & B can consume during 24 hours =\",Emax_B,Emax_A,\"kWh \"\n", + "ratio_A=E_A/Emax_A \n", + "ratio_B=E_B/Emax_B \n", + "print \"Ratio of actual energy to maximum energy of consumer A & B :\",round(ratio_A,2),\"&\",round(ratio_B,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Demand factor of consumer A & B are : 0.44 & 0.33\n", + "Group diversity factor : 1.91\n", + "Energy consumed by A & B during 24 hours = 5.5 & 6.9 kWh\n", + "Maximum energy consumer A & B can consume during 24 hours = 24.0 26.4 kWh \n", + "Ratio of actual energy to maximum energy of consumer A & B : 0.21 & 0.29\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.3 : page 31" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "n1=600 #No. of apartments\n", + "L1=5 #kW#Each Apartment Load\n", + "n2=20 #No. of general purpose shops\n", + "L2=2 #kW#Each Shop Load\n", + "df=0.8 #demand factor\n", + "#1 Floor mill\n", + "L3=10 #kW#Load\n", + "df3=0.7 #demand factor\n", + "#1 Saw mill\n", + "L4=5 #kW#Load\n", + "df4=0.8 #demand factor\n", + "#1 Laundry\n", + "L5=20 #kW#Load\n", + "df5=0.65 #demand factor\n", + "#1 Cinema\n", + "L6=80 #kW#Load\n", + "df6=0.5 #demand factor\n", + "#Street lights\n", + "n7=200 #no. of tube lights\n", + "L7=40 #W#Load of each light\n", + "#Residential Load\n", + "df8=0.5 #demand factor\n", + "gdf_r=3 #group diversity factor\n", + "pdf_r=1.25 #peak diversity factor\n", + "#Commertial Load\n", + "gdf_c=2 #group diversity factor\n", + "pdf_c=1.6 #peak diversity factor\n", + "#Solution :\n", + "#Maximum demand of each apartment\n", + "dmax_1a=L1*df8 #kW\n", + "#Maximum demand of 600 apartment\n", + "dmax_a=n1*dmax_1a/gdf_r #kW\n", + "#demand of apartments at system peak time\n", + "d_a_sp=dmax_a/pdf_r #kW\n", + "#Maximum Commercial demand\n", + "dmax_c=(n2*L2*df+L3*df3+L4*df4+L5*df5+L6*df6)/gdf_c #kW\n", + "#Commercial demand at system peak time\n", + "d_c_sp=dmax_c/pdf_c #kW\n", + "#demand of street light at system peak time\n", + "d_sl_sp=n7*L7/1000 #kW\n", + "#Increase in system peak demand\n", + "DI=d_a_sp+d_c_sp+d_sl_sp #kW\n", + "print \"Increase in system peak demand =\",DI,\"kW \" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Increase in system peak demand = 438.0 kW \n" + ] + } + ], + "prompt_number": 33 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.4 : page 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#12 to 5 am\n", + "L1=20 #MW\n", + "t1=5 #hours\n", + "#5 to 9 am\n", + "L2=40 #MW\n", + "t2=4 #hours\n", + "#9 to 6 pm\n", + "L3=80 #MW\n", + "t3=9 #hours\n", + "#6 to 10 pm\n", + "L4=100 #MW\n", + "t4=4 #hours\n", + "#10 to 12 am\n", + "L5=20 #MW\n", + "t5=2 #hours\n", + "#Energy Poduced in 24 hours\n", + "E=L1*t1+L2*t2+L3*t3+L4*t4+L5*t5 #MWh\n", + "print \"Energy Supplied by the plant in 24 hours =\",E,\"MWh \" \n", + "LF=E/24 #%#Load Factor\n", + "print \"Load Factor =\",round(LF,2),\"% \" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Energy Supplied by the plant in 24 hours = 1420 MWh \n", + "Load Factor = 59.17 % \n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.5 : page 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "C=125 #MW#Installed Capacity\n", + "#12 to 5 am\n", + "L1=20 #MW\n", + "t1=5 #hours\n", + "#5 to 9 am\n", + "L2=40 #MW\n", + "t2=4 #hours\n", + "#9 to 6 pm\n", + "L3=80 #MW\n", + "t3=9 #hours\n", + "#6 to 10 pm\n", + "L4=100 #MW\n", + "t4=4 #hours\n", + "#10 to 12 am\n", + "L5=20 #MW\n", + "t5=2 #hours\n", + "#Energy Poduced in 24 hours\n", + "E=L1*t1+L2*t2+L3*t3+L4*t4+L5*t5 #MWh\n", + "LF=E/24 #%#Load Factor\n", + "CF=LF/C #%#Capacity Factor\n", + "print \"Capacity Factor =\",round(CF,2),\"% \" \n", + "UF=100/C #%#Utilisation Factor\n", + "print \"Utilisation Factor =\",UF,\"% \" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Capacity Factor = 0.47 % \n", + "Utilisation Factor = 0.8 % \n" + ] + } + ], + "prompt_number": 35 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.6 : page 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#12 to 5 am & 10 to 12 am\n", + "L1=20 #MW\n", + "E1=L1*24 #MWh\n", + "#5 to 9 am\n", + "L2=40 #MW\n", + "E2=E1+(L2-L1)*17 #MWh\n", + "#9 to 6 pm\n", + "L3=80 #MW\n", + "E3=E2+(L3-L2)*13 #MWh\n", + "#6 to 10 pm\n", + "L4=100 #MW\n", + "E4=E3+(L4-L3)*4 #MWh\n", + "#Plotting Energy load curve\n", + "%matplotlib inline\n", + "from matplotlib.pyplot import *\n", + "L=array([0,L1,L2,L3,L4]) #MW\n", + "E=array([0,E1,E2,E3,E4]) #Mwh\n", + "subplot(3,1,1)\n", + "plot(E,L)\n", + "xlabel('Energy(MWh)') \n", + "ylabel('Load(MW)') \n", + "title('Energy Load Curve') \n", + "#Energy Supplied\n", + "#Upto 5am\n", + "t1=5 #hours\n", + "E1=L1*t1 #MWh\n", + "#Upto 9am\n", + "t2=4 #hours\n", + "E2=E1+L2*t2 #MWh\n", + "#Upto 6pm\n", + "t3=9 #hours\n", + "E3=E2+L3*t3 #MWh\n", + "#Upto 10pm\n", + "t4=4 #hours\n", + "E4=E3+L4*t4 #MWh\n", + "#Upto 12pm\n", + "t4=2 #hours\n", + "E4=E3+L4*t4 #MWh\n", + "#Plotting Mass curve\n", + "T=[0,1,2,3,4] #MW\n", + "E=[0,E1,E2,E3,E4] #Mwh\n", + "subplot(3,1,3)\n", + "plot(T,E)\n", + "ylabel('Energy(MWh)') \n", + "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-10pm above4: 10-12pm') \n", + "title('Mass Curve') \n", + "show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "met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Y52clrl2tPc9YAJhLOeHZraujvvM\nPpbhPIUB5kkEb7T6hwbPP2ZyDXBC7Ha8CvhenvMviL+pnoTQ9X8FiOMzsxXGc26lelwEwkP6x5Jm\nAB2BP8f02u451/0/CWwZr/NbQldXhtWE1vFUwt8240zwHeC6+HfZJ5EOQXhOo7obch3h4X5t/I1M\norqbKElyDCrvb0fSiFhXbeMz4pfx0O3AdpLeBi4CLs1z/oHx/P8GblX11IWTCN3LZyZ6PPZJnNo5\n3u/5hPGRzeymsP+rBuMh6B2nxCh4yjya5w2y2RNbJo+a2YAym9IiKEGrqSQ0q5aJ4zipwd9Sm45U\n1LW3TBzHcZyi8ZaJ4ziOUzQuJo7jOE7RuJg4juM4ReNi4jiO4xSNi4njOI5TNC4mjuM4TtH8f3Sp\nUZu5Oj0hAAAAAElFTkSuQmCC\n", + "text": [ + "" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.7 : page 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "dmax=40 #MW#Maximum demand\n", + "CF=0.5 #Capacity Factor\n", + "UF=0.8 #Utilisation Factor\n", + "LF=CF/UF #/Load Factor\n", + "print \"(a) Load Factor =\",LF \n", + "C=dmax/UF #MW#Plant Capacity\n", + "print \"(b) Plant Capacity =\",C,\"MW \" \n", + "RC=C-dmax #MW#Reserve Capacity\n", + "print \"(c) Reserve Capacity =\",RC,\"MW \" \n", + "p=dmax*LF*24*365 #MWh#Annual Energy Production\n", + "print \"(d) Annual Energy Production =\",p,\"MWh\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Load Factor = 0.625\n", + "(b) Plant Capacity = 50.0 MW \n", + "(c) Reserve Capacity = 10.0 MW \n", + "(d) Annual Energy Production = 219000.0 MWh\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.8 : page 52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "L1=50 #MW#Initial\n", + "t1=5 #hours\n", + "L2=50 #MW#5am\n", + "t2=4 #hours\n", + "L3=100 #MW#9am\n", + "t3=9 #hours\n", + "L4=100 #MW#6pm\n", + "t4=2 #hours\n", + "L5=150 #MW#8pm\n", + "t5=2 #hours\n", + "L6=80 #MW#10pm\n", + "t6=2 #hours\n", + "L7=50 #MW\n", + "#Energy Required in 24 hours\n", + "E=L1*t1+(L2+L3)/2*t2+(L3+L4)/2*t3+(L4+L5)/2*t4+(L5+L6)/2*t5+(L6+L1)/2*t6 #MWh\n", + "print \"Energy required in one day =\",E,\"MWh\" \n", + "DLF=E/L5/24*100 #%#Daily Load Factor\n", + "print \"Daily Load Factor =\",round(DLF,2),\"%\" \n", + "#Plotting load curve\n", + "% matplotlib inline\n", + "T=arange(0,7,1) #Slots\n", + "L=array([L1,L2,L3,L4,L5,L6,L7]) #MW\n", + "plot(T,L)\n", + "ylabel('Load(MW)') \n", + "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-8pm 4-5:8-10pm 5-6 :10-12pm') \n", + "title('Chronological Load Curve') \n", + "show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Energy required in one day = 2060.0 MWh\n", + "Daily Load Factor = 57.22 %\n" + ] + }, + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAEZCAYAAABWwhjiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucHFWZ//HPlxDUgBIQ5RokiihRUGBB0EVHFBVcEsD1\ngooGVBTWoAg/CYoSXUREvBEFVlgi4hJABAQJCiKjsFwFQrhKQC4JSLjI1bgQyPP745xJOp3unp6e\n7q6+fN+v17zSXV1d/VTPpJ465zl1ShGBmZlZI1YpOgAzM+teTiJmZtYw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lZw5xEzMysYf8fAHl1R8P2C3cAAAAASUVORK5CYII=\n", + "text": [ + "" + ] + } + ], + "prompt_number": 38 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "exa 1.9 : page 55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "L1=50 #MW#Initial\n", + "t1=5 #hours\n", + "L2=50 #MW#5am\n", + "t2=4 #hours\n", + "L3=100 #MW#9am\n", + "t3=9 #hours\n", + "L4=100 #MW#6pm\n", + "t4=2 #hours\n", + "L5=150 #MW#8pm\n", + "t5=2 #hours\n", + "L6=80 #MW#10pm\n", + "t6=2 #hours\n", + "L7=50 #MW\n", + "#Load Duration Curve\n", + "l1=L5 #Mw\n", + "l2=L4 #MW\n", + "l3=L1 #MW\n", + "L=array([l1,l2,l2,l3,l3])\n", + "T=arange(0,30,6) #Duration in hours\n", + "subplot(3,1,1)\n", + "plot(T,L)\n", + "ylabel('Load(MW)') \n", + "xlabel('Hours') \n", + "title('Load Duration Curve') \n", + "#Energy Consumed\n", + "#Upto 5am\n", + "t1=5 #hours\n", + "E1=L1*t1 #MWh\n", + "#Upto 9am\n", + "t2=4 #hours\n", + "E2=E1+L2*t2 #MWh\n", + "#Upto 6pm\n", + "t3=9 #hours\n", + "E3=E2+L3*t3 #MWh\n", + "#Upto 10pm\n", + "t4=4 #hours\n", + "E4=E3+L4*t4 #MWh\n", + "#Upto 12pm\n", + "t4=2 #hours\n", + "E4=E3+L4*t4 #MWh\n", + "#Plotting Mass curve\n", + "T=arange(0,5,1) #MW\n", + "E=[0,E1,E2,E3,E4] #Mwh\n", + "subplot(3,1,3)\n", + "plot(T,E)\n", + "ylabel('Energy(MWh)') \n", + "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-10pm above4: 10-12pm') \n", + "title('Mass Curve') \n", + "show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "metadata": {}, + "output_type": "display_data", + "png": "iVBORw0KGgoAAAANSUh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KDJckw4OL477Ml2piKFtXyiH2JmXDoU4CxZvZGrrwK\nob6fBTaTNEPScTE975iHpKnAn4Bj4zmbK6wNfC6wBfBy/Io4PsfpawIPSnqF8AKbQegqABgF3Cbp\nJWAutV8ORt2viOwvq1W+tCR9TyF0+SDgPkkP5LoXQitgHeCRaPPV8fx8/bmF7M/mckmvA08DFyZe\nfo12n/nsz8GFkibHbo8hwFn13Gch+7M5GxgV6+TITNnR3unAC4SxmJPMbGk995l9LMNpCgPCEwmz\nxVKHHVf+MY+LgENiN+LvgB/mOf+M+ExtQAjlfg1AHF95X2E85u/UjmtAeCmfKmkK0BH4a0wvdM+5\n7v9BYPVYzoWErqsMXxBav5MJ/7eZwf9jgD/E/5cBiXQIQnMktd2KSwkv84vjMzKR2m6fJMkxpLzP\njqRLYl21i++I8+Kha4H1JL0D/BQ4J8/5O8bzDwX+rlpXgsMJ3cXHJno0BiRO7Rzv93TC+MYqdlPc\n31XReEh2x2lkFGay3JPnC7HFE1se95hZ/zKb0ipohFZRSbSolofjOBWDf5U2H2Wpa295OI7jOKnx\nlofjOI6TGhcPx3EcJzUuHo7jOE5qXDwcx3Gc1Lh4OI7jOKlx8XAcx3FS8//ja4GDLNv8OwAAAABJ\nRU5ErkJggg==\n", + "text": [ + "" + ] + } + ], + "prompt_number": 39 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/NeerajBaunthiyal/chapter1.ipynb b/sample_notebooks/NeerajBaunthiyal/chapter1.ipynb deleted file mode 100755 index 2d6f6ded..00000000 --- a/sample_notebooks/NeerajBaunthiyal/chapter1.ipynb +++ /dev/null @@ -1,570 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter1 : Introduction" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.1 : 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from numpy import *\n", - "B=100 #W(8Bulb)\n", - "F=60 #W(2Fan)\n", - "L=100 #W(2Light)\n", - "LoadConnected=8*B+2*F+2*L #W\n", - "print \"(a) Connected Load =\",LoadConnected,\"W\"\n", - "#12 midnight to 5am\n", - "demand1=1*F #W\n", - "#5am to 7am\n", - "demand2=2*F+1*L #W\n", - "#7am to 9am\n", - "demand3=0 #W\n", - "#9am to 6pm\n", - "demand4=2*F #W\n", - "#6pm to midnight\n", - "demand5=2*F+4*B #W\n", - "DEMAND=array([demand1, demand2, demand3, demand4, demand5])\n", - "max_demand=max(DEMAND) \n", - "print \"(b) Maximum demand =\",max_demand,\"W\" \n", - "df=max_demand/LoadConnected #demand factor\n", - "print \"(c) Demand factor =\",df \n", - "E=demand1*5+demand2*2+demand3*2+demand4*9+demand5*6 #Wh\n", - "E=E/1000 #kWh\n", - "print \"(d) Energy consumed during 24 hours =\",E,\"kWh \"\n", - "Edash=LoadConnected*24/1000 #kWh\n", - "print \"(e) Energy consumed during 24 hours if all devices are used =\",Edash,\"kWh\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Connected Load = 1120 W\n", - "(b) Maximum demand = 520 W\n", - "(c) Demand factor = 0.464285714286\n", - "(d) Energy consumed during 24 hours = 4.94 kWh \n", - "(e) Energy consumed during 24 hours if all devices are used = 26.88 kWh\n" - ] - } - ], - "prompt_number": 31 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.2 : page 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "LoadA=2.5*1000 #W\n", - "#12 midnight to 5am\n", - "d1A=100 #W\n", - "#5am to 6am\n", - "d2A=1.1*1000 #W\n", - "#6am to 8am\n", - "d3A=200 #W\n", - "#8am to 5pm\n", - "d4A=0 #W\n", - "#5pm to 12 midnight\n", - "d5A=500 #W\n", - "LoadB=3*1000 #W\n", - "#11 pm to 7am\n", - "d1B=0 #W\n", - "#7 am to 8 am\n", - "d2B=300 #W\n", - "#8 am to 10 am\n", - "d3B=1*1000 #W\n", - "#10 am to 6 pm\n", - "d4B=200 #W\n", - "#6 pm to 11 pm\n", - "d5B=600 #W\n", - "DEMAND_A=array([d1A, d2A, d3A, d4A, d5A]) #W\n", - "DEMAND_B=array([d1B, d2B, d3B, d4B, d5B]) #W\n", - "max_demand_A=max(DEMAND_A) #W\n", - "max_demand_B=max(DEMAND_B) #W\n", - "df_A=max_demand_A/LoadA #demand factor\n", - "df_B=max_demand_B/LoadB #demand factor\n", - "print \"Demand factor of consumer A & B are :\",round(df_A,2),\"&\",round(df_B ,2)\n", - "gd_factor=(max_demand_A+max_demand_B)/max_demand_A \n", - "print \"Group diversity factor :\",round(gd_factor,2)\n", - "E_A=d1A*5+d2A*1+d3A*2+d4A*9+d5A*7 #Wh\n", - "E_B=d1B*8+d2B*1+d3B*2+d4B*8+d5B*5 #Wh\n", - "E_A=E_A/1000 #kWh\n", - "E_B=E_B/1000 #kWh\n", - "print \"Energy consumed by A & B during 24 hours =\",E_A,\"&\",E_B,\"kWh\"\n", - "Emax_A=max_demand_A*24/1000 #kWh\n", - "Emax_B=max_demand_B*24/1000 #kWh\n", - "print \"Maximum energy consumer A & B can consume during 24 hours =\",Emax_B,Emax_A,\"kWh \"\n", - "ratio_A=E_A/Emax_A \n", - "ratio_B=E_B/Emax_B \n", - "print \"Ratio of actual energy to maximum energy of consumer A & B :\",round(ratio_A,2),\"&\",round(ratio_B,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Demand factor of consumer A & B are : 0.44 & 0.33\n", - "Group diversity factor : 1.91\n", - "Energy consumed by A & B during 24 hours = 5.5 & 6.9 kWh\n", - "Maximum energy consumer A & B can consume during 24 hours = 24.0 26.4 kWh \n", - "Ratio of actual energy to maximum energy of consumer A & B : 0.21 & 0.29\n" - ] - } - ], - "prompt_number": 32 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.3 : page 31" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "n1=600 #No. of apartments\n", - "L1=5 #kW#Each Apartment Load\n", - "n2=20 #No. of general purpose shops\n", - "L2=2 #kW#Each Shop Load\n", - "df=0.8 #demand factor\n", - "#1 Floor mill\n", - "L3=10 #kW#Load\n", - "df3=0.7 #demand factor\n", - "#1 Saw mill\n", - "L4=5 #kW#Load\n", - "df4=0.8 #demand factor\n", - "#1 Laundry\n", - "L5=20 #kW#Load\n", - "df5=0.65 #demand factor\n", - "#1 Cinema\n", - "L6=80 #kW#Load\n", - "df6=0.5 #demand factor\n", - "#Street lights\n", - "n7=200 #no. of tube lights\n", - "L7=40 #W#Load of each light\n", - "#Residential Load\n", - "df8=0.5 #demand factor\n", - "gdf_r=3 #group diversity factor\n", - "pdf_r=1.25 #peak diversity factor\n", - "#Commertial Load\n", - "gdf_c=2 #group diversity factor\n", - "pdf_c=1.6 #peak diversity factor\n", - "#Solution :\n", - "#Maximum demand of each apartment\n", - "dmax_1a=L1*df8 #kW\n", - "#Maximum demand of 600 apartment\n", - "dmax_a=n1*dmax_1a/gdf_r #kW\n", - "#demand of apartments at system peak time\n", - "d_a_sp=dmax_a/pdf_r #kW\n", - "#Maximum Commercial demand\n", - "dmax_c=(n2*L2*df+L3*df3+L4*df4+L5*df5+L6*df6)/gdf_c #kW\n", - "#Commercial demand at system peak time\n", - "d_c_sp=dmax_c/pdf_c #kW\n", - "#demand of street light at system peak time\n", - "d_sl_sp=n7*L7/1000 #kW\n", - "#Increase in system peak demand\n", - "DI=d_a_sp+d_c_sp+d_sl_sp #kW\n", - "print \"Increase in system peak demand =\",DI,\"kW \" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Increase in system peak demand = 438.0 kW \n" - ] - } - ], - "prompt_number": 33 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.4 : page 35" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#12 to 5 am\n", - "L1=20 #MW\n", - "t1=5 #hours\n", - "#5 to 9 am\n", - "L2=40 #MW\n", - "t2=4 #hours\n", - "#9 to 6 pm\n", - "L3=80 #MW\n", - "t3=9 #hours\n", - "#6 to 10 pm\n", - "L4=100 #MW\n", - "t4=4 #hours\n", - "#10 to 12 am\n", - "L5=20 #MW\n", - "t5=2 #hours\n", - "#Energy Poduced in 24 hours\n", - "E=L1*t1+L2*t2+L3*t3+L4*t4+L5*t5 #MWh\n", - "print \"Energy Supplied by the plant in 24 hours =\",E,\"MWh \" \n", - "LF=E/24 #%#Load Factor\n", - "print \"Load Factor =\",round(LF,2),\"% \" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Energy Supplied by the plant in 24 hours = 1420 MWh \n", - "Load Factor = 59.17 % \n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.5 : page 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "C=125 #MW#Installed Capacity\n", - "#12 to 5 am\n", - "L1=20 #MW\n", - "t1=5 #hours\n", - "#5 to 9 am\n", - "L2=40 #MW\n", - "t2=4 #hours\n", - "#9 to 6 pm\n", - "L3=80 #MW\n", - "t3=9 #hours\n", - "#6 to 10 pm\n", - "L4=100 #MW\n", - "t4=4 #hours\n", - "#10 to 12 am\n", - "L5=20 #MW\n", - "t5=2 #hours\n", - "#Energy Poduced in 24 hours\n", - "E=L1*t1+L2*t2+L3*t3+L4*t4+L5*t5 #MWh\n", - "LF=E/24 #%#Load Factor\n", - "CF=LF/C #%#Capacity Factor\n", - "print \"Capacity Factor =\",round(CF,2),\"% \" \n", - "UF=100/C #%#Utilisation Factor\n", - "print \"Utilisation Factor =\",UF,\"% \" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Capacity Factor = 0.47 % \n", - "Utilisation Factor = 0.8 % \n" - ] - } - ], - "prompt_number": 35 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.6 : page 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#12 to 5 am & 10 to 12 am\n", - "L1=20 #MW\n", - "E1=L1*24 #MWh\n", - "#5 to 9 am\n", - "L2=40 #MW\n", - "E2=E1+(L2-L1)*17 #MWh\n", - "#9 to 6 pm\n", - "L3=80 #MW\n", - "E3=E2+(L3-L2)*13 #MWh\n", - "#6 to 10 pm\n", - "L4=100 #MW\n", - "E4=E3+(L4-L3)*4 #MWh\n", - "#Plotting Energy load curve\n", - "%matplotlib inline\n", - "from matplotlib.pyplot import *\n", - "L=array([0,L1,L2,L3,L4]) #MW\n", - "E=array([0,E1,E2,E3,E4]) #Mwh\n", - "subplot(3,1,1)\n", - "plot(E,L)\n", - "xlabel('Energy(MWh)') \n", - "ylabel('Load(MW)') \n", - "title('Energy Load Curve') \n", - "#Energy Supplied\n", - "#Upto 5am\n", - "t1=5 #hours\n", - "E1=L1*t1 #MWh\n", - "#Upto 9am\n", - "t2=4 #hours\n", - "E2=E1+L2*t2 #MWh\n", - "#Upto 6pm\n", - "t3=9 #hours\n", - "E3=E2+L3*t3 #MWh\n", - "#Upto 10pm\n", - "t4=4 #hours\n", - "E4=E3+L4*t4 #MWh\n", - "#Upto 12pm\n", - "t4=2 #hours\n", - "E4=E3+L4*t4 #MWh\n", - "#Plotting Mass curve\n", - "T=[0,1,2,3,4] #MW\n", - "E=[0,E1,E2,E3,E4] #Mwh\n", - "subplot(3,1,3)\n", - "plot(T,E)\n", - "ylabel('Energy(MWh)') \n", - "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-10pm above4: 10-12pm') \n", - "title('Mass Curve') \n", - "show()" - ], - "language": "python", - "metadata": {},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t4z5rsz+bnwPDY52clrl2tPc9YAJhLOeHZraujvvM\nPpbhPIUB5kkEb7T6hwbPP2ZyDXBC7Ha8CvhenvMviL+pnoTQ9X8FiOMzsxXGc26lelwEwkP6x5Jm\nAB2BP8f02u451/0/CWwZr/NbQldXhtWE1vFUwt8240zwHeC6+HfZJ5EOQXhOo7obch3h4X5t/I1M\norqbKElyDCrvb0fSiFhXbeMz4pfx0O3AdpLeBi4CLs1z/oHx/P8GblX11IWTCN3LZyZ6PPZJnNo5\n3u/5hPGRzeymsP+rBuMh6B2nxCh4yjya5w2y2RNbJo+a2YAym9IiKEGrqSQ0q5aJ4zipwd9Sm45U\n1LW3TBzHcZyi8ZaJ4ziOUzQuJo7jOE7RuJg4juM4ReNi4jiO4xSNi4njOI5TNC4mjuM4TtH8f3Sp\nUZu5Oj0hAAAAAElFTkSuQmCC\n", - "text": [ - "" - ] - } - ], - "prompt_number": 36 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.7 : page 45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "dmax=40 #MW#Maximum demand\n", - "CF=0.5 #Capacity Factor\n", - "UF=0.8 #Utilisation Factor\n", - "LF=CF/UF #/Load Factor\n", - "print \"(a) Load Factor =\",LF \n", - "C=dmax/UF #MW#Plant Capacity\n", - "print \"(b) Plant Capacity =\",C,\"MW \" \n", - "RC=C-dmax #MW#Reserve Capacity\n", - "print \"(c) Reserve Capacity =\",RC,\"MW \" \n", - "p=dmax*LF*24*365 #MWh#Annual Energy Production\n", - "print \"(d) Annual Energy Production =\",p,\"MWh\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Load Factor = 0.625\n", - "(b) Plant Capacity = 50.0 MW \n", - "(c) Reserve Capacity = 10.0 MW \n", - "(d) Annual Energy Production = 219000.0 MWh\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.8 : page 52" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "L1=50 #MW#Initial\n", - "t1=5 #hours\n", - "L2=50 #MW#5am\n", - "t2=4 #hours\n", - "L3=100 #MW#9am\n", - "t3=9 #hours\n", - "L4=100 #MW#6pm\n", - "t4=2 #hours\n", - "L5=150 #MW#8pm\n", - "t5=2 #hours\n", - "L6=80 #MW#10pm\n", - "t6=2 #hours\n", - "L7=50 #MW\n", - "#Energy Required in 24 hours\n", - "E=L1*t1+(L2+L3)/2*t2+(L3+L4)/2*t3+(L4+L5)/2*t4+(L5+L6)/2*t5+(L6+L1)/2*t6 #MWh\n", - "print \"Energy required in one day =\",E,\"MWh\" \n", - "DLF=E/L5/24*100 #%#Daily Load Factor\n", - "print \"Daily Load Factor =\",round(DLF,2),\"%\" \n", - "#Plotting load curve\n", - "% matplotlib inline\n", - "T=arange(0,7,1) #Slots\n", - "L=array([L1,L2,L3,L4,L5,L6,L7]) #MW\n", - "plot(T,L)\n", - "ylabel('Load(MW)') \n", - "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-8pm 4-5:8-10pm 5-6 :10-12pm') \n", - "title('Chronological Load Curve') \n", - "show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Energy required in one day = 2060.0 MWh\n", - "Daily Load Factor = 57.22 %\n" - ] - }, - { - "metadata": {}, - "output_type": "display_data", - "png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAEZCAYAAABWwhjiAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucHFWZ//HPlxDUgBIQ5RokiihRUGBB0EVHFBVcEsD1\ngooGVBTWoAg/CYoSXUREvBEFVlgi4hJABAQJCiKjsFwFQrhKQC4JSLjI1bgQyPP745xJOp3unp6e\n7q6+fN+v17zSXV1d/VTPpJ465zl1ShGBmZlZI1YpOg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XMSMTOzhjmJmJlZw5xEzMysYf8fAHl1R8P2C3cAAAAASUVORK5CYII=\n", - "text": [ - "" - ] - } - ], - "prompt_number": 38 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "exa 1.9 : page 55" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "L1=50 #MW#Initial\n", - "t1=5 #hours\n", - "L2=50 #MW#5am\n", - "t2=4 #hours\n", - "L3=100 #MW#9am\n", - "t3=9 #hours\n", - "L4=100 #MW#6pm\n", - "t4=2 #hours\n", - "L5=150 #MW#8pm\n", - "t5=2 #hours\n", - "L6=80 #MW#10pm\n", - "t6=2 #hours\n", - "L7=50 #MW\n", - "#Load Duration Curve\n", - "l1=L5 #Mw\n", - "l2=L4 #MW\n", - "l3=L1 #MW\n", - "L=array([l1,l2,l2,l3,l3])\n", - "T=arange(0,30,6) #Duration in hours\n", - "subplot(3,1,1)\n", - "plot(T,L)\n", - "ylabel('Load(MW)') \n", - "xlabel('Hours') \n", - "title('Load Duration Curve') \n", - "#Energy Consumed\n", - "#Upto 5am\n", - "t1=5 #hours\n", - "E1=L1*t1 #MWh\n", - "#Upto 9am\n", - "t2=4 #hours\n", - "E2=E1+L2*t2 #MWh\n", - "#Upto 6pm\n", - "t3=9 #hours\n", - "E3=E2+L3*t3 #MWh\n", - "#Upto 10pm\n", - "t4=4 #hours\n", - "E4=E3+L4*t4 #MWh\n", - "#Upto 12pm\n", - "t4=2 #hours\n", - "E4=E3+L4*t4 #MWh\n", - "#Plotting Mass curve\n", - "T=arange(0,5,1) #MW\n", - "E=[0,E1,E2,E3,E4] #Mwh\n", - "subplot(3,1,3)\n", - "plot(T,E)\n", - "ylabel('Energy(MWh)') \n", - "xlabel('0-1: 12-5am 1-2: 5-9am 2-3: 9-6pm 3-4: 6-10pm above4: 10-12pm') \n", - "title('Mass Curve') \n", - "show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "metadata": {}, - "output_type": "display_data", - "png": "iVBOR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+FJZ3+DdwY+KDJckw4OL477Ml2piKFtXyiH2JmXDoU4CxZvZGrrwK\nob6fBTaTNEPScTE975iHpKnAn4Bj4zmbK6wNfC6wBfBy/Io4PsfpawIPSnqF8AKbQegqABgF3Cbp\nJWAutV8ORt2viOwvq1W+tCR9TyF0+SDgPkkP5LoXQitgHeCRaPPV8fx8/bmF7M/mckmvA08DFyZe\nfo12n/nsz8GFkibHbo8hwFn13Gch+7M5GxgV6+TITNnR3unAC4SxmJPMbGk995l9LMNpCgPCEwmz\nxVKHHVf+MY+LgENiN+LvgB/mOf+M+ExtQAjlfg1AHF95X2E85u/UjmtAeCmfKmkK0BH4a0wvdM+5\n7v9BYPVYzoWErqsMXxBav5MJ/7eZwf9jgD/E/5cBiXQIQnMktd2KSwkv84vjMzKR2m6fJMkxpLzP\njqRLYl21i++I8+Kha4H1JL0D/BQ4J8/5O8bzDwX+rlpXgsMJ3cXHJno0BiRO7Rzv93TC+MYqdlPc\n31XReEh2x2lkFGay3JPnC7HFE1se95hZ/zKb0ipohFZRSbSolofjOBWDf5U2H2Wpa295OI7jOKnx\nlofjOI6TGhcPx3EcJzUuHo7jOE5qXDwcx3Gc1Lh4OI7jOKlx8XAcx3FS8//ja4GDLNv8OwAAAABJ\nRU5ErkJggg==\n", - "text": [ - "" - ] - } - ], - "prompt_number": 39 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2.ipynb b/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2.ipynb new file mode 100755 index 00000000..78fcb8ea --- /dev/null +++ b/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2.ipynb @@ -0,0 +1,507 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:8949f832de7d3f263ae07355a00ea5a20f907aff9cf98c80b9a9488be44e93f7" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2: Special Theory of Relativity" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2, Page 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "ly = 9.46e+015; # Distance travelled by light in an year, m\n", + "c = 3e+008; # Speed of light, m/s\n", + "L = 4.30*ly; # Distance of Alpha Centauri from earth, m\n", + "T0 = 16*365.25*24*60*60; # Proper time in system K_prime, s\n", + "\n", + "#Calculations\n", + "# As time measured on earth, T = 2*L/v = T0_prime/sqrt(1-(v/c)^2), solving for v\n", + "v = sqrt(4*L**2/(T0**2+4*L**2/c**2)); # Speed of the aircraft, m/s\n", + "gama = 1/sqrt(1-(v/c)**2); # Relativistic factor\n", + "T = gama*T0/(365.25*24*60*60); # Time interval as measured on Earth, y\n", + "\n", + "#Results\n", + "print \"The speed of the aircraft = %4.2e m/s\" %v\n", + "print \"The time interval as measured on earth = %4.1f y\"%T\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The speed of the aircraft = 1.42e+08 m/s\n", + "The time interval as measured on earth = 18.2 y\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3, Page 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "L0 = 4.30; # Distance of Alpha Centauri from earth, ly\n", + "c = 3e+008; # Speed of light, m/s\n", + "T = 8; # Proper time in system K_prime, y\n", + "\n", + "#Calculations\n", + "# As v/c = L0*sqrt(1-(v/c)^2)/(c*T) or bita = L0*sqrt(1-bita^2)/(c*T), solving for bita\n", + "bita = sqrt(L0**2/(T**2 + L0**2)); # Boost parameter\n", + "v = L0*sqrt(1-bita**2)/T; # Speed of the aircraft, c units\n", + "\n", + "#Results\n", + "print \"The boost parameter = %5.3f\"%bita\n", + "print \"The speed of the aircraft = %5.3fc units\"%v" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The boost parameter = 0.473\n", + "The speed of the aircraft = 0.473c units\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4, Page 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume speed of light to be unity, m/s\n", + "bita = 0.600; # Boost parameter\n", + "gama = 1/sqrt(1-bita**2); # Relativistic factor\n", + "u_x_prime = 0; # Speed of the protons in spaceship frame along x-axis, m/s\n", + "u_y_prime = 0.99*c; # Speed of the protons in spaceship frame along y-axis, m/s\n", + "u_z_prime = 0; # Speed of the protons in spaceship frame along z-axis, m/s\n", + "v = 0.60*c; # Speed of the spaceship w.r.t. space station, m/s\n", + "\n", + "#Calculations\n", + "u_x = (u_x_prime + v)/(1 + v/c**2*u_x_prime); # Speed of protons in space station frame along x-axis, m/s\n", + "u_y = u_y_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", + "u_z = u_z_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", + "u = sqrt(u_x**2 + u_y**2 + u_z**2); # The speed of the protons measured by an observer in the space station, m/s\n", + "\n", + "#Result\n", + "print \"The speed of the protons measured by an observer in the space station = %5.3fc units\"%u" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The speed of the protons measured by an observer in the space station = 0.994c units\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5, Page 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "c = 2.998e+008; # Speed of light in free space, m/s\n", + "v = 7712; # Speed of the space shuttle, m/s\n", + "bita = v/c; # Boost parameter\n", + "T_loss = 295.02; # Total measured loss in time, ps/sec\n", + "Add_T_loss = 35.0; # Additional time loss for moving clock from general relativity prediction, ps/s\n", + "\n", + "#Calculations\n", + "# From time dilation relation, T0_prime = T*sqrt(1 - bita^2), solving for (T - T0_prime)/T\n", + "Calc_T_loss = bita**2/2*1e+012; # Expected time lost per sec by the moving clock, ps/sec\n", + "Measured_T_loss = T_loss + Add_T_loss; # Total measured loss in time per sec as per special relativity, ps/s\n", + "percent_T_loss = (Calc_T_loss - Measured_T_loss)/Calc_T_loss*100; # Percentage deviation of measured and the calculated time loss per sec\n", + "T = 6.05e+05; # Total time of the seven-day mission, s\n", + "delta_T = Calc_T_loss*1e-012*T; # The total time difference between the moving and stationary clocks during the entire shuttle flight, s\n", + "\n", + "#Results\n", + "print \"The expected time lost per second for the moving clock = %6.2f ps\"%Calc_T_loss\n", + "print \"The percentage deviation of measured and the calculated time loss per sec for moving clock = %3.1f percent\"%percent_T_loss #answer differs due to rounding errors\n", + "print \"The total time difference between the moving and stationary clocks during the entire shuttle flight = %3.1f ms\"%(delta_T/1e-003)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The expected time lost per second for the moving clock = 330.86 ps\n", + "The percentage deviation of measured and the calculated time loss per sec for moving clock = 0.3 percent\n", + "The total time difference between the moving and stationary clocks during the entire shuttle flight = 0.2 ms\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8, Page 57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "f0 = 1; # For simplicity assume frequency of the signals sent by Frank, Hz\n", + "# Outbound trip\n", + "bita = -0.8; # Boost parameter for receding frames\n", + "\n", + "#Calculations&Results\n", + "f = sqrt(1+bita)/sqrt(1-bita)*f0; # The frequency of the signals received by Mary in outbound trip, Hz\n", + "print \"The frequency of the signals received by Mary in outbound trip = f0/%d\", ceil(f*9)\n", + "# Return trip\n", + "bita = +0.8; # Boost parameter for approaching frames\n", + "f = sqrt(1+bita)/sqrt(1-bita)*f0; # The frequency of the signals received by Mary in return trip, Hz\n", + "print \"The frequency of the signals received by Mary in return trip = %df0\"%f" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The frequency of the signals received by Mary in outbound trip = f0/%d 3.0\n", + "The frequency of the signals received by Mary in return trip = 3f0\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.11, Page 64" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "q = 1.6e-019; # Charge on an electron, C\n", + "V = 25e+003; # Accelerating potential, volt\n", + "K = q*V; # Kinetic energy of electrons, J\n", + "m = 9.11e-031; # Rest mass of an electron, kg\n", + "c = 3.00e+08; # Speed of light, m/s\n", + "\n", + "#Calculations\n", + "# From relativistic kinetic energy formula, K = (gama - 1)*m*C^2, solving for gama\n", + "gama = 1 + K/(m*c**2); # Relativistic factor\n", + "bita = sqrt((gama**2-1)/gama**2); # Boost parameter\n", + "u = bita*c; # Speed of the electrons, m/s\n", + "# From non-relativistic expression, K = 1/2*m*u^2, solving for u\n", + "u_classical = sqrt(2*K/m); # Non-relativistic speed of the electrons, m/s\n", + "u_error = (u_classical - u)/u_classical*100; # Percentage error in speed of electrons, m/s\n", + "\n", + "#Results\n", + "print \"The relativistic speed of the accelerated electrons = %4.2e m/s\"%u\n", + "print \"The classical speed is about %d percent greater than the relativistic speed\"%ceil(u_error)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The relativistic speed of the accelerated electrons = 9.04e+07 m/s\n", + "The classical speed is about 4 percent greater than the relativistic speed\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13, Page 69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume peed of light to be unity, m/s\n", + "K = 2.00; # Kinetic energy of protons, GeV\n", + "E0 = 0.938; # Rest mass of a proton, GeV\n", + "E = K + E0; # Total energy of the proton, GeV\n", + "\n", + "#Calculations\n", + "# From relativistic mass energy relation, E^2 = (p*c)^2+E0^2, solving for p\n", + "p = sqrt(E**2 - E0**2)/c; # Momentum of the protons, GeV/c\n", + "# As E = gama*E0, solving for gama\n", + "gama = E/E0; # Relativistic factor\n", + "bita = sqrt((gama**2-1)/gama**2); # Boost parameter\n", + "v = bita*3.00e+08; # Speed of 2 GeV proton, m/s\n", + "\n", + "#Results\n", + "print \"The energy of each initial proton = %5.3f GeV\"%E\n", + "print \"The momentum of each initial proton = %4.2f GeV/c\"%p\n", + "print \"The speed of each initial proton = %3.1e m/s\"%v\n", + "print \"The relativistic factor, gama = %4.2f\"%gama\n", + "print \"The boost parameter, beta = %5.3f\"%bita" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy of each initial proton = 2.938 GeV\n", + "The momentum of each initial proton = 2.78 GeV/c\n", + "The speed of each initial proton = 2.8e+08 m/s\n", + "The relativistic factor, gama = 3.13\n", + "The boost parameter, beta = 0.948\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.15, Page 71" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "E_d = 1875.6; # Rest mass energy of the deuterium, MeV\n", + "E_pi = 139.6; # Rest mass energy of the pion, MeV\n", + "E_p = 938.3; # Rest mass energy of the proton, MeV\n", + "\n", + "#Calculation\n", + "K = 1./2*(E_d + E_pi - 2*E_p); # Minimum kinetic energy of the protons, MeV \n", + "\n", + "#Result\n", + "print \"The minimum kinetic energy of the protons = %2d MeV\"%K" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum kinetic energy of the protons = 69 MeV\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.16, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "u = 931.5; # Energy equivalent of 1 amu, MeV\n", + "c = 1; # Speed of light in vacuum, m/s\n", + "\n", + "#Calculations\n", + "m_e = 0.000549*u; # Rest mass of an electron, MeV/c^2\n", + "m_p = 1.007276*u; # Rest mass of a proton, MeV/c^2\n", + "m_n = 1.008665*u; # Rest mass of a neutron, MeV/c^2\n", + "m_He = 4.002603*u; # Rest mass of a helium, MeV/c^2\n", + "M_He = m_He - 2*m_e; # Mass of He nucleus, MeV/c^2\n", + "E_B_He = (2*m_p + 2*m_n - M_He)*c**2; # Binding energy of the He nucleus, MeV\n", + "\n", + "#Result\n", + "print \"The binding energy of the He nucleus = %4.1f MeV\"%E_B_He" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The binding energy of the He nucleus = 28.3 MeV\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.17, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "u = 931.5; # Energy equivalent of 1 amu, MeV/u\n", + "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", + "E_B = 4.24; # The dissociationenergy of the NaCl molecule, MeV\n", + "\n", + "#Calculations\n", + "M = 58.44*u; # Energy corresponding to molecular mass of NaCl, MeV\n", + "f_r = E_B/M; # The fractional mass increase of the Na and Cl atoms\n", + "\n", + "#Result\n", + "print \"The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = %4.1e\"%(f_r/1e+006)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = 7.8e-11\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.18, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from math import *\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", + "E0_n = 940; # Rest energy of a neutron, MeV\n", + "E0_pi = 140; # Rest energy of a pion, MeV\n", + "p_n = 4702; # Momentum of the neutron, MeV/c\n", + "p_pi = 169; # Momentum of the pion, MeV/c\n", + "\n", + "#Calculations\n", + "E_n = sqrt((p_n*c)**2+E0_n**2); # Total energy of the neutron, MeV\n", + "E_pi = sqrt((p_pi*c)**2+E0_pi**2); # Total energy of the pion, MeV\n", + "E = E_n + E_pi; # Total energy of the reaction, MeV\n", + "p_sigma = p_n + p_pi; # Momentum of the sigma particle, MeV/c\n", + "E0_sigma = sqrt(E**2 - (p_sigma*c)**2); # Rest mass energy of the sigma particle, MeV\n", + "m_sigma = E0_sigma/c**2; # Rest mass of sigma particle, MeV/c^2;\n", + "K = E - E0_sigma; # Kinetic energy of sigma particle, MeV\n", + "\n", + "#Results\n", + "print \"The rest mass of sigma particle = %4d MeV/c^2\"%ceil(m_sigma)\n", + "print \"The kinetic energy of sigma particle = %4d MeV\"%ceil(K)\n", + "\n", + "#Answers differ due to rounding errors" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The rest mass of sigma particle = 1192 MeV/c^2\n", + "The kinetic energy of sigma particle = 3824 MeV\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2_1.ipynb b/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2_1.ipynb new file mode 100755 index 00000000..e79c5ef9 --- /dev/null +++ b/sample_notebooks/NirenNegandhi/NirenNegandhi_version_backup/ch2_1.ipynb @@ -0,0 +1,505 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:d53ace7eee908f1b365cd69f5f5bf3b12191ff7d43291af068a8947558149234" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2: Special Theory of Relativity" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2, Page 34" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "ly = 9.46e+015; # Distance travelled by light in an year, m\n", + "c = 3e+008; # Speed of light, m/s\n", + "L = 4.30*ly; # Distance of Alpha Centauri from earth, m\n", + "T0 = 16*365.25*24*60*60; # Proper time in system K_prime, s\n", + "\n", + "#Calculations\n", + "# As time measured on earth, T = 2*L/v = T0_prime/sqrt(1-(v/c)^2), solving for v\n", + "v = math.sqrt(4*L**2/(T0**2+4*L**2/c**2)); # Speed of the aircraft, m/s\n", + "gama = 1/math.sqrt(1-(v/c)**2); # Relativistic factor\n", + "T = gama*T0/(365.25*24*60*60); # Time interval as measured on Earth, y\n", + "\n", + "#Results\n", + "print \"The speed of the aircraft = %4.2e m/s\" %v\n", + "print \"The time interval as measured on earth = %4.1f y\"%T\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The speed of the aircraft = 1.42e+08 m/s\n", + "The time interval as measured on earth = 18.2 y\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3, Page 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "L0 = 4.30; # Distance of Alpha Centauri from earth, ly\n", + "c = 3e+008; # Speed of light, m/s\n", + "T = 8; # Proper time in system K_prime, y\n", + "\n", + "#Calculations\n", + "# As v/c = L0*sqrt(1-(v/c)^2)/(c*T) or bita = L0*sqrt(1-bita^2)/(c*T), solving for bita\n", + "bita = math.sqrt(L0**2/(T**2 + L0**2)); # Boost parameter\n", + "v = L0*math.sqrt(1-bita**2)/T; # Speed of the aircraft, c units\n", + "\n", + "#Results\n", + "print \"The boost parameter = %5.3f\"%bita\n", + "print \"The speed of the aircraft = %5.3fc units\"%v" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The boost parameter = 0.473\n", + "The speed of the aircraft = 0.473c units\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4, Page 40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume speed of light to be unity, m/s\n", + "bita = 0.600; # Boost parameter\n", + "gama = 1/math.sqrt(1-bita**2); # Relativistic factor\n", + "u_x_prime = 0; # Speed of the protons in spaceship frame along x-axis, m/s\n", + "u_y_prime = 0.99*c; # Speed of the protons in spaceship frame along y-axis, m/s\n", + "u_z_prime = 0; # Speed of the protons in spaceship frame along z-axis, m/s\n", + "v = 0.60*c; # Speed of the spaceship w.r.t. space station, m/s\n", + "\n", + "#Calculations\n", + "u_x = (u_x_prime + v)/(1 + v/c**2*u_x_prime); # Speed of protons in space station frame along x-axis, m/s\n", + "u_y = u_y_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", + "u_z = u_z_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", + "u = math.sqrt(u_x**2 + u_y**2 + u_z**2); # The speed of the protons measured by an observer in the space station, m/s\n", + "\n", + "#Result\n", + "print \"The speed of the protons measured by an observer in the space station = %5.3fc units\"%u" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The speed of the protons measured by an observer in the space station = 0.994c units\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5, Page 45" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "c = 2.998e+008; # Speed of light in free space, m/s\n", + "v = 7712; # Speed of the space shuttle, m/s\n", + "bita = v/c; # Boost parameter\n", + "T_loss = 295.02; # Total measured loss in time, ps/sec\n", + "Add_T_loss = 35.0; # Additional time loss for moving clock from general relativity prediction, ps/s\n", + "\n", + "#Calculations\n", + "# From time dilation relation, T0_prime = T*sqrt(1 - bita^2), solving for (T - T0_prime)/T\n", + "Calc_T_loss = bita**2/2*1e+012; # Expected time lost per sec by the moving clock, ps/sec\n", + "Measured_T_loss = T_loss + Add_T_loss; # Total measured loss in time per sec as per special relativity, ps/s\n", + "percent_T_loss = (Calc_T_loss - Measured_T_loss)/Calc_T_loss*100; # Percentage deviation of measured and the calculated time loss per sec\n", + "T = 6.05e+05; # Total time of the seven-day mission, s\n", + "delta_T = Calc_T_loss*1e-012*T; # The total time difference between the moving and stationary clocks during the entire shuttle flight, s\n", + "\n", + "#Results\n", + "print \"The expected time lost per second for the moving clock = %6.2f ps\"%Calc_T_loss\n", + "print \"The percentage deviation of measured and the calculated time loss per sec for moving clock = %3.1f percent\"%percent_T_loss #answer differs due to rounding errors\n", + "print \"The total time difference between the moving and stationary clocks during the entire shuttle flight = %3.1f ms\"%(delta_T/1e-003)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The expected time lost per second for the moving clock = 330.86 ps\n", + "The percentage deviation of measured and the calculated time loss per sec for moving clock = 0.3 percent\n", + "The total time difference between the moving and stationary clocks during the entire shuttle flight = 0.2 ms\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8, Page 57" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "f0 = 1; # For simplicity assume frequency of the signals sent by Frank, Hz\n", + "# Outbound trip\n", + "bita = -0.8; # Boost parameter for receding frames\n", + "\n", + "#Calculations&Results\n", + "f = math.sqrt(1+bita)/math.sqrt(1-bita)*f0; # The frequency of the signals received by Mary in outbound trip, Hz\n", + "print \"The frequency of the signals received by Mary in outbound trip = f0/%d\", math.ceil(f*9)\n", + "# Return trip\n", + "bita = +0.8; # Boost parameter for approaching frames\n", + "f = math.sqrt(1+bita)/math.sqrt(1-bita)*f0; # The frequency of the signals received by Mary in return trip, Hz\n", + "print \"The frequency of the signals received by Mary in return trip = %df0\"%f" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The frequency of the signals received by Mary in outbound trip = f0/%d 3.0\n", + "The frequency of the signals received by Mary in return trip = 3f0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.11, Page 64" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "q = 1.6e-019; # Charge on an electron, C\n", + "V = 25e+003; # Accelerating potential, volt\n", + "K = q*V; # Kinetic energy of electrons, J\n", + "m = 9.11e-031; # Rest mass of an electron, kg\n", + "c = 3.00e+08; # Speed of light, m/s\n", + "\n", + "#Calculations\n", + "# From relativistic kinetic energy formula, K = (gama - 1)*m*C^2, solving for gama\n", + "gama = 1 + K/(m*c**2); # Relativistic factor\n", + "bita = math.sqrt((gama**2-1)/gama**2); # Boost parameter\n", + "u = bita*c; # Speed of the electrons, m/s\n", + "# From non-relativistic expression, K = 1/2*m*u^2, solving for u\n", + "u_classical = math.sqrt(2*K/m); # Non-relativistic speed of the electrons, m/s\n", + "u_error = (u_classical - u)/u_classical*100; # Percentage error in speed of electrons, m/s\n", + "\n", + "#Results\n", + "print \"The relativistic speed of the accelerated electrons = %4.2e m/s\"%u\n", + "print \"The classical speed is about %d percent greater than the relativistic speed\"%math.ceil(u_error)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The relativistic speed of the accelerated electrons = 9.04e+07 m/s\n", + "The classical speed is about 4 percent greater than the relativistic speed\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13, Page 69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume peed of light to be unity, m/s\n", + "K = 2.00; # Kinetic energy of protons, GeV\n", + "E0 = 0.938; # Rest mass of a proton, GeV\n", + "E = K + E0; # Total energy of the proton, GeV\n", + "\n", + "#Calculations\n", + "# From relativistic mass energy relation, E^2 = (p*c)^2+E0^2, solving for p\n", + "p = math.sqrt(E**2 - E0**2)/c; # Momentum of the protons, GeV/c\n", + "# As E = gama*E0, solving for gama\n", + "gama = E/E0; # Relativistic factor\n", + "bita = math.sqrt((gama**2-1)/gama**2); # Boost parameter\n", + "v = bita*3.00e+08; # Speed of 2 GeV proton, m/s\n", + "\n", + "#Results\n", + "print \"The energy of each initial proton = %5.3f GeV\"%E\n", + "print \"The momentum of each initial proton = %4.2f GeV/c\"%p\n", + "print \"The speed of each initial proton = %3.1e m/s\"%v\n", + "print \"The relativistic factor, gama = %4.2f\"%gama\n", + "print \"The boost parameter, beta = %5.3f\"%bita" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The energy of each initial proton = 2.938 GeV\n", + "The momentum of each initial proton = 2.78 GeV/c\n", + "The speed of each initial proton = 2.8e+08 m/s\n", + "The relativistic factor, gama = 3.13\n", + "The boost parameter, beta = 0.948\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.15, Page 71" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "E_d = 1875.6; # Rest mass energy of the deuterium, MeV\n", + "E_pi = 139.6; # Rest mass energy of the pion, MeV\n", + "E_p = 938.3; # Rest mass energy of the proton, MeV\n", + "\n", + "#Calculation\n", + "K = 1./2*(E_d + E_pi - 2*E_p); # Minimum kinetic energy of the protons, MeV \n", + "\n", + "#Result\n", + "print \"The minimum kinetic energy of the protons = %2d MeV\"%K" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The minimum kinetic energy of the protons = 69 MeV\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.16, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "u = 931.5; # Energy equivalent of 1 amu, MeV\n", + "c = 1; # Speed of light in vacuum, m/s\n", + "\n", + "#Calculations\n", + "m_e = 0.000549*u; # Rest mass of an electron, MeV/c^2\n", + "m_p = 1.007276*u; # Rest mass of a proton, MeV/c^2\n", + "m_n = 1.008665*u; # Rest mass of a neutron, MeV/c^2\n", + "m_He = 4.002603*u; # Rest mass of a helium, MeV/c^2\n", + "M_He = m_He - 2*m_e; # Mass of He nucleus, MeV/c^2\n", + "E_B_He = (2*m_p + 2*m_n - M_He)*c**2; # Binding energy of the He nucleus, MeV\n", + "\n", + "#Result\n", + "print \"The binding energy of the He nucleus = %4.1f MeV\"%E_B_He" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The binding energy of the He nucleus = 28.3 MeV\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.17, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Variable declaration\n", + "u = 931.5; # Energy equivalent of 1 amu, MeV/u\n", + "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", + "E_B = 4.24; # The dissociationenergy of the NaCl molecule, MeV\n", + "\n", + "#Calculations\n", + "M = 58.44*u; # Energy corresponding to molecular mass of NaCl, MeV\n", + "f_r = E_B/M; # The fractional mass increase of the Na and Cl atoms\n", + "\n", + "#Result\n", + "print \"The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = %4.1e\"%(f_r/1e+006)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = 7.8e-11\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.18, Page 72" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Variable declaration\n", + "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", + "E0_n = 940; # Rest energy of a neutron, MeV\n", + "E0_pi = 140; # Rest energy of a pion, MeV\n", + "p_n = 4702; # Momentum of the neutron, MeV/c\n", + "p_pi = 169; # Momentum of the pion, MeV/c\n", + "\n", + "#Calculations\n", + "E_n = math.sqrt((p_n*c)**2+E0_n**2); # Total energy of the neutron, MeV\n", + "E_pi = math.sqrt((p_pi*c)**2+E0_pi**2); # Total energy of the pion, MeV\n", + "E = E_n + E_pi; # Total energy of the reaction, MeV\n", + "p_sigma = p_n + p_pi; # Momentum of the sigma particle, MeV/c\n", + "E0_sigma = math.sqrt(E**2 - (p_sigma*c)**2); # Rest mass energy of the sigma particle, MeV\n", + "m_sigma = E0_sigma/c**2; # Rest mass of sigma particle, MeV/c^2;\n", + "K = E - E0_sigma; # Kinetic energy of sigma particle, MeV\n", + "\n", + "#Results\n", + "print \"The rest mass of sigma particle = %4d MeV/c^2\"%math.ceil(m_sigma)\n", + "print \"The kinetic energy of sigma particle = %4d MeV\"%math.ceil(K)\n", + "\n", + "#Answers differ due to rounding errors" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The rest mass of sigma particle = 1192 MeV/c^2\n", + "The kinetic energy of sigma particle = 3824 MeV\n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NirenNegandhi/ch2.ipynb b/sample_notebooks/NirenNegandhi/ch2.ipynb deleted file mode 100755 index 78fcb8ea..00000000 --- a/sample_notebooks/NirenNegandhi/ch2.ipynb +++ /dev/null @@ -1,507 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:8949f832de7d3f263ae07355a00ea5a20f907aff9cf98c80b9a9488be44e93f7" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2: Special Theory of Relativity" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2, Page 34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "ly = 9.46e+015; # Distance travelled by light in an year, m\n", - "c = 3e+008; # Speed of light, m/s\n", - "L = 4.30*ly; # Distance of Alpha Centauri from earth, m\n", - "T0 = 16*365.25*24*60*60; # Proper time in system K_prime, s\n", - "\n", - "#Calculations\n", - "# As time measured on earth, T = 2*L/v = T0_prime/sqrt(1-(v/c)^2), solving for v\n", - "v = sqrt(4*L**2/(T0**2+4*L**2/c**2)); # Speed of the aircraft, m/s\n", - "gama = 1/sqrt(1-(v/c)**2); # Relativistic factor\n", - "T = gama*T0/(365.25*24*60*60); # Time interval as measured on Earth, y\n", - "\n", - "#Results\n", - "print \"The speed of the aircraft = %4.2e m/s\" %v\n", - "print \"The time interval as measured on earth = %4.1f y\"%T\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The speed of the aircraft = 1.42e+08 m/s\n", - "The time interval as measured on earth = 18.2 y\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3, Page 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "L0 = 4.30; # Distance of Alpha Centauri from earth, ly\n", - "c = 3e+008; # Speed of light, m/s\n", - "T = 8; # Proper time in system K_prime, y\n", - "\n", - "#Calculations\n", - "# As v/c = L0*sqrt(1-(v/c)^2)/(c*T) or bita = L0*sqrt(1-bita^2)/(c*T), solving for bita\n", - "bita = sqrt(L0**2/(T**2 + L0**2)); # Boost parameter\n", - "v = L0*sqrt(1-bita**2)/T; # Speed of the aircraft, c units\n", - "\n", - "#Results\n", - "print \"The boost parameter = %5.3f\"%bita\n", - "print \"The speed of the aircraft = %5.3fc units\"%v" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The boost parameter = 0.473\n", - "The speed of the aircraft = 0.473c units\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4, Page 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume speed of light to be unity, m/s\n", - "bita = 0.600; # Boost parameter\n", - "gama = 1/sqrt(1-bita**2); # Relativistic factor\n", - "u_x_prime = 0; # Speed of the protons in spaceship frame along x-axis, m/s\n", - "u_y_prime = 0.99*c; # Speed of the protons in spaceship frame along y-axis, m/s\n", - "u_z_prime = 0; # Speed of the protons in spaceship frame along z-axis, m/s\n", - "v = 0.60*c; # Speed of the spaceship w.r.t. space station, m/s\n", - "\n", - "#Calculations\n", - "u_x = (u_x_prime + v)/(1 + v/c**2*u_x_prime); # Speed of protons in space station frame along x-axis, m/s\n", - "u_y = u_y_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", - "u_z = u_z_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", - "u = sqrt(u_x**2 + u_y**2 + u_z**2); # The speed of the protons measured by an observer in the space station, m/s\n", - "\n", - "#Result\n", - "print \"The speed of the protons measured by an observer in the space station = %5.3fc units\"%u" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The speed of the protons measured by an observer in the space station = 0.994c units\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5, Page 45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "c = 2.998e+008; # Speed of light in free space, m/s\n", - "v = 7712; # Speed of the space shuttle, m/s\n", - "bita = v/c; # Boost parameter\n", - "T_loss = 295.02; # Total measured loss in time, ps/sec\n", - "Add_T_loss = 35.0; # Additional time loss for moving clock from general relativity prediction, ps/s\n", - "\n", - "#Calculations\n", - "# From time dilation relation, T0_prime = T*sqrt(1 - bita^2), solving for (T - T0_prime)/T\n", - "Calc_T_loss = bita**2/2*1e+012; # Expected time lost per sec by the moving clock, ps/sec\n", - "Measured_T_loss = T_loss + Add_T_loss; # Total measured loss in time per sec as per special relativity, ps/s\n", - "percent_T_loss = (Calc_T_loss - Measured_T_loss)/Calc_T_loss*100; # Percentage deviation of measured and the calculated time loss per sec\n", - "T = 6.05e+05; # Total time of the seven-day mission, s\n", - "delta_T = Calc_T_loss*1e-012*T; # The total time difference between the moving and stationary clocks during the entire shuttle flight, s\n", - "\n", - "#Results\n", - "print \"The expected time lost per second for the moving clock = %6.2f ps\"%Calc_T_loss\n", - "print \"The percentage deviation of measured and the calculated time loss per sec for moving clock = %3.1f percent\"%percent_T_loss #answer differs due to rounding errors\n", - "print \"The total time difference between the moving and stationary clocks during the entire shuttle flight = %3.1f ms\"%(delta_T/1e-003)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The expected time lost per second for the moving clock = 330.86 ps\n", - "The percentage deviation of measured and the calculated time loss per sec for moving clock = 0.3 percent\n", - "The total time difference between the moving and stationary clocks during the entire shuttle flight = 0.2 ms\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8, Page 57" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "f0 = 1; # For simplicity assume frequency of the signals sent by Frank, Hz\n", - "# Outbound trip\n", - "bita = -0.8; # Boost parameter for receding frames\n", - "\n", - "#Calculations&Results\n", - "f = sqrt(1+bita)/sqrt(1-bita)*f0; # The frequency of the signals received by Mary in outbound trip, Hz\n", - "print \"The frequency of the signals received by Mary in outbound trip = f0/%d\", ceil(f*9)\n", - "# Return trip\n", - "bita = +0.8; # Boost parameter for approaching frames\n", - "f = sqrt(1+bita)/sqrt(1-bita)*f0; # The frequency of the signals received by Mary in return trip, Hz\n", - "print \"The frequency of the signals received by Mary in return trip = %df0\"%f" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The frequency of the signals received by Mary in outbound trip = f0/%d 3.0\n", - "The frequency of the signals received by Mary in return trip = 3f0\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.11, Page 64" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "q = 1.6e-019; # Charge on an electron, C\n", - "V = 25e+003; # Accelerating potential, volt\n", - "K = q*V; # Kinetic energy of electrons, J\n", - "m = 9.11e-031; # Rest mass of an electron, kg\n", - "c = 3.00e+08; # Speed of light, m/s\n", - "\n", - "#Calculations\n", - "# From relativistic kinetic energy formula, K = (gama - 1)*m*C^2, solving for gama\n", - "gama = 1 + K/(m*c**2); # Relativistic factor\n", - "bita = sqrt((gama**2-1)/gama**2); # Boost parameter\n", - "u = bita*c; # Speed of the electrons, m/s\n", - "# From non-relativistic expression, K = 1/2*m*u^2, solving for u\n", - "u_classical = sqrt(2*K/m); # Non-relativistic speed of the electrons, m/s\n", - "u_error = (u_classical - u)/u_classical*100; # Percentage error in speed of electrons, m/s\n", - "\n", - "#Results\n", - "print \"The relativistic speed of the accelerated electrons = %4.2e m/s\"%u\n", - "print \"The classical speed is about %d percent greater than the relativistic speed\"%ceil(u_error)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The relativistic speed of the accelerated electrons = 9.04e+07 m/s\n", - "The classical speed is about 4 percent greater than the relativistic speed\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.13, Page 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume peed of light to be unity, m/s\n", - "K = 2.00; # Kinetic energy of protons, GeV\n", - "E0 = 0.938; # Rest mass of a proton, GeV\n", - "E = K + E0; # Total energy of the proton, GeV\n", - "\n", - "#Calculations\n", - "# From relativistic mass energy relation, E^2 = (p*c)^2+E0^2, solving for p\n", - "p = sqrt(E**2 - E0**2)/c; # Momentum of the protons, GeV/c\n", - "# As E = gama*E0, solving for gama\n", - "gama = E/E0; # Relativistic factor\n", - "bita = sqrt((gama**2-1)/gama**2); # Boost parameter\n", - "v = bita*3.00e+08; # Speed of 2 GeV proton, m/s\n", - "\n", - "#Results\n", - "print \"The energy of each initial proton = %5.3f GeV\"%E\n", - "print \"The momentum of each initial proton = %4.2f GeV/c\"%p\n", - "print \"The speed of each initial proton = %3.1e m/s\"%v\n", - "print \"The relativistic factor, gama = %4.2f\"%gama\n", - "print \"The boost parameter, beta = %5.3f\"%bita" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The energy of each initial proton = 2.938 GeV\n", - "The momentum of each initial proton = 2.78 GeV/c\n", - "The speed of each initial proton = 2.8e+08 m/s\n", - "The relativistic factor, gama = 3.13\n", - "The boost parameter, beta = 0.948\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.15, Page 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "E_d = 1875.6; # Rest mass energy of the deuterium, MeV\n", - "E_pi = 139.6; # Rest mass energy of the pion, MeV\n", - "E_p = 938.3; # Rest mass energy of the proton, MeV\n", - "\n", - "#Calculation\n", - "K = 1./2*(E_d + E_pi - 2*E_p); # Minimum kinetic energy of the protons, MeV \n", - "\n", - "#Result\n", - "print \"The minimum kinetic energy of the protons = %2d MeV\"%K" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The minimum kinetic energy of the protons = 69 MeV\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.16, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "u = 931.5; # Energy equivalent of 1 amu, MeV\n", - "c = 1; # Speed of light in vacuum, m/s\n", - "\n", - "#Calculations\n", - "m_e = 0.000549*u; # Rest mass of an electron, MeV/c^2\n", - "m_p = 1.007276*u; # Rest mass of a proton, MeV/c^2\n", - "m_n = 1.008665*u; # Rest mass of a neutron, MeV/c^2\n", - "m_He = 4.002603*u; # Rest mass of a helium, MeV/c^2\n", - "M_He = m_He - 2*m_e; # Mass of He nucleus, MeV/c^2\n", - "E_B_He = (2*m_p + 2*m_n - M_He)*c**2; # Binding energy of the He nucleus, MeV\n", - "\n", - "#Result\n", - "print \"The binding energy of the He nucleus = %4.1f MeV\"%E_B_He" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The binding energy of the He nucleus = 28.3 MeV\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.17, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "u = 931.5; # Energy equivalent of 1 amu, MeV/u\n", - "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", - "E_B = 4.24; # The dissociationenergy of the NaCl molecule, MeV\n", - "\n", - "#Calculations\n", - "M = 58.44*u; # Energy corresponding to molecular mass of NaCl, MeV\n", - "f_r = E_B/M; # The fractional mass increase of the Na and Cl atoms\n", - "\n", - "#Result\n", - "print \"The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = %4.1e\"%(f_r/1e+006)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = 7.8e-11\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.18, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from math import *\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", - "E0_n = 940; # Rest energy of a neutron, MeV\n", - "E0_pi = 140; # Rest energy of a pion, MeV\n", - "p_n = 4702; # Momentum of the neutron, MeV/c\n", - "p_pi = 169; # Momentum of the pion, MeV/c\n", - "\n", - "#Calculations\n", - "E_n = sqrt((p_n*c)**2+E0_n**2); # Total energy of the neutron, MeV\n", - "E_pi = sqrt((p_pi*c)**2+E0_pi**2); # Total energy of the pion, MeV\n", - "E = E_n + E_pi; # Total energy of the reaction, MeV\n", - "p_sigma = p_n + p_pi; # Momentum of the sigma particle, MeV/c\n", - "E0_sigma = sqrt(E**2 - (p_sigma*c)**2); # Rest mass energy of the sigma particle, MeV\n", - "m_sigma = E0_sigma/c**2; # Rest mass of sigma particle, MeV/c^2;\n", - "K = E - E0_sigma; # Kinetic energy of sigma particle, MeV\n", - "\n", - "#Results\n", - "print \"The rest mass of sigma particle = %4d MeV/c^2\"%ceil(m_sigma)\n", - "print \"The kinetic energy of sigma particle = %4d MeV\"%ceil(K)\n", - "\n", - "#Answers differ due to rounding errors" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The rest mass of sigma particle = 1192 MeV/c^2\n", - "The kinetic energy of sigma particle = 3824 MeV\n" - ] - } - ], - "prompt_number": 12 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NirenNegandhi/ch2_1.ipynb b/sample_notebooks/NirenNegandhi/ch2_1.ipynb deleted file mode 100755 index e79c5ef9..00000000 --- a/sample_notebooks/NirenNegandhi/ch2_1.ipynb +++ /dev/null @@ -1,505 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:d53ace7eee908f1b365cd69f5f5bf3b12191ff7d43291af068a8947558149234" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2: Special Theory of Relativity" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2, Page 34" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "ly = 9.46e+015; # Distance travelled by light in an year, m\n", - "c = 3e+008; # Speed of light, m/s\n", - "L = 4.30*ly; # Distance of Alpha Centauri from earth, m\n", - "T0 = 16*365.25*24*60*60; # Proper time in system K_prime, s\n", - "\n", - "#Calculations\n", - "# As time measured on earth, T = 2*L/v = T0_prime/sqrt(1-(v/c)^2), solving for v\n", - "v = math.sqrt(4*L**2/(T0**2+4*L**2/c**2)); # Speed of the aircraft, m/s\n", - "gama = 1/math.sqrt(1-(v/c)**2); # Relativistic factor\n", - "T = gama*T0/(365.25*24*60*60); # Time interval as measured on Earth, y\n", - "\n", - "#Results\n", - "print \"The speed of the aircraft = %4.2e m/s\" %v\n", - "print \"The time interval as measured on earth = %4.1f y\"%T\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The speed of the aircraft = 1.42e+08 m/s\n", - "The time interval as measured on earth = 18.2 y\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3, Page 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "L0 = 4.30; # Distance of Alpha Centauri from earth, ly\n", - "c = 3e+008; # Speed of light, m/s\n", - "T = 8; # Proper time in system K_prime, y\n", - "\n", - "#Calculations\n", - "# As v/c = L0*sqrt(1-(v/c)^2)/(c*T) or bita = L0*sqrt(1-bita^2)/(c*T), solving for bita\n", - "bita = math.sqrt(L0**2/(T**2 + L0**2)); # Boost parameter\n", - "v = L0*math.sqrt(1-bita**2)/T; # Speed of the aircraft, c units\n", - "\n", - "#Results\n", - "print \"The boost parameter = %5.3f\"%bita\n", - "print \"The speed of the aircraft = %5.3fc units\"%v" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The boost parameter = 0.473\n", - "The speed of the aircraft = 0.473c units\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4, Page 40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume speed of light to be unity, m/s\n", - "bita = 0.600; # Boost parameter\n", - "gama = 1/math.sqrt(1-bita**2); # Relativistic factor\n", - "u_x_prime = 0; # Speed of the protons in spaceship frame along x-axis, m/s\n", - "u_y_prime = 0.99*c; # Speed of the protons in spaceship frame along y-axis, m/s\n", - "u_z_prime = 0; # Speed of the protons in spaceship frame along z-axis, m/s\n", - "v = 0.60*c; # Speed of the spaceship w.r.t. space station, m/s\n", - "\n", - "#Calculations\n", - "u_x = (u_x_prime + v)/(1 + v/c**2*u_x_prime); # Speed of protons in space station frame along x-axis, m/s\n", - "u_y = u_y_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", - "u_z = u_z_prime/(gama*(1 + v/c**2*u_x_prime)); # Speed of protons in space station frame along y-axis, m/s\n", - "u = math.sqrt(u_x**2 + u_y**2 + u_z**2); # The speed of the protons measured by an observer in the space station, m/s\n", - "\n", - "#Result\n", - "print \"The speed of the protons measured by an observer in the space station = %5.3fc units\"%u" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The speed of the protons measured by an observer in the space station = 0.994c units\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5, Page 45" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "c = 2.998e+008; # Speed of light in free space, m/s\n", - "v = 7712; # Speed of the space shuttle, m/s\n", - "bita = v/c; # Boost parameter\n", - "T_loss = 295.02; # Total measured loss in time, ps/sec\n", - "Add_T_loss = 35.0; # Additional time loss for moving clock from general relativity prediction, ps/s\n", - "\n", - "#Calculations\n", - "# From time dilation relation, T0_prime = T*sqrt(1 - bita^2), solving for (T - T0_prime)/T\n", - "Calc_T_loss = bita**2/2*1e+012; # Expected time lost per sec by the moving clock, ps/sec\n", - "Measured_T_loss = T_loss + Add_T_loss; # Total measured loss in time per sec as per special relativity, ps/s\n", - "percent_T_loss = (Calc_T_loss - Measured_T_loss)/Calc_T_loss*100; # Percentage deviation of measured and the calculated time loss per sec\n", - "T = 6.05e+05; # Total time of the seven-day mission, s\n", - "delta_T = Calc_T_loss*1e-012*T; # The total time difference between the moving and stationary clocks during the entire shuttle flight, s\n", - "\n", - "#Results\n", - "print \"The expected time lost per second for the moving clock = %6.2f ps\"%Calc_T_loss\n", - "print \"The percentage deviation of measured and the calculated time loss per sec for moving clock = %3.1f percent\"%percent_T_loss #answer differs due to rounding errors\n", - "print \"The total time difference between the moving and stationary clocks during the entire shuttle flight = %3.1f ms\"%(delta_T/1e-003)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The expected time lost per second for the moving clock = 330.86 ps\n", - "The percentage deviation of measured and the calculated time loss per sec for moving clock = 0.3 percent\n", - "The total time difference between the moving and stationary clocks during the entire shuttle flight = 0.2 ms\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8, Page 57" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "f0 = 1; # For simplicity assume frequency of the signals sent by Frank, Hz\n", - "# Outbound trip\n", - "bita = -0.8; # Boost parameter for receding frames\n", - "\n", - "#Calculations&Results\n", - "f = math.sqrt(1+bita)/math.sqrt(1-bita)*f0; # The frequency of the signals received by Mary in outbound trip, Hz\n", - "print \"The frequency of the signals received by Mary in outbound trip = f0/%d\", math.ceil(f*9)\n", - "# Return trip\n", - "bita = +0.8; # Boost parameter for approaching frames\n", - "f = math.sqrt(1+bita)/math.sqrt(1-bita)*f0; # The frequency of the signals received by Mary in return trip, Hz\n", - "print \"The frequency of the signals received by Mary in return trip = %df0\"%f" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The frequency of the signals received by Mary in outbound trip = f0/%d 3.0\n", - "The frequency of the signals received by Mary in return trip = 3f0\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.11, Page 64" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "q = 1.6e-019; # Charge on an electron, C\n", - "V = 25e+003; # Accelerating potential, volt\n", - "K = q*V; # Kinetic energy of electrons, J\n", - "m = 9.11e-031; # Rest mass of an electron, kg\n", - "c = 3.00e+08; # Speed of light, m/s\n", - "\n", - "#Calculations\n", - "# From relativistic kinetic energy formula, K = (gama - 1)*m*C^2, solving for gama\n", - "gama = 1 + K/(m*c**2); # Relativistic factor\n", - "bita = math.sqrt((gama**2-1)/gama**2); # Boost parameter\n", - "u = bita*c; # Speed of the electrons, m/s\n", - "# From non-relativistic expression, K = 1/2*m*u^2, solving for u\n", - "u_classical = math.sqrt(2*K/m); # Non-relativistic speed of the electrons, m/s\n", - "u_error = (u_classical - u)/u_classical*100; # Percentage error in speed of electrons, m/s\n", - "\n", - "#Results\n", - "print \"The relativistic speed of the accelerated electrons = %4.2e m/s\"%u\n", - "print \"The classical speed is about %d percent greater than the relativistic speed\"%math.ceil(u_error)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The relativistic speed of the accelerated electrons = 9.04e+07 m/s\n", - "The classical speed is about 4 percent greater than the relativistic speed\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.13, Page 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume peed of light to be unity, m/s\n", - "K = 2.00; # Kinetic energy of protons, GeV\n", - "E0 = 0.938; # Rest mass of a proton, GeV\n", - "E = K + E0; # Total energy of the proton, GeV\n", - "\n", - "#Calculations\n", - "# From relativistic mass energy relation, E^2 = (p*c)^2+E0^2, solving for p\n", - "p = math.sqrt(E**2 - E0**2)/c; # Momentum of the protons, GeV/c\n", - "# As E = gama*E0, solving for gama\n", - "gama = E/E0; # Relativistic factor\n", - "bita = math.sqrt((gama**2-1)/gama**2); # Boost parameter\n", - "v = bita*3.00e+08; # Speed of 2 GeV proton, m/s\n", - "\n", - "#Results\n", - "print \"The energy of each initial proton = %5.3f GeV\"%E\n", - "print \"The momentum of each initial proton = %4.2f GeV/c\"%p\n", - "print \"The speed of each initial proton = %3.1e m/s\"%v\n", - "print \"The relativistic factor, gama = %4.2f\"%gama\n", - "print \"The boost parameter, beta = %5.3f\"%bita" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The energy of each initial proton = 2.938 GeV\n", - "The momentum of each initial proton = 2.78 GeV/c\n", - "The speed of each initial proton = 2.8e+08 m/s\n", - "The relativistic factor, gama = 3.13\n", - "The boost parameter, beta = 0.948\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.15, Page 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "E_d = 1875.6; # Rest mass energy of the deuterium, MeV\n", - "E_pi = 139.6; # Rest mass energy of the pion, MeV\n", - "E_p = 938.3; # Rest mass energy of the proton, MeV\n", - "\n", - "#Calculation\n", - "K = 1./2*(E_d + E_pi - 2*E_p); # Minimum kinetic energy of the protons, MeV \n", - "\n", - "#Result\n", - "print \"The minimum kinetic energy of the protons = %2d MeV\"%K" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The minimum kinetic energy of the protons = 69 MeV\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.16, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "u = 931.5; # Energy equivalent of 1 amu, MeV\n", - "c = 1; # Speed of light in vacuum, m/s\n", - "\n", - "#Calculations\n", - "m_e = 0.000549*u; # Rest mass of an electron, MeV/c^2\n", - "m_p = 1.007276*u; # Rest mass of a proton, MeV/c^2\n", - "m_n = 1.008665*u; # Rest mass of a neutron, MeV/c^2\n", - "m_He = 4.002603*u; # Rest mass of a helium, MeV/c^2\n", - "M_He = m_He - 2*m_e; # Mass of He nucleus, MeV/c^2\n", - "E_B_He = (2*m_p + 2*m_n - M_He)*c**2; # Binding energy of the He nucleus, MeV\n", - "\n", - "#Result\n", - "print \"The binding energy of the He nucleus = %4.1f MeV\"%E_B_He" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The binding energy of the He nucleus = 28.3 MeV\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.17, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Variable declaration\n", - "u = 931.5; # Energy equivalent of 1 amu, MeV/u\n", - "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", - "E_B = 4.24; # The dissociationenergy of the NaCl molecule, MeV\n", - "\n", - "#Calculations\n", - "M = 58.44*u; # Energy corresponding to molecular mass of NaCl, MeV\n", - "f_r = E_B/M; # The fractional mass increase of the Na and Cl atoms\n", - "\n", - "#Result\n", - "print \"The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = %4.1e\"%(f_r/1e+006)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The fractional mass increase of the Na and Cl atoms when they are not bound together in NaCl = 7.8e-11\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.18, Page 72" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Variable declaration\n", - "c = 1; # For simplicity assume speed of light in vacuum to be unity, m/s\n", - "E0_n = 940; # Rest energy of a neutron, MeV\n", - "E0_pi = 140; # Rest energy of a pion, MeV\n", - "p_n = 4702; # Momentum of the neutron, MeV/c\n", - "p_pi = 169; # Momentum of the pion, MeV/c\n", - "\n", - "#Calculations\n", - "E_n = math.sqrt((p_n*c)**2+E0_n**2); # Total energy of the neutron, MeV\n", - "E_pi = math.sqrt((p_pi*c)**2+E0_pi**2); # Total energy of the pion, MeV\n", - "E = E_n + E_pi; # Total energy of the reaction, MeV\n", - "p_sigma = p_n + p_pi; # Momentum of the sigma particle, MeV/c\n", - "E0_sigma = math.sqrt(E**2 - (p_sigma*c)**2); # Rest mass energy of the sigma particle, MeV\n", - "m_sigma = E0_sigma/c**2; # Rest mass of sigma particle, MeV/c^2;\n", - "K = E - E0_sigma; # Kinetic energy of sigma particle, MeV\n", - "\n", - "#Results\n", - "print \"The rest mass of sigma particle = %4d MeV/c^2\"%math.ceil(m_sigma)\n", - "print \"The kinetic energy of sigma particle = %4d MeV\"%math.ceil(K)\n", - "\n", - "#Answers differ due to rounding errors" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The rest mass of sigma particle = 1192 MeV/c^2\n", - "The kinetic energy of sigma particle = 3824 MeV\n" - ] - } - ], - "prompt_number": 10 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb deleted file mode 100755 index a7c3a90a..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:da354bb89e19562e65167a0447837d31b8126b13ef9a65d132ea4ce7ac74a2e3" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no:208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb b/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb deleted file mode 100755 index 7eb86cba..00000000 --- a/sample_notebooks/NitamoniDas/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb new file mode 100755 index 00000000..a7c3a90a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:da354bb89e19562e65167a0447837d31b8126b13ef9a65d132ea4ce7ac74a2e3" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no:208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_1.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_2.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_3.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_4.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb new file mode 100755 index 00000000..7eb86cba --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/Chapter_8_Data_Abstraction_through_Classes_and_User_Defined_Data_Types_5.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:cceaf517d4ab644356e85522addd8c655c7a27bbc143387c58a9d5656be364df" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb new file mode 100755 index 00000000..1083b19a --- /dev/null +++ b/sample_notebooks/NitamoniDas/NitamoniDas_version_backup/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb @@ -0,0 +1,809 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.1, page no: 208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Super:\n", + " def __init__(self):\n", + " self.__IntegerData=None #private member\n", + " #public functions\n", + " def SetData(self,i):\n", + " self.__IntegerData=i #refer to IntegerData\n", + " def ShowData(self):\n", + " print \"Data is \",self.__IntegerData,' '\n", + "\n", + "ob1=Super()\n", + "ob2=Super()\n", + "ob1.SetData(1000)\n", + "ob2.SetData(2000)\n", + "ob1.ShowData()\n", + "ob2.ShowData()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Data is 1000 \n", + "Data is 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.2, page no:211" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " def __init__(self):\n", + " self.a=None #private members\n", + " self.b=None #private members\n", + " \n", + "#no structure type present in python \n", + "x = X()\n", + "\n", + "x.a=0\n", + "x.b=1\n", + "print \"x.a=\",x.a,\",x.b=\",x.b" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "x.a= 0 ,x.b= 1\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.3, page no:214" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def SetValue(self,a,b): #public functions\n", + " self.__num=a \n", + " self.__denom=b \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 3 4\n", + "Numerator value set: 3\n", + "Denominator value set: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.4, page no:216" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " def __init__(self):\n", + " self.__i=None #private member\n", + " \n", + " def __init__(self):\n", + " self.__i=500 #constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__i=d\n", + " \n", + " def GetData(self):\n", + " return self.__i\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "print \"s1 has data: \",s1.GetData()\n", + "print \"s2 has data: \",s2.GetData()\n", + "s1.SetData(1000) #function call\n", + "s2.SetData(2000)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \", s2.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500\n", + "s2 has data: 500\n", + "s1 has data: 1000 \n", + "s2 has data: 2000 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.5, page no:217" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class SimpleClass:\n", + " __IntegerData=None\n", + " def __init__(self,data=None):\n", + " if data==None:\n", + " self.__IntegerData=500 #default constructor\n", + " else:\n", + " self.__IntegerData=data #parameterised constructor\n", + " \n", + " def SetData(self,d):\n", + " self.__IntegerData=d\n", + " \n", + " def GetData(self):\n", + " return self.__IntegerData\n", + " \n", + "#Initializing\n", + "s1=SimpleClass()\n", + "s2=SimpleClass()\n", + "s3=SimpleClass(400)\n", + "s4=SimpleClass(600)\n", + "print \"s1 has data: \",s1.GetData(),' '\n", + "print \"s2 has data: \",s2.GetData(),' '\n", + "print \"s3 has data: \",s3.GetData(),' '\n", + "print \"s4 has data: \",s4.GetData(),' '\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "s1 has data: 500 \n", + "s2 has data: 500 \n", + "s3 has data: 400 \n", + "s4 has data: 600 \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.6, page no:218" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction: \n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " def __init__(self,a=0,b=1):\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor\",' ',n\n", + " print \"Denominator set inside constructor\",' ',d\n", + " \n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b\n", + " def GetValue(self,a,b):\n", + " a= self.__num\n", + " b= self.__denom\n", + " return a,b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter value of numerator and denominator: \",' ',n,d\n", + "f=Fraction(n,d)\n", + "f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter value of numerator and denominator: 3 4\n", + "Numerator set inside constructor 3\n", + "Denominator set inside constructor 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.7, page no:221" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " print \"Numerator set inside constructor: \",self.__num\n", + " print \"Denominator set inside constructor: \",self.__denom \n", + " \n", + " def GetValue(self,a,b):\n", + " return self.__num,self.__denom\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"Please enter the value of the numerator and denominator: \",n,d\n", + "f=Fraction(n,d)\n", + "n,d=f.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "n=input(\"Please enter the value of numerator only: \")\n", + "f1=Fraction(n)\n", + "n,d=f1.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print 'ok..now I will create a fraction-no input please'\n", + "f2=Fraction()\n", + "n,d=f2.GetValue(n,d)\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of the numerator and denominator: 3 4\n", + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 4\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter the value of numerator only: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Numerator set inside constructor: 3\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 3\n", + "Denominator value retrieved: 1\n", + "ok..now I will create a fraction-no input please\n", + "Numerator set inside constructor: 0\n", + "Denominator set inside constructor: 1\n", + "Numerator value retrieved: 0\n", + "Denominator value retrieved: 1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.8, page no:223" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " def_init_num=None #private members\n", + " def_init_denom=None #private members\n", + " \n", + " def __init__(self,anotherFraction=None): \n", + " if anotherFraction==None: #normal constructor\n", + " self.__num=anotherFraction\n", + " self.__denom=anotherFraction\n", + " else: #copy constructor\n", + " self.__num=anotherFraction.self.__num\n", + " self.__denom=anotherFraction.self.__denom\n", + " \n", + " \n", + " #public functions\n", + " def SetValue(self,a,b):\n", + " self.__num=a\n", + " self.__denom=b#refer to IntegerData\n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return a,b\n", + " \n", + "f=Fraction()\n", + "n=input(\"Enter n: \") #user input\n", + "d=input(\"Enter d: \") #user input\n", + "print \"enter the numerator and denominator: \", ' ',n,d\n", + "\n", + "f.SetValue(n,d) #call function SetValue\n", + "print \"Numerator value set: \", ' ',n\n", + "print \"Denominator value set: \", ' ',d\n", + "f.GetValue(n,d) #call function GetData\n", + "print \"Numerator value retrieved: \", ' ',n\n", + "print \"Denominator value retrieved: \", ' ',d\n", + "print \"Now a second clone copy is being created: \",''\n", + "f1=f\n", + "f1.GetValue(n,d)\n", + "print \"Clone's numerator value retrieved: \", ' ',n\n", + "print \"Clone's denominator value retrieved: \", ' ',d" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter n: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter d: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "enter the numerator and denominator: 5 6\n", + "Numerator value set: 5\n", + "Denominator value set: 6\n", + "Numerator value retrieved: 5\n", + "Denominator value retrieved: 6\n", + "Now a second clone copy is being created: \n", + "Clone's numerator value retrieved: 5\n", + "Clone's denominator value retrieved: 6\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.9, page no:229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MyNewHandler():\n", + " print \"Sorry operator new failed to allocate memory\"\n", + " exit(0)\n", + " \n", + "def _set_new_handler(s):\n", + " s()\n", + "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", + "_set_new_handler(MyNewHandler)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sorry operator new failed to allocate memory\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.10, page no:230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from ctypes import * \n", + "class Fraction: \n", + " def __init__(self,a=0,b=1): \n", + " if isinstance(a,int): \n", + " c = c_int(a) \n", + " d = c_int(b) \n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d) \n", + " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " else:\n", + " c=c_int(a.__num[0])\n", + " d = c_int(a.__denom[0])\n", + " self.__num = pointer(c) \n", + " self.__denom = pointer(d)\n", + " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + " def __del__(self): \n", + " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", + " \n", + "n = input(\"Please enter values of numerator: \") \n", + "d = input(\"Please enter values of denominator: \") \n", + "f = Fraction(n,d) \n", + "print 'Please enter another set of ' \n", + "n = input(\"numerator: \") \n", + "d = input(\"denominator: \") \n", + "print 'Creating fraction *pf : ' \n", + "pf = Fraction(n,d) \n", + "print 'Now a clone copy (f2) created from *pf: ' \n", + "f2 = Fraction(pf)\n", + "print 'Now another clone copy (*pf2) created from f:' \n", + "pf2 = Fraction(f) \n", + "print '*pf2 is being destroyed:' \n", + "del pf2\n", + "print '*pf is being destroyed:' \n", + "del pf \n", + "print 'now objects f2 and f automatically destroyed : '" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of numerator: 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please enter values of denominator: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "constructor sets numerator = 3 , denominator = 4\n", + "Please enter another set of \n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "numerator: 5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "denominator: 6\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Creating fraction *pf : \n", + "constructor sets numerator = 5 , denominator = 6\n", + "Now a clone copy (f2) created from *pf: \n", + "copy constructor sets numerator = 5 , denominator = 6\n", + "Now another clone copy (*pf2) created from f:\n", + "copy constructor sets numerator = 3 , denominator = 4\n", + "*pf2 is being destroyed:\n", + "*pf is being destroyed:\n", + "now objects f2 and f automatically destroyed : \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.11, page no:234" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def Memfail(self,s):\n", + " print \"Sorry Unable to allocate memory\"\n", + " sys.exit(0)\n", + "\n", + "MAX_SIZE = 60 + 1\n", + "\n", + "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", + "nChar=0\n", + "chArr=\"Hello\"\n", + "\n", + "print \"Please input a string( 60 characters max.): \",chArr\n", + "\n", + "nChar=len(chArr)+1\n", + "szStr=chArr\n", + "print \"required memory space for\",nChar,\n", + "print \"characters\"\n", + "chArr=szStr #string copy\n", + "szStr=chArr\n", + "print \"String copied in allocated space: \",szStr\n", + "print \"Memory space dellocated\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Please input a string( 60 characters max.): Hello\n", + "required memory space for 6 characters\n", + "String copied in allocated space: Hello\n", + "Memory space dellocated\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.12, page no:236" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Fraction:\n", + " \n", + " def __init__(self,a=0,b=1): #constructor\n", + " self.__num=a\n", + " self.__denom=b\n", + " \n", + " def __del__(self): #destructor\n", + " pass\n", + " \n", + " def GetValue(self,a,b):\n", + " a=self.__num\n", + " b=self.__denom\n", + " return self.__num,self.__denom\n", + "n=4\n", + "d=5\n", + "f=Fraction(4,5)\n", + "n,d=f.GetValue(n,d)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Program Source Code 8.13, page no:239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class X:\n", + " __sa=20 #initialising static member\n", + " a = None\n", + " def __init__(self):\n", + " self.a=None #public member\n", + " def f(self,b):\n", + " a=30\n", + " print \"Global a= \",b\n", + " print \"Local a= \",a\n", + " print \"Nonstatic member a= \",self.a\n", + " print \"static member sa= \",self.__sa\n", + "\n", + "a=10\n", + "\n", + "aXobj=X()\n", + "aXobj.a=40\n", + "aXobj.f(a)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Global a= 10\n", + "Local a= 30\n", + "Nonstatic member a= 40\n", + "static member sa= 20\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_(1).ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_(1).ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_(1).ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_1.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_10.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_2.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_3.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_4.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_5.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_7.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb b/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb deleted file mode 100755 index 1083b19a..00000000 --- a/sample_notebooks/NitamoniDas/chapter_8_Data_Abstraction_through_Classes_and_User-Defined_Data_Types_8.ipynb +++ /dev/null @@ -1,809 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:dbbd8ed92141bcc804ff2fbeacf8bb85f122dc6e196e1d830291a4a449a3a439" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 8: Data Abstraction through Classes and User-Defined Data Types " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.1, page no: 208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Super:\n", - " def __init__(self):\n", - " self.__IntegerData=None #private member\n", - " #public functions\n", - " def SetData(self,i):\n", - " self.__IntegerData=i #refer to IntegerData\n", - " def ShowData(self):\n", - " print \"Data is \",self.__IntegerData,' '\n", - "\n", - "ob1=Super()\n", - "ob2=Super()\n", - "ob1.SetData(1000)\n", - "ob2.SetData(2000)\n", - "ob1.ShowData()\n", - "ob2.ShowData()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Data is 1000 \n", - "Data is 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.2, page no:211" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " def __init__(self):\n", - " self.a=None #private members\n", - " self.b=None #private members\n", - " \n", - "#no structure type present in python \n", - "x = X()\n", - "\n", - "x.a=0\n", - "x.b=1\n", - "print \"x.a=\",x.a,\",x.b=\",x.b" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "x.a= 0 ,x.b= 1\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.3, page no:214" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def SetValue(self,a,b): #public functions\n", - " self.__num=a \n", - " self.__denom=b \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 3 4\n", - "Numerator value set: 3\n", - "Denominator value set: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.4, page no:216" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " def __init__(self):\n", - " self.__i=None #private member\n", - " \n", - " def __init__(self):\n", - " self.__i=500 #constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__i=d\n", - " \n", - " def GetData(self):\n", - " return self.__i\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "print \"s1 has data: \",s1.GetData()\n", - "print \"s2 has data: \",s2.GetData()\n", - "s1.SetData(1000) #function call\n", - "s2.SetData(2000)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \", s2.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500\n", - "s2 has data: 500\n", - "s1 has data: 1000 \n", - "s2 has data: 2000 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.5, page no:217" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class SimpleClass:\n", - " __IntegerData=None\n", - " def __init__(self,data=None):\n", - " if data==None:\n", - " self.__IntegerData=500 #default constructor\n", - " else:\n", - " self.__IntegerData=data #parameterised constructor\n", - " \n", - " def SetData(self,d):\n", - " self.__IntegerData=d\n", - " \n", - " def GetData(self):\n", - " return self.__IntegerData\n", - " \n", - "#Initializing\n", - "s1=SimpleClass()\n", - "s2=SimpleClass()\n", - "s3=SimpleClass(400)\n", - "s4=SimpleClass(600)\n", - "print \"s1 has data: \",s1.GetData(),' '\n", - "print \"s2 has data: \",s2.GetData(),' '\n", - "print \"s3 has data: \",s3.GetData(),' '\n", - "print \"s4 has data: \",s4.GetData(),' '\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "s1 has data: 500 \n", - "s2 has data: 500 \n", - "s3 has data: 400 \n", - "s4 has data: 600 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.6, page no:218" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction: \n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " def __init__(self,a=0,b=1):\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor\",' ',n\n", - " print \"Denominator set inside constructor\",' ',d\n", - " \n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b\n", - " def GetValue(self,a,b):\n", - " a= self.__num\n", - " b= self.__denom\n", - " return a,b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter value of numerator and denominator: \",' ',n,d\n", - "f=Fraction(n,d)\n", - "f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter value of numerator and denominator: 3 4\n", - "Numerator set inside constructor 3\n", - "Denominator set inside constructor 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.7, page no:221" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " print \"Numerator set inside constructor: \",self.__num\n", - " print \"Denominator set inside constructor: \",self.__denom \n", - " \n", - " def GetValue(self,a,b):\n", - " return self.__num,self.__denom\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"Please enter the value of the numerator and denominator: \",n,d\n", - "f=Fraction(n,d)\n", - "n,d=f.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "n=input(\"Please enter the value of numerator only: \")\n", - "f1=Fraction(n)\n", - "n,d=f1.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print 'ok..now I will create a fraction-no input please'\n", - "f2=Fraction()\n", - "n,d=f2.GetValue(n,d)\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of the numerator and denominator: 3 4\n", - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 4\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 4\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter the value of numerator only: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Numerator set inside constructor: 3\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 3\n", - "Denominator value retrieved: 1\n", - "ok..now I will create a fraction-no input please\n", - "Numerator set inside constructor: 0\n", - "Denominator set inside constructor: 1\n", - "Numerator value retrieved: 0\n", - "Denominator value retrieved: 1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.8, page no:223" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " def_init_num=None #private members\n", - " def_init_denom=None #private members\n", - " \n", - " def __init__(self,anotherFraction=None): \n", - " if anotherFraction==None: #normal constructor\n", - " self.__num=anotherFraction\n", - " self.__denom=anotherFraction\n", - " else: #copy constructor\n", - " self.__num=anotherFraction.self.__num\n", - " self.__denom=anotherFraction.self.__denom\n", - " \n", - " \n", - " #public functions\n", - " def SetValue(self,a,b):\n", - " self.__num=a\n", - " self.__denom=b#refer to IntegerData\n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return a,b\n", - " \n", - "f=Fraction()\n", - "n=input(\"Enter n: \") #user input\n", - "d=input(\"Enter d: \") #user input\n", - "print \"enter the numerator and denominator: \", ' ',n,d\n", - "\n", - "f.SetValue(n,d) #call function SetValue\n", - "print \"Numerator value set: \", ' ',n\n", - "print \"Denominator value set: \", ' ',d\n", - "f.GetValue(n,d) #call function GetData\n", - "print \"Numerator value retrieved: \", ' ',n\n", - "print \"Denominator value retrieved: \", ' ',d\n", - "print \"Now a second clone copy is being created: \",''\n", - "f1=f\n", - "f1.GetValue(n,d)\n", - "print \"Clone's numerator value retrieved: \", ' ',n\n", - "print \"Clone's denominator value retrieved: \", ' ',d" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter n: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter d: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "enter the numerator and denominator: 5 6\n", - "Numerator value set: 5\n", - "Denominator value set: 6\n", - "Numerator value retrieved: 5\n", - "Denominator value retrieved: 6\n", - "Now a second clone copy is being created: \n", - "Clone's numerator value retrieved: 5\n", - "Clone's denominator value retrieved: 6\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.9, page no:229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MyNewHandler():\n", - " print \"Sorry operator new failed to allocate memory\"\n", - " exit(0)\n", - " \n", - "def _set_new_handler(s):\n", - " s()\n", - "#In python there is no in-built _set_new_handler function, so i made this function and passed MyNewHandler function as a parameters\n", - "_set_new_handler(MyNewHandler)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sorry operator new failed to allocate memory\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.10, page no:230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from ctypes import * \n", - "class Fraction: \n", - " def __init__(self,a=0,b=1): \n", - " if isinstance(a,int): \n", - " c = c_int(a) \n", - " d = c_int(b) \n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d) \n", - " print 'constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " else:\n", - " c=c_int(a.__num[0])\n", - " d = c_int(a.__denom[0])\n", - " self.__num = pointer(c) \n", - " self.__denom = pointer(d)\n", - " print 'copy constructor sets numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - " def __del__(self): \n", - " print 'destructor deallocates numerator = ', self.__num[0] , ', denominator = ', self.__denom[0] \n", - " \n", - "n = input(\"Please enter values of numerator: \") \n", - "d = input(\"Please enter values of denominator: \") \n", - "f = Fraction(n,d) \n", - "print 'Please enter another set of ' \n", - "n = input(\"numerator: \") \n", - "d = input(\"denominator: \") \n", - "print 'Creating fraction *pf : ' \n", - "pf = Fraction(n,d) \n", - "print 'Now a clone copy (f2) created from *pf: ' \n", - "f2 = Fraction(pf)\n", - "print 'Now another clone copy (*pf2) created from f:' \n", - "pf2 = Fraction(f) \n", - "print '*pf2 is being destroyed:' \n", - "del pf2\n", - "print '*pf is being destroyed:' \n", - "del pf \n", - "print 'now objects f2 and f automatically destroyed : '" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of numerator: 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please enter values of denominator: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "constructor sets numerator = 3 , denominator = 4\n", - "Please enter another set of \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "numerator: 5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "denominator: 6\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Creating fraction *pf : \n", - "constructor sets numerator = 5 , denominator = 6\n", - "Now a clone copy (f2) created from *pf: \n", - "copy constructor sets numerator = 5 , denominator = 6\n", - "Now another clone copy (*pf2) created from f:\n", - "copy constructor sets numerator = 3 , denominator = 4\n", - "*pf2 is being destroyed:\n", - "*pf is being destroyed:\n", - "now objects f2 and f automatically destroyed : \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.11, page no:234" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def Memfail(self,s):\n", - " print \"Sorry Unable to allocate memory\"\n", - " sys.exit(0)\n", - "\n", - "MAX_SIZE = 60 + 1\n", - "\n", - "MAX_SIZE=[[0 for col in range(MAX_SIZE)]for row in range(MAX_SIZE)]\n", - "nChar=0\n", - "chArr=\"Hello\"\n", - "\n", - "print \"Please input a string( 60 characters max.): \",chArr\n", - "\n", - "nChar=len(chArr)+1\n", - "szStr=chArr\n", - "print \"required memory space for\",nChar,\n", - "print \"characters\"\n", - "chArr=szStr #string copy\n", - "szStr=chArr\n", - "print \"String copied in allocated space: \",szStr\n", - "print \"Memory space dellocated\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Please input a string( 60 characters max.): Hello\n", - "required memory space for 6 characters\n", - "String copied in allocated space: Hello\n", - "Memory space dellocated\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.12, page no:236" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Fraction:\n", - " \n", - " def __init__(self,a=0,b=1): #constructor\n", - " self.__num=a\n", - " self.__denom=b\n", - " \n", - " def __del__(self): #destructor\n", - " pass\n", - " \n", - " def GetValue(self,a,b):\n", - " a=self.__num\n", - " b=self.__denom\n", - " return self.__num,self.__denom\n", - "n=4\n", - "d=5\n", - "f=Fraction(4,5)\n", - "n,d=f.GetValue(n,d)" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Program Source Code 8.13, page no:239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class X:\n", - " __sa=20 #initialising static member\n", - " a = None\n", - " def __init__(self):\n", - " self.a=None #public member\n", - " def f(self,b):\n", - " a=30\n", - " print \"Global a= \",b\n", - " print \"Local a= \",a\n", - " print \"Nonstatic member a= \",self.a\n", - " print \"static member sa= \",self.__sa\n", - "\n", - "a=10\n", - "\n", - "aXobj=X()\n", - "aXobj.a=40\n", - "aXobj.f(a)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Global a= 10\n", - "Local a= 30\n", - "Nonstatic member a= 40\n", - "static member sa= 20\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Nitin Kumar/Nitin Kumar_version_backup/chapter2.ipynb b/sample_notebooks/Nitin Kumar/Nitin Kumar_version_backup/chapter2.ipynb new file mode 100644 index 00000000..ddf5a2a5 --- /dev/null +++ b/sample_notebooks/Nitin Kumar/Nitin Kumar_version_backup/chapter2.ipynb @@ -0,0 +1,680 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 - Power Switching Devices & Their Characteristics" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.1 page 67" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "VA = 1.10 V\n" + ] + } + ], + "source": [ + "V1=1 # V across SCR\n", + "IG=0 # A\n", + "Ih=2 # mA holding current\n", + "R=50 # ohm\n", + "\n", + "# Applying kirchoff law\n", + "#VA-(IAK*R)-V1=0\n", + "VA=(Ih*10**-3*R)+V1 # V (let IAK=Ih)\n", + "print 'VA = %.2f V'%(VA)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.2 page 67" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum duration of gating pulse = 10 us\n" + ] + } + ], + "source": [ + "diBYdt=1000 # A/s (rate of rise of current)\n", + "il=10 # mA (latching current = diBYdt * tp)\n", + "tp=il*10**-3/diBYdt # s\n", + "print 'Minimum duration of gating pulse = %.f us'%(tp*10**6)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.3 page 68" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gate power dissipation = 4 W\n", + "\n", + " Resistance to be connected = 14 ohm\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "m=16 # V/A (gradient)\n", + "t_on=4 # us\n", + "IG=500 # mA\n", + "VS=15 # V\n", + "\n", + "VG=m*IG/1000 # V\n", + "#Load line equation\n", + "#VG=VS-IG*RS\n", + "RS=(VS-VG)/(IG/1000) # ohm\n", + "Pg=VS*(IG/1000)**2 # # W\n", + "print 'Gate power dissipation = %.f W'%(Pg)\n", + "print '\\n Resistance to be connected = %.f ohm'%(RS)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.4 page 68" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of resistance to be added in series = 44.11 ohm\n" + ] + } + ], + "source": [ + "from numpy import roots\n", + "# VG=0.5+8*IG -- eqn(1)\n", + "f=400# # Hz\n", + "delta=0.1 # # (Duty Cycle)\n", + "P=0.5 # W\n", + "VS=12 # V\n", + "\n", + "Tp=1/f*10**6 # us\n", + "# P= VG*IG -- eqn(2)\n", + "# solving eqn 1 and 2\n", + "#8*IG*IG**2+0.5*IG-P=0\n", + "p=[8, 0.5, -P] # polynomial for IG\n", + "IG=roots(p) # A \n", + "IG=IG[1] # A (discarding -ve value)\n", + "VG=0.5+8*IG # V\n", + "# VS=VG+IG*RS\n", + "RS=(VS-VG)/IG\n", + "print 'Value of resistance to be added in series = %.2f ohm'%(RS)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.5 page 69" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of resistance to be connected in series = 6.97 ohm\n", + "\n", + " Triggering frequency = 5.00 kHz\n", + "\n", + " Duty Cycle = 0.1 \n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import sqrt\n", + "# VG=10*IG -- eqn(1)\n", + "PGM=5 # W\n", + "PGav=.5 # W\n", + "VS=12 # V\n", + "Tp=20 # us\n", + "\n", + "# PGM = VG*IG where VG=10*IG\n", + "\n", + "IG=sqrt(PGM/10) # A\n", + "VG=10*IG # V\n", + "# During the application of pulse VS = VG+(IG*RS)\n", + "RS=(VS-VG)/IG # ohm\n", + "f=PGav/(PGM*Tp*10**-6)/1000 # kHz\n", + "delta=f*1000*Tp*10**-6 # Duty Cycle\n", + "print 'Value of resistance to be connected in series = %.2f ohm'%(RS)\n", + "print '\\n Triggering frequency = %.2f kHz'%(f)\n", + "print '\\n Duty Cycle = %.1f '%(delta)\n", + "# Note : ans in the textbook is not accurate." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.6 page 70" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of R = 31.25 kohm\n", + "\n", + " Value of C = 1.20e-07 F\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "VS=3 # kV\n", + "IS=750 # A\n", + "\n", + "VD=800 # V\n", + "ID=175 # A\n", + "dr=30/100 # de-rating factor\n", + "IB=8 # mA\n", + "delQ=30 # u Coulomb\n", + "# dr = 1-IS/np*ID\n", + "np = round(IS/(1-dr)/(ID)) # # no. of parallel string\n", + "ns = round(VS*1000/(1-dr)/(VD)) # # no. of series string\n", + "R=(ns*VD-VS*1000)/(ns-1)/(IB/1000)/1000 # kohm\n", + "C=(ns-1)*delQ*10**-6/(ns*VD-VS*1000)\n", + "print 'Value of R = %.2f kohm'%(R)\n", + "print '\\n Value of C = %.2e F'%(C)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.7 page 71" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " no. of series connection = 7\n", + "\n", + " no. of parallel connection = 5\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import ceil\n", + "VS=4 # kV\n", + "IS=800 # A\n", + "\n", + "VD=800 # V\n", + "ID=200 # A\n", + "dr=20/100 # de-rating factor\n", + "# for series connection\n", + "ns = ceil(VS*1000/(1-dr)/(VD)) # # no. of series string\n", + "# for parallel connection\n", + "np = round(IS/(1-dr)/(ID)) # # no. of parallel string\n", + "print '\\n no. of series connection = %d'%(ns)\n", + "print '\\n no. of parallel connection = %d'%(np)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.8 page 72" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Series resistance = 0.007 ohm\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "IS1=100 # A\n", + "IS2=150 # A\n", + "vd1=2.1 # V\n", + "vd2=1.75 # V\n", + "I=250 # A\n", + "\n", + "rf1=vd1/IS1 # ohm\n", + "rf2=vd2/IS2 # ohm\n", + "# Equating voltage drops\n", + "# vd1+IS1*re = vd2+IS2*re\n", + "re=(vd1-vd2)/(IS2-IS1)\n", + "print ' Series resistance = %.3f ohm'%(re)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.9 page 72" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Average power loss = 34.8 W\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import pi\n", + "Vf1=1 # V\n", + "If1=0 # A\n", + "Vf2=1.9 # V\n", + "If2=60 # A\n", + "IT=20*pi # A\n", + "# PAV = 1/T*integrate(VT*IT,0,T)*dt = ITAV+0.015*IRMS**2\n", + "ITAV=IT/pi # A\n", + "ITRMS=IT/2 # A\n", + "dt=ITAV+0.015*ITRMS**2 # W\n", + "print 'Average power loss = %.1f W'%(dt)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.10 page 73" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum gate pulse width = 8.7 us\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "R=10 # ohm\n", + "L=0.1 # H\n", + "delta_i=20/1000 # A\n", + "Vs=230 # V4\n", + "f=50 # Hz\n", + "theta=45 # degree\n", + "\n", + "delta_t = L*delta_i/Vs# # s\n", + "delta_t = delta_t*10**6 # us\n", + "print 'Minimum gate pulse width = %.1f us'%(delta_t)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.11 page 73" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "gate source resistance = 2.0 kohm\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import sqrt\n", + "m=3*10**3 # gradient (VG/IG)\n", + "VS=10 # V\n", + "PG=0.012 # W\n", + "# IG = VG/m & PG=VG*IG\n", + "VG=sqrt(PG*m)\n", + "IG=VG/m # # A\n", + "RS=(VS-VG)/IG/1000 # kohm\n", + "print 'gate source resistance = %.1f kohm'%(RS)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.12 page 74" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of resistance = 6.82 kohm\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "VS=300 # V\n", + "delta_i = 50/1000 # A\n", + "R=60 # ohm\n", + "L=2 # H\n", + "TP=40*10**-6 # s\n", + "\n", + "I1=VS/L*TP # A (at the end of pulse)\n", + "# as I1 << delta_i\n", + "I2=delta_i # A (anode current with RL load)\n", + "\n", + "Rdash = VS/(I2-I1)/1000 # kohm\n", + "print 'Value of resistance = %.2f kohm'%(Rdash)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.13 page 74" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "For half sine wave current : \n", + "\n", + "(i) Average ON State current = 31.83 A\n", + "\n", + "(ii) Average ON State current = 22.51 A\n", + "\n", + "(iii) Average ON State current = 12.54 A\n", + "\n", + "\n", + " For rectangular wave current : \n", + "\n", + "(i) Average ON State current = 35.36 A\n", + "\n", + "(ii) Average ON State current = 25.00 A\n", + "\n", + "(i) Average ON State current = 14.43 A\n", + "\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import pi,sqrt\n", + "Im=50 # A\n", + "\n", + "print 'For half sine wave current : \\n'\n", + "# theta=180 # degree\n", + "theta=180 # degree\n", + "Iav=Im/pi # A\n", + "Irms=Im/2 # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(i) Average ON State current = %.2f A\\n'%(ITav) \n", + "\n", + "# theta=90 # degree\n", + "theta=90 # degree\n", + "Iav=Im/2/pi # A\n", + "Irms=Im/2/sqrt(2) # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(ii) Average ON State current = %.2f A\\n'%(ITav) \n", + "\n", + "# theta=180 # degree\n", + "theta=180 # degree\n", + "Iav=Im*0.0213 # A\n", + "Irms=Im*0.0849 # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(iii) Average ON State current = %.2f A\\n'%(ITav) \n", + "\n", + "print '\\n For rectangular wave current : \\n'\n", + "# theta=180 # degree\n", + "theta=180 # degree\n", + "Iav=Im/2 # A\n", + "Irms=Im/sqrt(2) # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(i) Average ON State current = %.2f A\\n'%(ITav) \n", + "\n", + "# theta=90 # degree\n", + "theta=90 # degree\n", + "Iav=Im/4 # A\n", + "Irms=Im/2 # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(ii) Average ON State current = %.2f A\\n'%(ITav) \n", + "\n", + "# theta=180 # degree\n", + "theta=180 # degree\n", + "Iav=Im/12 # A\n", + "Irms=Im/2/sqrt(3) # A\n", + "FF=Irms/Iav # form factor\n", + "ITav=Im/FF # # A\n", + "print '(i) Average ON State current = %.2f A\\n'%(ITav) " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.14 page 76" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of L = 16.67 uH\n", + "\n", + " Value of R = 3.3 ohm\n", + "\n", + " Value of Ip = 175.0 A is greater than permissible peak current = 125.0 A\n", + " change the value of Rs\n", + "\n", + " Value of C = 0.78 uF\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "VS=500 # V\n", + "IP=250 # A\n", + "diBYdt=60 # A/us\n", + "dvaBYdt=200 # V/us\n", + "RL=20 # ohm\n", + "r=0.65 # ohm\n", + "eps=0.65 # damping ratios\n", + "\n", + "F=2 # saftety factor\n", + "IP=IP/2 # A\n", + "diBYdt=60/2 # A/us\n", + "dvaBYdt=200/2 # V/us\n", + "L=VS/diBYdt # uH\n", + "R=L*10**6/VS*dvaBYdt/10**6 # ohm\n", + "print 'Value of L = %.2f uH'%(L)\n", + "print '\\n Value of R = %.1f ohm'%(R)\n", + "\n", + "Ip=VS/RL+VS/R # A\n", + "if Ip > IP :\n", + " print '\\n Value of Ip = %.1f A is greater than permissible peak current = %.1f A\\n change the value of Rs'%(Ip,IP)\n", + " Rs=6 # ohm\n", + "\n", + "Ip=VS/RL+VS/Rs # A\n", + "Cs=(2*eps/Rs)**2*L # uF\n", + "print '\\n Value of C = %.2f uF'%(Cs)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 2.15 page 77" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I2t rating = 45000 A**2/s\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "from math import ceil,sqrt\n", + "Isb=3000 # A\n", + "f=50 # Hz\n", + "I=sqrt((Isb**2*1/2/f)*f) # A\n", + "I2t=I**2/2/f # A**2/s\n", + "print 'I2t rating = %d A**2/s'%(ceil(I2t))" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Nitin Kumar/chapter2.ipynb b/sample_notebooks/Nitin Kumar/chapter2.ipynb deleted file mode 100644 index ddf5a2a5..00000000 --- a/sample_notebooks/Nitin Kumar/chapter2.ipynb +++ /dev/null @@ -1,680 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 - Power Switching Devices & Their Characteristics" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.1 page 67" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "VA = 1.10 V\n" - ] - } - ], - "source": [ - "V1=1 # V across SCR\n", - "IG=0 # A\n", - "Ih=2 # mA holding current\n", - "R=50 # ohm\n", - "\n", - "# Applying kirchoff law\n", - "#VA-(IAK*R)-V1=0\n", - "VA=(Ih*10**-3*R)+V1 # V (let IAK=Ih)\n", - "print 'VA = %.2f V'%(VA)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.2 page 67" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum duration of gating pulse = 10 us\n" - ] - } - ], - "source": [ - "diBYdt=1000 # A/s (rate of rise of current)\n", - "il=10 # mA (latching current = diBYdt * tp)\n", - "tp=il*10**-3/diBYdt # s\n", - "print 'Minimum duration of gating pulse = %.f us'%(tp*10**6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.3 page 68" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Gate power dissipation = 4 W\n", - "\n", - " Resistance to be connected = 14 ohm\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "m=16 # V/A (gradient)\n", - "t_on=4 # us\n", - "IG=500 # mA\n", - "VS=15 # V\n", - "\n", - "VG=m*IG/1000 # V\n", - "#Load line equation\n", - "#VG=VS-IG*RS\n", - "RS=(VS-VG)/(IG/1000) # ohm\n", - "Pg=VS*(IG/1000)**2 # # W\n", - "print 'Gate power dissipation = %.f W'%(Pg)\n", - "print '\\n Resistance to be connected = %.f ohm'%(RS)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.4 page 68" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of resistance to be added in series = 44.11 ohm\n" - ] - } - ], - "source": [ - "from numpy import roots\n", - "# VG=0.5+8*IG -- eqn(1)\n", - "f=400# # Hz\n", - "delta=0.1 # # (Duty Cycle)\n", - "P=0.5 # W\n", - "VS=12 # V\n", - "\n", - "Tp=1/f*10**6 # us\n", - "# P= VG*IG -- eqn(2)\n", - "# solving eqn 1 and 2\n", - "#8*IG*IG**2+0.5*IG-P=0\n", - "p=[8, 0.5, -P] # polynomial for IG\n", - "IG=roots(p) # A \n", - "IG=IG[1] # A (discarding -ve value)\n", - "VG=0.5+8*IG # V\n", - "# VS=VG+IG*RS\n", - "RS=(VS-VG)/IG\n", - "print 'Value of resistance to be added in series = %.2f ohm'%(RS)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.5 page 69" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of resistance to be connected in series = 6.97 ohm\n", - "\n", - " Triggering frequency = 5.00 kHz\n", - "\n", - " Duty Cycle = 0.1 \n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import sqrt\n", - "# VG=10*IG -- eqn(1)\n", - "PGM=5 # W\n", - "PGav=.5 # W\n", - "VS=12 # V\n", - "Tp=20 # us\n", - "\n", - "# PGM = VG*IG where VG=10*IG\n", - "\n", - "IG=sqrt(PGM/10) # A\n", - "VG=10*IG # V\n", - "# During the application of pulse VS = VG+(IG*RS)\n", - "RS=(VS-VG)/IG # ohm\n", - "f=PGav/(PGM*Tp*10**-6)/1000 # kHz\n", - "delta=f*1000*Tp*10**-6 # Duty Cycle\n", - "print 'Value of resistance to be connected in series = %.2f ohm'%(RS)\n", - "print '\\n Triggering frequency = %.2f kHz'%(f)\n", - "print '\\n Duty Cycle = %.1f '%(delta)\n", - "# Note : ans in the textbook is not accurate." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.6 page 70" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of R = 31.25 kohm\n", - "\n", - " Value of C = 1.20e-07 F\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "VS=3 # kV\n", - "IS=750 # A\n", - "\n", - "VD=800 # V\n", - "ID=175 # A\n", - "dr=30/100 # de-rating factor\n", - "IB=8 # mA\n", - "delQ=30 # u Coulomb\n", - "# dr = 1-IS/np*ID\n", - "np = round(IS/(1-dr)/(ID)) # # no. of parallel string\n", - "ns = round(VS*1000/(1-dr)/(VD)) # # no. of series string\n", - "R=(ns*VD-VS*1000)/(ns-1)/(IB/1000)/1000 # kohm\n", - "C=(ns-1)*delQ*10**-6/(ns*VD-VS*1000)\n", - "print 'Value of R = %.2f kohm'%(R)\n", - "print '\\n Value of C = %.2e F'%(C)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.7 page 71" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " no. of series connection = 7\n", - "\n", - " no. of parallel connection = 5\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import ceil\n", - "VS=4 # kV\n", - "IS=800 # A\n", - "\n", - "VD=800 # V\n", - "ID=200 # A\n", - "dr=20/100 # de-rating factor\n", - "# for series connection\n", - "ns = ceil(VS*1000/(1-dr)/(VD)) # # no. of series string\n", - "# for parallel connection\n", - "np = round(IS/(1-dr)/(ID)) # # no. of parallel string\n", - "print '\\n no. of series connection = %d'%(ns)\n", - "print '\\n no. of parallel connection = %d'%(np)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.8 page 72" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Series resistance = 0.007 ohm\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "IS1=100 # A\n", - "IS2=150 # A\n", - "vd1=2.1 # V\n", - "vd2=1.75 # V\n", - "I=250 # A\n", - "\n", - "rf1=vd1/IS1 # ohm\n", - "rf2=vd2/IS2 # ohm\n", - "# Equating voltage drops\n", - "# vd1+IS1*re = vd2+IS2*re\n", - "re=(vd1-vd2)/(IS2-IS1)\n", - "print ' Series resistance = %.3f ohm'%(re)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.9 page 72" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Average power loss = 34.8 W\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import pi\n", - "Vf1=1 # V\n", - "If1=0 # A\n", - "Vf2=1.9 # V\n", - "If2=60 # A\n", - "IT=20*pi # A\n", - "# PAV = 1/T*integrate(VT*IT,0,T)*dt = ITAV+0.015*IRMS**2\n", - "ITAV=IT/pi # A\n", - "ITRMS=IT/2 # A\n", - "dt=ITAV+0.015*ITRMS**2 # W\n", - "print 'Average power loss = %.1f W'%(dt)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.10 page 73" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum gate pulse width = 8.7 us\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "R=10 # ohm\n", - "L=0.1 # H\n", - "delta_i=20/1000 # A\n", - "Vs=230 # V4\n", - "f=50 # Hz\n", - "theta=45 # degree\n", - "\n", - "delta_t = L*delta_i/Vs# # s\n", - "delta_t = delta_t*10**6 # us\n", - "print 'Minimum gate pulse width = %.1f us'%(delta_t)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.11 page 73" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "gate source resistance = 2.0 kohm\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import sqrt\n", - "m=3*10**3 # gradient (VG/IG)\n", - "VS=10 # V\n", - "PG=0.012 # W\n", - "# IG = VG/m & PG=VG*IG\n", - "VG=sqrt(PG*m)\n", - "IG=VG/m # # A\n", - "RS=(VS-VG)/IG/1000 # kohm\n", - "print 'gate source resistance = %.1f kohm'%(RS)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.12 page 74" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of resistance = 6.82 kohm\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "VS=300 # V\n", - "delta_i = 50/1000 # A\n", - "R=60 # ohm\n", - "L=2 # H\n", - "TP=40*10**-6 # s\n", - "\n", - "I1=VS/L*TP # A (at the end of pulse)\n", - "# as I1 << delta_i\n", - "I2=delta_i # A (anode current with RL load)\n", - "\n", - "Rdash = VS/(I2-I1)/1000 # kohm\n", - "print 'Value of resistance = %.2f kohm'%(Rdash)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.13 page 74" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "For half sine wave current : \n", - "\n", - "(i) Average ON State current = 31.83 A\n", - "\n", - "(ii) Average ON State current = 22.51 A\n", - "\n", - "(iii) Average ON State current = 12.54 A\n", - "\n", - "\n", - " For rectangular wave current : \n", - "\n", - "(i) Average ON State current = 35.36 A\n", - "\n", - "(ii) Average ON State current = 25.00 A\n", - "\n", - "(i) Average ON State current = 14.43 A\n", - "\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import pi,sqrt\n", - "Im=50 # A\n", - "\n", - "print 'For half sine wave current : \\n'\n", - "# theta=180 # degree\n", - "theta=180 # degree\n", - "Iav=Im/pi # A\n", - "Irms=Im/2 # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(i) Average ON State current = %.2f A\\n'%(ITav) \n", - "\n", - "# theta=90 # degree\n", - "theta=90 # degree\n", - "Iav=Im/2/pi # A\n", - "Irms=Im/2/sqrt(2) # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(ii) Average ON State current = %.2f A\\n'%(ITav) \n", - "\n", - "# theta=180 # degree\n", - "theta=180 # degree\n", - "Iav=Im*0.0213 # A\n", - "Irms=Im*0.0849 # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(iii) Average ON State current = %.2f A\\n'%(ITav) \n", - "\n", - "print '\\n For rectangular wave current : \\n'\n", - "# theta=180 # degree\n", - "theta=180 # degree\n", - "Iav=Im/2 # A\n", - "Irms=Im/sqrt(2) # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(i) Average ON State current = %.2f A\\n'%(ITav) \n", - "\n", - "# theta=90 # degree\n", - "theta=90 # degree\n", - "Iav=Im/4 # A\n", - "Irms=Im/2 # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(ii) Average ON State current = %.2f A\\n'%(ITav) \n", - "\n", - "# theta=180 # degree\n", - "theta=180 # degree\n", - "Iav=Im/12 # A\n", - "Irms=Im/2/sqrt(3) # A\n", - "FF=Irms/Iav # form factor\n", - "ITav=Im/FF # # A\n", - "print '(i) Average ON State current = %.2f A\\n'%(ITav) " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.14 page 76" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of L = 16.67 uH\n", - "\n", - " Value of R = 3.3 ohm\n", - "\n", - " Value of Ip = 175.0 A is greater than permissible peak current = 125.0 A\n", - " change the value of Rs\n", - "\n", - " Value of C = 0.78 uF\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "VS=500 # V\n", - "IP=250 # A\n", - "diBYdt=60 # A/us\n", - "dvaBYdt=200 # V/us\n", - "RL=20 # ohm\n", - "r=0.65 # ohm\n", - "eps=0.65 # damping ratios\n", - "\n", - "F=2 # saftety factor\n", - "IP=IP/2 # A\n", - "diBYdt=60/2 # A/us\n", - "dvaBYdt=200/2 # V/us\n", - "L=VS/diBYdt # uH\n", - "R=L*10**6/VS*dvaBYdt/10**6 # ohm\n", - "print 'Value of L = %.2f uH'%(L)\n", - "print '\\n Value of R = %.1f ohm'%(R)\n", - "\n", - "Ip=VS/RL+VS/R # A\n", - "if Ip > IP :\n", - " print '\\n Value of Ip = %.1f A is greater than permissible peak current = %.1f A\\n change the value of Rs'%(Ip,IP)\n", - " Rs=6 # ohm\n", - "\n", - "Ip=VS/RL+VS/Rs # A\n", - "Cs=(2*eps/Rs)**2*L # uF\n", - "print '\\n Value of C = %.2f uF'%(Cs)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 2.15 page 77" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I2t rating = 45000 A**2/s\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "from math import ceil,sqrt\n", - "Isb=3000 # A\n", - "f=50 # Hz\n", - "I=sqrt((Isb**2*1/2/f)*f) # A\n", - "I2t=I**2/2/f # A**2/s\n", - "print 'I2t rating = %d A**2/s'%(ceil(I2t))" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/NityaL/NityaL_version_backup/Sample-Chapter_26.ipynb b/sample_notebooks/NityaL/NityaL_version_backup/Sample-Chapter_26.ipynb new file mode 100755 index 00000000..4ae1c760 --- /dev/null +++ b/sample_notebooks/NityaL/NityaL_version_backup/Sample-Chapter_26.ipynb @@ -0,0 +1,226 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 26:CHARGE AND MATTER" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 26.1 Magnitude of total charges in a copper penny" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Magnitude of the charges in coulombs is 133687.50000000003\n" + ] + } + ], + "source": [ + "#Example 1.1\n", + "\n", + "m =3.1 #mass of copper penny in grams\n", + "e =4.6*10** -18 #charge in coulombs\n", + "N0 =6*10**23 #avogadro’s number atoms / mole\n", + "M =64 #molecular weight of copper in gm/ mole\n", + "\n", + "#Calculation\n", + "N =( N0 * m ) / M #No. of copper atoms in penny\n", + "q = N * e # magnitude of the charges in coulombs\n", + "print (\" Magnitude of the charges in coulomb is \",q )" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 26.2 Separation between total positive and negative charges" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Separation between total positive and negative charges in meters is 5813776741.499454\n" + ] + } + ], + "source": [ + "#Example 2\n", + "\n", + "import math\n", + "\n", + "F =4.5 #Force of attraction in nt\n", + "q =1.3*10**5 #total charge in coulomb\n", + "r = q * math.sqrt ((9*10**9) / F ) ;\n", + "print(\" Separation between total positive and negative charges in meters is \",r )" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 26.3 Force acting on charge q1" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "X component of resultant force acting on q1 in nt is 2.0999999999999996\n", + "Y component of resultant force acting on q1 in nt is -1.5588457268119893\n" + ] + } + ], + "source": [ + "#Example 3\n", + "\n", + "import math\n", + "\n", + "#given three charges q1,q2,q3\n", + "q1=-1.0*10**-6 #charge in coul\n", + "q2=+3.0*10**-6 #charge in coul\n", + "q3=-2.0*10**-6 #charge in coul\n", + "r12=15*10**-2 #separation between q1 and q2 in m\n", + "r13=10*10**-2 # separation between q1 and q3 in m\n", + "angle=math.pi/6 #in degrees\n", + "F12=(9.0*10**9)*q1*q2/(r12**2) #in nt\n", + "F13=(9.0*10**9)*q1*q3/(r13**2) #in nt\n", + "F12x=-F12 #ignoring signs of charges\n", + "F13x=F13*math.sin(angle);\n", + "F1x=F12x+F13x\n", + "F12y=0 #from fig.263\n", + "F13y=-F13*math.cos(angle);\n", + "F1y=F12y+F13y #in nt\n", + "print(\"X component of resultant force acting on q1 in nt is\",F1x)\n", + "print(\"Y component of resultant force acting on q1 in nt is\",F1y)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 26.4 Electrical and Gravitational force between two particles" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Coulomb force in nt is 8.202207191171238e-08\n", + "Gravitational force in nt is 3.689889640441438e-47\n" + ] + } + ], + "source": [ + "#Example 4\n", + "\n", + "r=5.3*10**-11 #distance between electron and proton in the hydrogen atom in meter\n", + "e=1.6*10**-19 #charge in coul\n", + "G=6.7*10**-11 #gravitatinal constant in nt-m2/kg2\n", + "m1=9.1*10**-31 #mass of electron in kg\n", + "m2=1.7*10**-27 #mass of proton in kg\n", + "F1=(9*10**9)*e*e/(r**2) #coulomb's law\n", + "F2=G*m1*m2/(r**2) #gravitational force\n", + "print(\"Coulomb force in nt is\",F1)\n", + "print(\"Gravitational force in nt is\",F2)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 26.5 Repulsive force between two protons in a nucleus of iron" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Repulsive coulomb force F 14.4 nt\n" + ] + } + ], + "source": [ + "#Example 5\n", + "\n", + "r=4*10**-15 #separation between proton annd nucleus in iron in meters\n", + "q=1.6*10**-19 #charge in coul\n", + "F=(9*10**9)*(q**2)/(r**2) #coulomb's law\n", + "print(\"Repulsive coulomb force F \",F,'nt')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/NityaL/NityaL_version_backup/Sample.ipynb b/sample_notebooks/NityaL/NityaL_version_backup/Sample.ipynb new file mode 100755 index 00000000..c7730277 --- /dev/null +++ b/sample_notebooks/NityaL/NityaL_version_backup/Sample.ipynb @@ -0,0 +1,236 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 26:CHARGE AND MATTER" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "##Example 26.1 Magnitude of total charges in a copper penny" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Magnitude of the charges in coulombs is 133687.50000000003\n" + ] + } + ], + "source": [ + "#Example 1.1\n", + "\n", + "m =3.1 #mass of copper penny in grams\n", + "e =4.6*10** -18 #charge in coulombs\n", + "N0 =6*10**23 #avogadro’s number atoms / mole\n", + "M =64 #molecular weight of copper in gm/ mole\n", + "\n", + "#Calculation\n", + "N =( N0 * m ) / M #No. of copper atoms in penny\n", + "q = N * e # magnitude of the charges in coulombs\n", + "print (\" Magnitude of the charges in coulomb is \",q )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "##Example 26.2 Separation between total positive and negative charges" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Separation between total positive and negative charges in meters is 5813776741.499454\n" + ] + } + ], + "source": [ + "#Example 2\n", + "\n", + "import math\n", + "\n", + "F =4.5 #Force of attraction in nt\n", + "q =1.3*10**5 #total charge in coulomb\n", + "r = q * math.sqrt ((9*10**9) / F ) ;\n", + "print(\" Separation between total positive and negative charges in meters is \",r )" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "##Example 26.3 Force acting on charge q1" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "X component of resultant force acting on q1 in nt is 2.0999999999999996\n", + "Y component of resultant force acting on q1 in nt is -1.5588457268119893\n" + ] + } + ], + "source": [ + "#Example 3\n", + "\n", + "import math\n", + "\n", + "#given three charges q1,q2,q3\n", + "q1=-1.0*10**-6 #charge in coul\n", + "q2=+3.0*10**-6 #charge in coul\n", + "q3=-2.0*10**-6 #charge in coul\n", + "r12=15*10**-2 #separation between q1 and q2 in m\n", + "r13=10*10**-2 # separation between q1 and q3 in m\n", + "angle=math.pi/6 #in degrees\n", + "F12=(9.0*10**9)*q1*q2/(r12**2) #in nt\n", + "F13=(9.0*10**9)*q1*q3/(r13**2) #in nt\n", + "F12x=-F12 #ignoring signs of charges\n", + "F13x=F13*math.sin(angle);\n", + "F1x=F12x+F13x\n", + "F12y=0 #from fig.263\n", + "F13y=-F13*math.cos(angle);\n", + "F1y=F12y+F13y #in nt\n", + "print(\"X component of resultant force acting on q1 in nt is\",F1x)\n", + "print(\"Y component of resultant force acting on q1 in nt is\",F1y)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "##Example 26.4 Electrical and Gravitational force between two particles" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Coulomb force in nt is 8.202207191171238e-08\n", + "Gravitational force in nt is 3.689889640441438e-47\n" + ] + } + ], + "source": [ + "#Example 4\n", + "\n", + "r=5.3*10**-11 #distance between electron and proton in the hydrogen atom in meter\n", + "e=1.6*10**-19 #charge in coul\n", + "G=6.7*10**-11 #gravitatinal constant in nt-m2/kg2\n", + "m1=9.1*10**-31 #mass of electron in kg\n", + "m2=1.7*10**-27 #mass of proton in kg\n", + "F1=(9*10**9)*e*e/(r**2) #coulomb's law\n", + "F2=G*m1*m2/(r**2) #gravitational force\n", + "print(\"Coulomb force in nt is\",F1)\n", + "print(\"Gravitational force in nt is\",F2)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "##Example 26.5 Repulsive force between two protons in a nucleus of iron" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Repulsive coulomb force F 14.4 nt\n" + ] + } + ], + "source": [ + "#Example 5\n", + "\n", + "r=4*10**-15 #separation between proton annd nucleus in iron in meters\n", + "q=1.6*10**-19 #charge in coul\n", + "F=(9*10**9)*(q**2)/(r**2) #coulomb's law\n", + "print(\"Repulsive coulomb force F \",F,'nt')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.4.3" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/NityaL/Sample-Chapter_26.ipynb b/sample_notebooks/NityaL/Sample-Chapter_26.ipynb deleted file mode 100755 index 4ae1c760..00000000 --- a/sample_notebooks/NityaL/Sample-Chapter_26.ipynb +++ /dev/null @@ -1,226 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 26:CHARGE AND MATTER" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 26.1 Magnitude of total charges in a copper penny" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Magnitude of the charges in coulombs is 133687.50000000003\n" - ] - } - ], - "source": [ - "#Example 1.1\n", - "\n", - "m =3.1 #mass of copper penny in grams\n", - "e =4.6*10** -18 #charge in coulombs\n", - "N0 =6*10**23 #avogadro’s number atoms / mole\n", - "M =64 #molecular weight of copper in gm/ mole\n", - "\n", - "#Calculation\n", - "N =( N0 * m ) / M #No. of copper atoms in penny\n", - "q = N * e # magnitude of the charges in coulombs\n", - "print (\" Magnitude of the charges in coulomb is \",q )" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 26.2 Separation between total positive and negative charges" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Separation between total positive and negative charges in meters is 5813776741.499454\n" - ] - } - ], - "source": [ - "#Example 2\n", - "\n", - "import math\n", - "\n", - "F =4.5 #Force of attraction in nt\n", - "q =1.3*10**5 #total charge in coulomb\n", - "r = q * math.sqrt ((9*10**9) / F ) ;\n", - "print(\" Separation between total positive and negative charges in meters is \",r )" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 26.3 Force acting on charge q1" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "X component of resultant force acting on q1 in nt is 2.0999999999999996\n", - "Y component of resultant force acting on q1 in nt is -1.5588457268119893\n" - ] - } - ], - "source": [ - "#Example 3\n", - "\n", - "import math\n", - "\n", - "#given three charges q1,q2,q3\n", - "q1=-1.0*10**-6 #charge in coul\n", - "q2=+3.0*10**-6 #charge in coul\n", - "q3=-2.0*10**-6 #charge in coul\n", - "r12=15*10**-2 #separation between q1 and q2 in m\n", - "r13=10*10**-2 # separation between q1 and q3 in m\n", - "angle=math.pi/6 #in degrees\n", - "F12=(9.0*10**9)*q1*q2/(r12**2) #in nt\n", - "F13=(9.0*10**9)*q1*q3/(r13**2) #in nt\n", - "F12x=-F12 #ignoring signs of charges\n", - "F13x=F13*math.sin(angle);\n", - "F1x=F12x+F13x\n", - "F12y=0 #from fig.263\n", - "F13y=-F13*math.cos(angle);\n", - "F1y=F12y+F13y #in nt\n", - "print(\"X component of resultant force acting on q1 in nt is\",F1x)\n", - "print(\"Y component of resultant force acting on q1 in nt is\",F1y)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 26.4 Electrical and Gravitational force between two particles" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Coulomb force in nt is 8.202207191171238e-08\n", - "Gravitational force in nt is 3.689889640441438e-47\n" - ] - } - ], - "source": [ - "#Example 4\n", - "\n", - "r=5.3*10**-11 #distance between electron and proton in the hydrogen atom in meter\n", - "e=1.6*10**-19 #charge in coul\n", - "G=6.7*10**-11 #gravitatinal constant in nt-m2/kg2\n", - "m1=9.1*10**-31 #mass of electron in kg\n", - "m2=1.7*10**-27 #mass of proton in kg\n", - "F1=(9*10**9)*e*e/(r**2) #coulomb's law\n", - "F2=G*m1*m2/(r**2) #gravitational force\n", - "print(\"Coulomb force in nt is\",F1)\n", - "print(\"Gravitational force in nt is\",F2)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 26.5 Repulsive force between two protons in a nucleus of iron" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Repulsive coulomb force F 14.4 nt\n" - ] - } - ], - "source": [ - "#Example 5\n", - "\n", - "r=4*10**-15 #separation between proton annd nucleus in iron in meters\n", - "q=1.6*10**-19 #charge in coul\n", - "F=(9*10**9)*(q**2)/(r**2) #coulomb's law\n", - "print(\"Repulsive coulomb force F \",F,'nt')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/NityaL/Sample.ipynb b/sample_notebooks/NityaL/Sample.ipynb deleted file mode 100755 index c7730277..00000000 --- a/sample_notebooks/NityaL/Sample.ipynb +++ /dev/null @@ -1,236 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 26:CHARGE AND MATTER" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "##Example 26.1 Magnitude of total charges in a copper penny" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Magnitude of the charges in coulombs is 133687.50000000003\n" - ] - } - ], - "source": [ - "#Example 1.1\n", - "\n", - "m =3.1 #mass of copper penny in grams\n", - "e =4.6*10** -18 #charge in coulombs\n", - "N0 =6*10**23 #avogadro’s number atoms / mole\n", - "M =64 #molecular weight of copper in gm/ mole\n", - "\n", - "#Calculation\n", - "N =( N0 * m ) / M #No. of copper atoms in penny\n", - "q = N * e # magnitude of the charges in coulombs\n", - "print (\" Magnitude of the charges in coulomb is \",q )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "##Example 26.2 Separation between total positive and negative charges" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Separation between total positive and negative charges in meters is 5813776741.499454\n" - ] - } - ], - "source": [ - "#Example 2\n", - "\n", - "import math\n", - "\n", - "F =4.5 #Force of attraction in nt\n", - "q =1.3*10**5 #total charge in coulomb\n", - "r = q * math.sqrt ((9*10**9) / F ) ;\n", - "print(\" Separation between total positive and negative charges in meters is \",r )" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "##Example 26.3 Force acting on charge q1" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "X component of resultant force acting on q1 in nt is 2.0999999999999996\n", - "Y component of resultant force acting on q1 in nt is -1.5588457268119893\n" - ] - } - ], - "source": [ - "#Example 3\n", - "\n", - "import math\n", - "\n", - "#given three charges q1,q2,q3\n", - "q1=-1.0*10**-6 #charge in coul\n", - "q2=+3.0*10**-6 #charge in coul\n", - "q3=-2.0*10**-6 #charge in coul\n", - "r12=15*10**-2 #separation between q1 and q2 in m\n", - "r13=10*10**-2 # separation between q1 and q3 in m\n", - "angle=math.pi/6 #in degrees\n", - "F12=(9.0*10**9)*q1*q2/(r12**2) #in nt\n", - "F13=(9.0*10**9)*q1*q3/(r13**2) #in nt\n", - "F12x=-F12 #ignoring signs of charges\n", - "F13x=F13*math.sin(angle);\n", - "F1x=F12x+F13x\n", - "F12y=0 #from fig.263\n", - "F13y=-F13*math.cos(angle);\n", - "F1y=F12y+F13y #in nt\n", - "print(\"X component of resultant force acting on q1 in nt is\",F1x)\n", - "print(\"Y component of resultant force acting on q1 in nt is\",F1y)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "##Example 26.4 Electrical and Gravitational force between two particles" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Coulomb force in nt is 8.202207191171238e-08\n", - "Gravitational force in nt is 3.689889640441438e-47\n" - ] - } - ], - "source": [ - "#Example 4\n", - "\n", - "r=5.3*10**-11 #distance between electron and proton in the hydrogen atom in meter\n", - "e=1.6*10**-19 #charge in coul\n", - "G=6.7*10**-11 #gravitatinal constant in nt-m2/kg2\n", - "m1=9.1*10**-31 #mass of electron in kg\n", - "m2=1.7*10**-27 #mass of proton in kg\n", - "F1=(9*10**9)*e*e/(r**2) #coulomb's law\n", - "F2=G*m1*m2/(r**2) #gravitational force\n", - "print(\"Coulomb force in nt is\",F1)\n", - "print(\"Gravitational force in nt is\",F2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "##Example 26.5 Repulsive force between two protons in a nucleus of iron" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Repulsive coulomb force F 14.4 nt\n" - ] - } - ], - "source": [ - "#Example 5\n", - "\n", - "r=4*10**-15 #separation between proton annd nucleus in iron in meters\n", - "q=1.6*10**-19 #charge in coul\n", - "F=(9*10**9)*(q**2)/(r**2) #coulomb's law\n", - "print(\"Repulsive coulomb force F \",F,'nt')" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.4.3" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/NivethaChezhian/NivethaChezhian_version_backup/Sample.ipynb b/sample_notebooks/NivethaChezhian/NivethaChezhian_version_backup/Sample.ipynb new file mode 100755 index 00000000..d14818c1 --- /dev/null +++ b/sample_notebooks/NivethaChezhian/NivethaChezhian_version_backup/Sample.ipynb @@ -0,0 +1,68 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:25987a4a9da0545d9c4c2518a85172c533cb91c125ae9df53acb145c94c690e6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2:Energy levels and energy bands" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Sec.2-3,Pg_no:40" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To calculate the number of photons per second\n", + "\n", + "#variable declaration\n", + "E=(12400.0/2537.0) #Energy per photon\n", + "p=0.05/(1.60*(10**(-19))) #power radiated\n", + "\n", + "#Calculation\n", + "n=p/E #number of photons per second\n", + "\n", + "#Result\n", + "print \"The number of photons per second is\",round(n,2),\"photons/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The number of photons per second is 6.39364919355e+16 photons/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/NivethaChezhian/Sample_Notebook.ipynb b/sample_notebooks/NivethaChezhian/Sample_Notebook.ipynb deleted file mode 100755 index d14818c1..00000000 --- a/sample_notebooks/NivethaChezhian/Sample_Notebook.ipynb +++ /dev/null @@ -1,68 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:25987a4a9da0545d9c4c2518a85172c533cb91c125ae9df53acb145c94c690e6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2:Energy levels and energy bands" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Sec.2-3,Pg_no:40" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To calculate the number of photons per second\n", - "\n", - "#variable declaration\n", - "E=(12400.0/2537.0) #Energy per photon\n", - "p=0.05/(1.60*(10**(-19))) #power radiated\n", - "\n", - "#Calculation\n", - "n=p/E #number of photons per second\n", - "\n", - "#Result\n", - "print \"The number of photons per second is\",round(n,2),\"photons/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The number of photons per second is 6.39364919355e+16 photons/sec\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/PRAVEENKUMAR C/CHAPTER_1.ipynb b/sample_notebooks/PRAVEENKUMAR C/CHAPTER_1.ipynb deleted file mode 100755 index e2b145a8..00000000 --- a/sample_notebooks/PRAVEENKUMAR C/CHAPTER_1.ipynb +++ /dev/null @@ -1,66 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The weight of a car in newton,W= 13734.0 N\n", - "The mass of the car in slugs,m= 95.9 slugs\n", - "The weight of the car in pounds,W= 3089.0 lb\n", - "The mass of the car in lbm,m= 3086.0 lbm\n" - ] - } - ], - "source": [ - "# CHAPTER 1:INTRODUCTION TO FLUID STATICS\n", - "# SAMPLE PROBLEM 1/1,PAGE NUMBER:19\n", - "\n", - "import math\n", - "\n", - "#Variable Declaration\n", - "m=1400; # Mass of car in kg\n", - "\n", - "#Calculation\n", - "g=9.81; # The acceleration due to gravity in m/s^2\n", - "W_1=m*g;# Weight in N\n", - "m_1=m/14.594;# Mass of the car in slugs (1slug=14.594kg)\n", - "g=32.2; # The acceleration due to gravity in ft/s^2\n", - "W_2=m_1*g;# Weight in pounds (lb)\n", - "m_2=m/0.45359; #Mass of the car in lbm\n", - "print \"The weight of a car in newton,W=\",round(W_1,0),\"N\"\n", - "print \"The mass of the car in slugs,m=\",round(m_1,1),\"slugs\"\n", - "print \"The weight of the car in pounds,W=\",round(W_2,0),\"lb\"\n", - "print \"The mass of the car in lbm,m=\",round(m_2,0),\"lbm\"\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PRAVEENKUMAR C/PRAVEENKUMAR C_version_backup/CHAPTER_1.ipynb b/sample_notebooks/PRAVEENKUMAR C/PRAVEENKUMAR C_version_backup/CHAPTER_1.ipynb new file mode 100755 index 00000000..e2b145a8 --- /dev/null +++ b/sample_notebooks/PRAVEENKUMAR C/PRAVEENKUMAR C_version_backup/CHAPTER_1.ipynb @@ -0,0 +1,66 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The weight of a car in newton,W= 13734.0 N\n", + "The mass of the car in slugs,m= 95.9 slugs\n", + "The weight of the car in pounds,W= 3089.0 lb\n", + "The mass of the car in lbm,m= 3086.0 lbm\n" + ] + } + ], + "source": [ + "# CHAPTER 1:INTRODUCTION TO FLUID STATICS\n", + "# SAMPLE PROBLEM 1/1,PAGE NUMBER:19\n", + "\n", + "import math\n", + "\n", + "#Variable Declaration\n", + "m=1400; # Mass of car in kg\n", + "\n", + "#Calculation\n", + "g=9.81; # The acceleration due to gravity in m/s^2\n", + "W_1=m*g;# Weight in N\n", + "m_1=m/14.594;# Mass of the car in slugs (1slug=14.594kg)\n", + "g=32.2; # The acceleration due to gravity in ft/s^2\n", + "W_2=m_1*g;# Weight in pounds (lb)\n", + "m_2=m/0.45359; #Mass of the car in lbm\n", + "print \"The weight of a car in newton,W=\",round(W_1,0),\"N\"\n", + "print \"The mass of the car in slugs,m=\",round(m_1,1),\"slugs\"\n", + "print \"The weight of the car in pounds,W=\",round(W_2,0),\"lb\"\n", + "print \"The mass of the car in lbm,m=\",round(m_2,0),\"lbm\"\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta.ipynb b/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta.ipynb deleted file mode 100755 index 3f6a6b0c..00000000 --- a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta.ipynb +++ /dev/null @@ -1,753 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#Chapter 2 : Molecular Diffusion" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.1 Page no. 10" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Molar average velocity of gas mixture is: 0.0303 m/s\n", - "Mass average velocity of gas mixture is: 0.029 m/s\n" - ] - } - ], - "source": [ - "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", - "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", - "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", - "Ar = 0.04 #mole fraction of Argon denoted as 4\n", - "u1 = 0.03\n", - "u2 = 0.035\n", - "u3 = 0.03\n", - "u4 = 0.02\n", - "#Calculating molar average velocity\n", - "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", - "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", - "#Calculating of mass average velocity\n", - "M1 = 28\n", - "M2 = 2\n", - "M3 = 17\n", - "M4 = 40\n", - "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", - "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", - "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " ##Example 2.2 Page no. 16" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false, - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Time for complete evaporation is: 15.93 hours\n", - "(b) Time for disappearance of water is: 8.87 hours\n" - ] - } - ], - "source": [ - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "\n", - "#Calcualtion for (a) part\n", - "#calculating vapor pressure of water at 301K\n", - "pv = exp(13.8573 - (5160.2/301)) #in bar\n", - "#wet-bulb temperature is 22.5 degree centigrade\n", - "#calculating mean air-film temperature\n", - "Tm = ((28+22.5)/2)+273 #in kelvin\n", - "#calculating diffusion coefficient\n", - "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", - "l = 2.5e-3 #in m\n", - "P = 1.013 #in bar\n", - "R = 0.08317 #Gas constant\n", - "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", - "pAl = 0.6*round(pv,4)\n", - "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", - "#amount of water per m^2 of floor area is\n", - "thickness = 2e-3\n", - "Amount = thickness*1 #in m^3 \n", - "#density of water is 1000kg/m^3\n", - "#therefore in kg it is\n", - "amount = Amount*1000\n", - "Time_for_completion = amount/Na #in seconds\n", - "Time_for_completion_hours = Time_for_completion/3600\n", - "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", - "\n", - "#Calculation for (b) part\n", - "water_loss = 0.1 #in kg/m^2.h\n", - "water_loss_by_evaporation = Na*3600\n", - "total_water_loss = water_loss + water_loss_by_evaporation\n", - "time_for_disappearance = amount/total_water_loss\n", - "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.3 Page no. 17" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", - "(b) and (c)\n", - "Velocity of A is 0.522 cm/s\n", - "Velocity of B is 0.000 cm/s\n", - "Mass average velocity of A is 0.439 cm/s\n", - "Molar average velocity of A is 0.47 cm/s\n", - "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb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z5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%matplotlib inline\n", - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "#calculation for (a) part\n", - "l = 1 #thickness of air in cm\n", - "pAo = 0.9 #in atm\n", - "pAl = 0.1 #in atm\n", - "Dab = 0.214 #in cm^2/s\n", - "T = 298 #in K\n", - "P = 1 #in atm\n", - "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", - "#calculating molar flux of ammonia\n", - "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", - "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", - "\n", - "#calculation for (b) and (c) part\n", - "Nb = 0 #air is non-diffusing\n", - "U = (Na/(P/(R*T))) #molar average velocity\n", - "yA = pAo/P\n", - "yB = pAl/P\n", - "uA = U/yA #\n", - "uB = 0 #since Nb=0\n", - "Ma = 17\n", - "Mb = 29\n", - "M = Ma*yA + Mb*yB\n", - "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", - "print '(b) and (c)'\n", - "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", - "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", - "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", - "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", - "\n", - "#calculation for (d) part\n", - "Ca = pAo/(R*T)\n", - "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", - " #with the mass average velocity \n", - "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", - "\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(1-(0.1*exp(2.197*z[i])))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.4 Page no. 19" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", - "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", - "(c)\n", - "Molar average velocity and diffusion velocities at \"midway\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 7.9E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"top of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 3.72E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen is not infinity\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "(d)\n", - "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", - "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1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w4EOZrYMGEdogmzw96am8BARkYyS3PQkIiIJoEQhIiIZKVGIiEhGShQiIpKREoWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#calculation of (a) part\n", - "#given data\n", - "from math import log\n", - "from math import pi\n", - "from math import exp\n", - "import numpy as np\n", - "T = 298 #in kelvin\n", - "P = 1.013 #in bar\n", - "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", - "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", - "l = 0.05 #length of diffusion path in m\n", - "Dab = 2.1e-5 #diffusivity in m^2/s\n", - "R = 0.08317 #in m^3.bar.kmol.K\n", - "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", - "area = (pi/4)*(0.015)**2\n", - "rate = area*Na\n", - "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "\n", - "#calculation of (b) part\n", - "z = 0.025 #diffusion path\n", - "pA = 0.113 #in bar\n", - "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", - "#let dpA/dz = ppd\n", - "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", - "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", - "\n", - "#calculation of (c) part\n", - "uA = Na*(R*T/pA) #velocity of oxygen\n", - "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", - "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", - "vAd = uA - U #diffusion velocity of oxygen\n", - "vBd = uB - U #diffusion velocity of nitrogen\n", - "print '(c)'\n", - "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0(at top of tube)\n", - "uA = Na*(R*T/pAo)\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0.05(at bottom of tube)\n", - "#uA = inf\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen is not infinity'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "\n", - "#calculation of (d) part\n", - "V = -2*U\n", - "pA = 0.113\n", - "Nad = round(Na,8) - V*(pA/(R*T))\n", - "Nbd = 0 - (P - pA)*V/(R*T)\n", - "print '(d)'\n", - "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", - "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.5 Page no. 21" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The air-film thickness is :0.00193 m\n" - ] - } - ], - "source": [ - "from math import log\n", - "#given data\n", - "area = 3*4 #in m^2\n", - "mperarea = 3.0/12 #in kg/m^2\n", - "#part (a)\n", - "P = 1.013 #in bar\n", - "Dab = 9.95e-6 #in m^2/s\n", - "R = 0.08317 #in m^3.bar./K.kmol\n", - "T = 273+27 #in K\n", - "#let d=1\n", - "d = 1 #in m\n", - "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", - "pAd = 0 #partial pressure over d length of stagnant film of air\n", - "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", - "Na = Na*60 #in kg/m^2.s\n", - "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", - "#now we have to find the value of d\n", - "d = Na/flux\n", - "print '(a) The air-film thickness is :%0.5f'%d,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.6 Page no. 24" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)\n", - "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", - "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", - "(b)\n", - "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", - "(c)\n", - "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", - "(d)\n", - "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "from math import pi\n", - "#given data\n", - "#part (a)\n", - "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", - "pA1 = 2*0.8 #in atm\n", - "pA2 = 2*0.2 #in atm\n", - "l = 0.15 #in m\n", - "R = 0.0821 #in m^3.atm./K.kmol\n", - "T = 293 #in K\n", - "Ma = 28\n", - "Mb = 32\n", - "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", - "area = pi/4*(0.05)**2 #in m^2\n", - "rate = area*Na\n", - "print '(a)'\n", - "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", - "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", - "\n", - "#part (b)\n", - "Nb = -Na\n", - "print '(b)'\n", - "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", - "\n", - "#part (c)\n", - "#let dpA/dz = ppg\n", - "dz = 0.05 #in m\n", - "ppg = (pA2 - pA1)/l #in atm/m\n", - "pA = pA1 + (ppg)*dz #in atm\n", - "print '(c)'\n", - "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", - "\n", - "#part (d)\n", - "nt = Ma*Na + Mb*Nb\n", - "print '(d)'\n", - "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.7 Page no. 25" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Methanol flux: 4.64e-05 kmol/m^2.s\n", - "Water flux: -4.06e-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "from math import log\n", - "#given data\n", - "Ha = 274.6*32 #molar latent heat of methanol(a)\n", - "Hb = 557.7*18 #molar latent heat of water(b)\n", - "yAl = 0.76 #mole fraction of methanol in the vapour\n", - "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", - "P = 1 #in atm\n", - "l = 1e-3 #in m\n", - "T =344.2 #in K\n", - "R = 0.0821 #m^3.atm./K.kmol\n", - "Dab = 1.816e-5 #in m^2/s\n", - "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", - "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", - "Nb = -(Ha/Hb)*Na\n", - "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.8 Page no. 27" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of pA1 is 0.937 atm\n" - ] - } - ], - "source": [ - "#given values\n", - "from math import exp\n", - "V1 = 3000 #in cm^3\n", - "V2 = 4000 #in cm^3\n", - "Dab = 0.23 #in cm^2/s\n", - "Dba = 0.23 #in cm^2/s\n", - "l1 = 4 #in cm\n", - "d1 = 0.5 #in cm\n", - "l2 = 2 #in cm\n", - "d2 = 0.3 #in cm\n", - "pA3 = 1 #in atm\n", - "#unknowns\n", - "# pA1 and pA2\n", - "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", - "#on integrating using Laplace trandformation\n", - "# initial conditions\n", - "t=18000 #in seconds\n", - "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", - "print 'Value of pA1 is %0.3f'%pA1,'atm'" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.10 Page no.34" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#given values\n", - "from math import log\n", - "y1l = 0 #mol fraction of dry air\n", - "y10 = (17.53/760) #mol fraction of water\n", - "l = 1.5 #in mm\n", - "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", - "D12 = 0.923 #Diffusivity of hydrogen over water\n", - "D13 = 0.267 #Diffusivity of oxygen over water\n", - "y2 = 0.6 #mole fraction of hydrogen\n", - "y3 = 0.4 #mole fraction of oxygen\n", - "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", - "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", - "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.11 Page no. 35" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flux of ethane 4.804E-05 gmol/cm^2.s\n" - ] - } - ], - "source": [ - "from math import log\n", - "#given data\n", - "y1 = 0.4 #mole fraction of ethane(1)\n", - "y2 = 0.3 #mole fraction of ethylene(2)\n", - "y3 = 0.3 #mole fraction of hydrogen(3)\n", - "#calculating D13\n", - "#The Lennard-Jones parameters are\n", - "sigma1 = 4.443 #in angstrom\n", - "sigma2 = 4.163 #in angstrom\n", - "sigma3 = 2.827 #in angstrom\n", - "e1byk = 215.7\n", - "e2byk = 224.7\n", - "e3byk = 59.7\n", - "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", - "e13byk = (e1byk*e3byk)**0.5\n", - "kTbye13 = 993/113.5\n", - "ohmD13 = 0.76 #from collision integral table\n", - "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", - "#calculating D23\n", - "sigma23 = (sigma2+sigma3)/2\n", - "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", - "ohmD23 = 0.762\n", - "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", - "D = (D13+D23)/2 #in cm^2/s\n", - "l = 0.15 #in cm\n", - "#at z=0 (bulk gas)\n", - "y10 = 0.6\n", - "y20 = 0.2\n", - "y30 = 0.2\n", - "#at z=l (catalyst surface)\n", - "y1l = 0.4\n", - "y2l = 0.3\n", - "y3l = 0.3\n", - "C = 2.0/(82.1*993) #calculated by P/RT\n", - "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", - "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.12 Page no. 43" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The liquid-film thickness is: 0.0004 m\n" - ] - } - ], - "source": [ - "#given data\n", - "from math import pi\n", - "rc = 5e-4 #in m\n", - "D = 7e-10 #in m^2/s\n", - "Cab = 1 #in kmol/m^3\n", - "Na = 3.15e-6 #in kmol/m^2.s\n", - "W = 4*pi*(rc**2)*Na #the rate of reaction\n", - "#let (rc+delta)/delta = 1\n", - "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", - "rcplusdelta = W/w1\n", - "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", - "print 'The liquid-film thickness is: ',delta,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.13 Page no. 46" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tortuosity factor is: 2.5\n" - ] - } - ], - "source": [ - "#given data\n", - "from math import log\n", - "V1 = 60.2 #in cm^3; volume of compartment 1\n", - "V2 = 59.3 #volume of compartment 2 in cm^3\n", - "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", - "Ca2i = 0 #initial concentration of KCl in compartment 2\n", - "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", - "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", - "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", - "tf = 55.2*3600 #time of the experiment in s\n", - "#calcutaling cell constant\n", - "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", - "#diffusion of propionic acid\n", - "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", - "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", - "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", - "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", - "tfp = 56.4*3600 #time for the experiment\n", - "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", - "#calculating tortusity factor\n", - "A= (math.pi/4)*(3.5**2) #area of the diaphragm\n", - "epsilon = 0.39 #average porosity of the diaphragm\n", - "l = 0.18 #thickness of hte diaphragm\n", - "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", - "print 'Tortuosity factor is: ',round(tou,1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb b/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb deleted file mode 100755 index 958c7769..00000000 --- a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb +++ /dev/null @@ -1,789 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#Chapter 2 Molecular Diffusion" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.1 pgno:10" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Molar average velocity of gas mixture is: 0.0303 m/s\n", - "Mass average velocity of gas mixture is: 0.029 m/s\n" - ] - } - ], - "source": [ - "#Calculation of average velocities\n", - "\n", - "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", - "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", - "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", - "Ar = 0.04 #mole fraction of Argon denoted as 4\n", - "u1 = 0.03\n", - "u2 = 0.035\n", - "u3 = 0.03\n", - "u4 = 0.02\n", - "#Calculating molar average velocity\n", - "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", - "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", - "#Calculating of mass average velocity\n", - "M1 = 28\n", - "M2 = 2\n", - "M3 = 17\n", - "M4 = 40\n", - "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", - "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", - "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " ##Example 2.2 pgno:16" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false, - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Time for complete evaporation is: 15.93 hours\n", - "(b) Time for disappearance of water is: 8.87 hours\n" - ] - } - ], - "source": [ - "#Diffusion of A through non-diffusing B\n", - "\n", - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "\n", - "#Calcualtion for (a) part\n", - "#calculating vapor pressure of water at 301K\n", - "pv = exp(13.8573 - (5160.2/301)) #in bar\n", - "#wet-bulb temperature is 22.5 degree centigrade\n", - "#calculating mean air-film temperature\n", - "Tm = ((28+22.5)/2)+273 #in kelvin\n", - "#calculating diffusion coefficient\n", - "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", - "l = 2.5e-3 #in m\n", - "P = 1.013 #in bar\n", - "R = 0.08317 #Gas constant\n", - "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", - "pAl = 0.6*round(pv,4)\n", - "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", - "#amount of water per m^2 of floor area is\n", - "thickness = 2e-3\n", - "Amount = thickness*1 #in m^3 \n", - "#density of water is 1000kg/m^3\n", - "#therefore in kg it is\n", - "amount = Amount*1000\n", - "Time_for_completion = amount/Na #in seconds\n", - "Time_for_completion_hours = Time_for_completion/3600\n", - "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", - "\n", - "#Calculation for (b) part\n", - "water_loss = 0.1 #in kg/m^2.h\n", - "water_loss_by_evaporation = Na*3600\n", - "total_water_loss = water_loss + water_loss_by_evaporation\n", - "time_for_disappearance = amount/total_water_loss\n", - "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.3 pgno:17" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", - "(b) and (c)\n", - "Velocity of A is 0.522 cm/s\n", - "Velocity of B is 0.000 cm/s\n", - "Mass average velocity of A is 0.439 cm/s\n", - "Molar average velocity of A is 0.47 cm/s\n", - "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb981yruGsM04HwAM+sNfOLuH1RV0N11uHP99dfHHkOu\nHLoXuhe6FzUf9RVpjcHMHgKOAVqb2RrgeqAJgL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AsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#Calculation of flux and velocity\n", - "\n", - "%matplotlib inline\n", - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "#calculation for (a) part\n", - "l = 1 #thickness of air in cm\n", - "pAo = 0.9 #in atm\n", - "pAl = 0.1 #in atm\n", - "Dab = 0.214 #in cm^2/s\n", - "T = 298 #in K\n", - "P = 1 #in atm\n", - "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", - "#calculating molar flux of ammonia\n", - "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", - "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", - "\n", - "#calculation for (b) and (c) part\n", - "Nb = 0 #air is non-diffusing\n", - "U = (Na/(P/(R*T))) #molar average velocity\n", - "yA = pAo/P\n", - "yB = pAl/P\n", - "uA = U/yA #\n", - "uB = 0 #since Nb=0\n", - "Ma = 17\n", - "Mb = 29\n", - "M = Ma*yA + Mb*yB\n", - "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", - "print '(b) and (c)'\n", - "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", - "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", - "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", - "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", - "\n", - "#calculation for (d) part\n", - "Ca = pAo/(R*T)\n", - "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", - " #with the mass average velocity \n", - "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", - "\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(1-(0.1*exp(2.197*z[i])))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.4 pgno:19" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", - "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", - "(c)\n", - "Molar average velocity and diffusion velocities at \"midway\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 7.9E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"top of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 3.72E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen is not infinity\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "(d)\n", - "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", - "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX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oWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#Flux, velocity and pressure gradient\n", - "\n", - "#calculation of (a) part\n", - "#given data\n", - "from math import log\n", - "from math import pi\n", - "from math import exp\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "T = 298 #in kelvin\n", - "P = 1.013 #in bar\n", - "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", - "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", - "l = 0.05 #length of diffusion path in m\n", - "Dab = 2.1e-5 #diffusivity in m^2/s\n", - "R = 0.08317 #in m^3.bar.kmol.K\n", - "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", - "area = (pi/4)*(0.015)**2\n", - "rate = area*Na\n", - "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "\n", - "#calculation of (b) part\n", - "z = 0.025 #diffusion path\n", - "pA = 0.113 #in bar\n", - "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", - "#let dpA/dz = ppd\n", - "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", - "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", - "\n", - "#calculation of (c) part\n", - "uA = Na*(R*T/pA) #velocity of oxygen\n", - "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", - "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", - "vAd = uA - U #diffusion velocity of oxygen\n", - "vBd = uB - U #diffusion velocity of nitrogen\n", - "print '(c)'\n", - "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0(at top of tube)\n", - "uA = Na*(R*T/pAo)\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0.05(at bottom of tube)\n", - "#uA = inf\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen is not infinity'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "\n", - "#calculation of (d) part\n", - "V = -2*U\n", - "pA = 0.113\n", - "Nad = round(Na,8) - V*(pA/(R*T))\n", - "Nbd = 0 - (P - pA)*V/(R*T)\n", - "print '(d)'\n", - "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", - "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.5 pgno:21" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The air-film thickness is :0.00193 m\n" - ] - } - ], - "source": [ - "#Diffusion with changing bulk concentration\n", - "\n", - "from math import log\n", - "#given data\n", - "area = 3*4 #in m^2\n", - "mperarea = 3.0/12 #in kg/m^2\n", - "#part (a)\n", - "P = 1.013 #in bar\n", - "Dab = 9.95e-6 #in m^2/s\n", - "R = 0.08317 #in m^3.bar./K.kmol\n", - "T = 273+27 #in K\n", - "#let d=1\n", - "d = 1 #in m\n", - "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", - "pAd = 0 #partial pressure over d length of stagnant film of air\n", - "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", - "Na = Na*60 #in kg/m^2.s\n", - "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", - "#now we have to find the value of d\n", - "d = Na/flux\n", - "print '(a) The air-film thickness is :%0.5f'%d,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.6 pgno:24" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)\n", - "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", - "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", - "(b)\n", - "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", - "(c)\n", - "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", - "(d)\n", - "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Equimolar counterdiffusion\n", - "\n", - "from math import pi\n", - "#given data\n", - "#part (a)\n", - "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", - "pA1 = 2*0.8 #in atm\n", - "pA2 = 2*0.2 #in atm\n", - "l = 0.15 #in m\n", - "R = 0.0821 #in m^3.atm./K.kmol\n", - "T = 293 #in K\n", - "Ma = 28\n", - "Mb = 32\n", - "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", - "area = pi/4*(0.05)**2 #in m^2\n", - "rate = area*Na\n", - "print '(a)'\n", - "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", - "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", - "\n", - "#part (b)\n", - "Nb = -Na\n", - "print '(b)'\n", - "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", - "\n", - "#part (c)\n", - "#let dpA/dz = ppg\n", - "dz = 0.05 #in m\n", - "ppg = (pA2 - pA1)/l #in atm/m\n", - "pA = pA1 + (ppg)*dz #in atm\n", - "print '(c)'\n", - "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", - "\n", - "#part (d)\n", - "nt = Ma*Na + Mb*Nb\n", - "print '(d)'\n", - "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.7 pgno:25" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Methanol flux: 4.64e-05 kmol/m^2.s\n", - "Water flux: -4.06e-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Non-equimolar counterdiffusion in distillation of a binary mixture\n", - "\n", - "from math import log\n", - "#given data\n", - "Ha = 274.6*32 #molar latent heat of methanol(a)\n", - "Hb = 557.7*18 #molar latent heat of water(b)\n", - "yAl = 0.76 #mole fraction of methanol in the vapour\n", - "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", - "P = 1 #in atm\n", - "l = 1e-3 #in m\n", - "T =344.2 #in K\n", - "R = 0.0821 #m^3.atm./K.kmol\n", - "Dab = 1.816e-5 #in m^2/s\n", - "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", - "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", - "Nb = -(Ha/Hb)*Na\n", - "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.8 pgno:27" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of pA1 is 0.937 atm\n" - ] - } - ], - "source": [ - "#Equimolar counterdiffusion in an interconnected system\n", - "\n", - "#given values\n", - "from math import exp\n", - "V1 = 3000 #in cm^3\n", - "V2 = 4000 #in cm^3\n", - "Dab = 0.23 #in cm^2/s\n", - "Dba = 0.23 #in cm^2/s\n", - "l1 = 4 #in cm\n", - "d1 = 0.5 #in cm\n", - "l2 = 2 #in cm\n", - "d2 = 0.3 #in cm\n", - "pA3 = 1 #in atm\n", - "#unknowns\n", - "# pA1 and pA2\n", - "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", - "#on integrating using Laplace trandformation\n", - "# initial conditions\n", - "t=18000 #in seconds\n", - "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", - "print 'Value of pA1 is %0.3f'%pA1,'atm'" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.10 pgno:34" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Diffusion of only one component in a three-component mixture\n", - "\n", - "#given values\n", - "from math import log\n", - "y1l = 0 #mol fraction of dry air\n", - "y10 = (17.53/760) #mol fraction of water\n", - "l = 1.5 #in mm\n", - "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", - "D12 = 0.923 #Diffusivity of hydrogen over water\n", - "D13 = 0.267 #Diffusivity of oxygen over water\n", - "y2 = 0.6 #mole fraction of hydrogen\n", - "y3 = 0.4 #mole fraction of oxygen\n", - "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", - "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", - "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.11 pgno:35" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flux of ethane 4.804E-05 gmol/cm^2.s\n" - ] - } - ], - "source": [ - "#Multicomponent diffusion\n", - "\n", - "from math import log\n", - "#given data\n", - "y1 = 0.4 #mole fraction of ethane(1)\n", - "y2 = 0.3 #mole fraction of ethylene(2)\n", - "y3 = 0.3 #mole fraction of hydrogen(3)\n", - "#calculating D13\n", - "#The Lennard-Jones parameters are\n", - "sigma1 = 4.443 #in angstrom\n", - "sigma2 = 4.163 #in angstrom\n", - "sigma3 = 2.827 #in angstrom\n", - "e1byk = 215.7\n", - "e2byk = 224.7\n", - "e3byk = 59.7\n", - "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", - "e13byk = (e1byk*e3byk)**0.5\n", - "kTbye13 = 993/113.5\n", - "ohmD13 = 0.76 #from collision integral table\n", - "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", - "#calculating D23\n", - "sigma23 = (sigma2+sigma3)/2\n", - "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", - "ohmD23 = 0.762\n", - "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", - "D = (D13+D23)/2 #in cm^2/s\n", - "l = 0.15 #in cm\n", - "#at z=0 (bulk gas)\n", - "y10 = 0.6\n", - "y20 = 0.2\n", - "y30 = 0.2\n", - "#at z=l (catalyst surface)\n", - "y1l = 0.4\n", - "y2l = 0.3\n", - "y3l = 0.3\n", - "C = 2.0/(82.1*993) #calculated by P/RT\n", - "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", - "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.12 pgno:43" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The liquid-film thickness is: 0.0004 m\n" - ] - } - ], - "source": [ - "#Liquid-phase diffusion\n", - "\n", - "#given data\n", - "from math import pi\n", - "rc = 5e-4 #in m\n", - "D = 7e-10 #in m^2/s\n", - "Cab = 1 #in kmol/m^3\n", - "Na = 3.15e-6 #in kmol/m^2.s\n", - "W = 4*pi*(rc**2)*Na #the rate of reaction\n", - "#let (rc+delta)/delta = 1\n", - "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", - "rcplusdelta = W/w1\n", - "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", - "print 'The liquid-film thickness is: ',delta,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.13 pgno:46" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tortuosity factor is: 2.5\n" - ] - } - ], - "source": [ - "#Diffusivity determination--diaphragm cell\n", - "\n", - "#given data\n", - "from math import log\n", - "from math import pi\n", - "V1 = 60.2 #in cm^3; volume of compartment 1\n", - "V2 = 59.3 #volume of compartment 2 in cm^3\n", - "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", - "Ca2i = 0 #initial concentration of KCl in compartment 2\n", - "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", - "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", - "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", - "tf = 55.2*3600 #time of the experiment in s\n", - "#calcutaling cell constant\n", - "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", - "#diffusion of propionic acid\n", - "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", - "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", - "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", - "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", - "tfp = 56.4*3600 #time for the experiment\n", - "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", - "#calculating tortusity factor\n", - "A= (pi/4)*(3.5**2) #area of the diaphragm\n", - "epsilon = 0.39 #average porosity of the diaphragm\n", - "l = 0.18 #thickness of hte diaphragm\n", - "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", - "print 'Tortuosity factor is: ',round(tou,1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb b/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb deleted file mode 100755 index b67d0cbd..00000000 --- a/sample_notebooks/PrashantSahu/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb +++ /dev/null @@ -1,789 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Molecular Diffusion" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.1 pgno:10" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Molar average velocity of gas mixture is: 0.0303 m/s\n", - "Mass average velocity of gas mixture is: 0.029 m/s\n" - ] - } - ], - "source": [ - "#Calculation of average velocities\n", - "\n", - "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", - "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", - "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", - "Ar = 0.04 #mole fraction of Argon denoted as 4\n", - "u1 = 0.03\n", - "u2 = 0.035\n", - "u3 = 0.03\n", - "u4 = 0.02\n", - "#Calculating molar average velocity\n", - "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", - "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", - "#Calculating of mass average velocity\n", - "M1 = 28\n", - "M2 = 2\n", - "M3 = 17\n", - "M4 = 40\n", - "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", - "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", - "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.2 pgno:16" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false, - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Time for complete evaporation is: 15.93 hours\n", - "(b) Time for disappearance of water is: 8.87 hours\n" - ] - } - ], - "source": [ - "#Diffusion of A through non-diffusing B\n", - "\n", - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "\n", - "#Calcualtion for (a) part\n", - "#calculating vapor pressure of water at 301K\n", - "pv = exp(13.8573 - (5160.2/301)) #in bar\n", - "#wet-bulb temperature is 22.5 degree centigrade\n", - "#calculating mean air-film temperature\n", - "Tm = ((28+22.5)/2)+273 #in kelvin\n", - "#calculating diffusion coefficient\n", - "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", - "l = 2.5e-3 #in m\n", - "P = 1.013 #in bar\n", - "R = 0.08317 #Gas constant\n", - "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", - "pAl = 0.6*round(pv,4)\n", - "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", - "#amount of water per m^2 of floor area is\n", - "thickness = 2e-3\n", - "Amount = thickness*1 #in m^3 \n", - "#density of water is 1000kg/m^3\n", - "#therefore in kg it is\n", - "amount = Amount*1000\n", - "Time_for_completion = amount/Na #in seconds\n", - "Time_for_completion_hours = Time_for_completion/3600\n", - "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", - "\n", - "#Calculation for (b) part\n", - "water_loss = 0.1 #in kg/m^2.h\n", - "water_loss_by_evaporation = Na*3600\n", - "total_water_loss = water_loss + water_loss_by_evaporation\n", - "time_for_disappearance = amount/total_water_loss\n", - "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.3 pgno:17" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", - "(b) and (c)\n", - "Velocity of A is 0.522 cm/s\n", - "Velocity of B is 0.000 cm/s\n", - "Mass average velocity of A is 0.439 cm/s\n", - "Molar average velocity of A is 0.47 cm/s\n", - "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" - ] - }, - { - "data": { - "text/plain": [ - "" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmA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wd2fAvYpt8bOAOCRbefu/km5\n33ky9fNN4P+7+1sevnW9RdhpbJsPqLjSpUjOyZlF9ERyQWpv4HbufkUVLzvV7/XwdepnGfBVuefL\nqPh3ZhTmHiJSQFRjEEkxsyMI/Qfldz5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#Calculation of flux and velocity\n", - "\n", - "%matplotlib inline\n", - "from math import log\n", - "from math import exp\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "#calculation for (a) part\n", - "l = 1 #thickness of air in cm\n", - "pAo = 0.9 #in atm\n", - "pAl = 0.1 #in atm\n", - "Dab = 0.214 #in cm^2/s\n", - "T = 298 #in K\n", - "P = 1 #in atm\n", - "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", - "#calculating molar flux of ammonia\n", - "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", - "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", - "\n", - "#calculation for (b) and (c) part\n", - "Nb = 0 #air is non-diffusing\n", - "U = (Na/(P/(R*T))) #molar average velocity\n", - "yA = pAo/P\n", - "yB = pAl/P\n", - "uA = U/yA #\n", - "uB = 0 #since Nb=0\n", - "Ma = 17\n", - "Mb = 29\n", - "M = Ma*yA + Mb*yB\n", - "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", - "print '(b) and (c)'\n", - "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", - "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", - "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", - "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", - "\n", - "#calculation for (d) part\n", - "Ca = pAo/(R*T)\n", - "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", - " #with the mass average velocity \n", - "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", - "\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(1-(0.1*exp(2.197*z[i])))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "#Answers may vary due to round off error" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.4 pgno:19" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", - "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", - "(c)\n", - "Molar average velocity and diffusion velocities at \"midway\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 7.9E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"top of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 3.72E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen is not infinity\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "(d)\n", - "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", - "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX\nqNFwxVl81USjETXCfZfG+Y3xGl1elWgS0TglKlEQ0HKIIoiKIoKgIIOKEyJBhIZ+3j92td1gd3V1\nd506p6p/n7X2qlOnTp/zcBZdT++9z97b3B0REZHabBV3ACIikmxKFCIikpEShYiIZKREISIiGSlR\niIhIRkoUIiKSUUncATSEmemZXhGRBnB3q+/PFGyNwt1V3Bk3blzsMSSl6F7oXuheZC4NVbCJQkRE\n8kOJQkREMlKiKHBlZWVxh5AYuhdVdC+q6F40njWm3SouZuaFGLeISJzMDG9KndkiIpIfShQiIpKR\nEoWIiGSkRCEiIhkpUYiISEZKFCIikpEShYiIZKREISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZ\nJTJRmNlwM5tvZgvN7NdxxyMi0pQlbvZYM2sGLACGASuAWcAp7v5+tWM0e6yISD0V0+yxg4BF7r7E\n3cuBh4GRWx70/fdQUZH32EREmpySuAOoQRdgWbX3y4EDtjyoTRvYsAFKSmCbbULZeuvw2qJF1b4W\nLeouLVtWvdZUtt02lOrbLVrAVklMsyIiOZbERJFVm9LYseNxD7WKgw4qY9CgMjZsCDWN9es3L99/\nD+vW/fj999+H8u23sHJl2FdZKo/57ruq17Vrq7bXrw/JolWrkDhatdq8bLddKJXbrVtX7at8X72U\nlobSvHnUt1dEmopUKkUqlWr0eZLYR3EgMN7dh6ffjwUq3P3GasfE3kdRURGSxtq1tZd//SuU6ttr\n1lS9VpZvv616bd68KmmUloaaU2kptG0bttu2/XFp166qtG4NVu8WSBFpChraR5HERFFC6MweCnwC\nzKSJdGa7h5rM6tWhfPttKJXvV6+Gb74JpX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1ymSo9/dmYmsU7r7RzP4PMIXwRMN97v6+mZ2b/vxud3/GzEaY2SJgLTA6xpAjk829AK4B\n2gF3pf+SLnf3QXHFHJUs70WTkOXvyHwzmwy8A1QA97h70SWKLP9f/Bb4o5nNIfyRfLm7fx1b0BEx\ns4eAw4EOZrYMGEdogmzw96am8BARkYyS3PQkIiIJoEQhIiIZKVGIiEhGShQiIpKREoWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#Flux, velocity and pressure gradient\n", - "\n", - "#calculation of (a) part\n", - "#given data\n", - "from math import log\n", - "from math import pi\n", - "from math import exp\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "T = 298 #in kelvin\n", - "P = 1.013 #in bar\n", - "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", - "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", - "l = 0.05 #length of diffusion path in m\n", - "Dab = 2.1e-5 #diffusivity in m^2/s\n", - "R = 0.08317 #in m^3.bar.kmol.K\n", - "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", - "area = (pi/4)*(0.015)**2\n", - "rate = area*Na\n", - "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "\n", - "#calculation of (b) part\n", - "z = 0.025 #diffusion path\n", - "pA = 0.113 #in bar\n", - "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", - "#let dpA/dz = ppd\n", - "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", - "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", - "\n", - "#calculation of (c) part\n", - "uA = Na*(R*T/pA) #velocity of oxygen\n", - "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", - "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", - "vAd = uA - U #diffusion velocity of oxygen\n", - "vBd = uB - U #diffusion velocity of nitrogen\n", - "print '(c)'\n", - "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0(at top of tube)\n", - "uA = Na*(R*T/pAo)\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0.05(at bottom of tube)\n", - "#uA = inf\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen is not infinity'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "\n", - "#calculation of (d) part\n", - "V = -2*U\n", - "pA = 0.113\n", - "Nad = round(Na,8) - V*(pA/(R*T))\n", - "Nbd = 0 - (P - pA)*V/(R*T)\n", - "print '(d)'\n", - "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", - "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.5 pgno:21" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The air-film thickness is :0.00193 m\n" - ] - } - ], - "source": [ - "#Diffusion with changing bulk concentration\n", - "\n", - "from math import log\n", - "#given data\n", - "area = 3*4 #in m^2\n", - "mperarea = 3.0/12 #in kg/m^2\n", - "#part (a)\n", - "P = 1.013 #in bar\n", - "Dab = 9.95e-6 #in m^2/s\n", - "R = 0.08317 #in m^3.bar./K.kmol\n", - "T = 273+27 #in K\n", - "#let d=1\n", - "d = 1 #in m\n", - "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", - "pAd = 0 #partial pressure over d length of stagnant film of air\n", - "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", - "Na = Na*60 #in kg/m^2.s\n", - "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", - "#now we have to find the value of d\n", - "d = Na/flux\n", - "print '(a) The air-film thickness is :%0.5f'%d,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.6 pgno:24" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)\n", - "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", - "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", - "(b)\n", - "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", - "(c)\n", - "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", - "(d)\n", - "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Equimolar counterdiffusion\n", - "\n", - "from math import pi\n", - "#given data\n", - "#part (a)\n", - "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", - "pA1 = 2*0.8 #in atm\n", - "pA2 = 2*0.2 #in atm\n", - "l = 0.15 #in m\n", - "R = 0.0821 #in m^3.atm./K.kmol\n", - "T = 293 #in K\n", - "Ma = 28\n", - "Mb = 32\n", - "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", - "area = pi/4*(0.05)**2 #in m^2\n", - "rate = area*Na\n", - "print '(a)'\n", - "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", - "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", - "\n", - "#part (b)\n", - "Nb = -Na\n", - "print '(b)'\n", - "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", - "\n", - "#part (c)\n", - "#let dpA/dz = ppg\n", - "dz = 0.05 #in m\n", - "ppg = (pA2 - pA1)/l #in atm/m\n", - "pA = pA1 + (ppg)*dz #in atm\n", - "print '(c)'\n", - "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", - "\n", - "#part (d)\n", - "nt = Ma*Na + Mb*Nb\n", - "print '(d)'\n", - "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.7 pgno:25" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Methanol flux: 4.64e-05 kmol/m^2.s\n", - "Water flux: -4.06e-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Non-equimolar counterdiffusion in distillation of a binary mixture\n", - "\n", - "from math import log\n", - "#given data\n", - "Ha = 274.6*32 #molar latent heat of methanol(a)\n", - "Hb = 557.7*18 #molar latent heat of water(b)\n", - "yAl = 0.76 #mole fraction of methanol in the vapour\n", - "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", - "P = 1 #in atm\n", - "l = 1e-3 #in m\n", - "T =344.2 #in K\n", - "R = 0.0821 #m^3.atm./K.kmol\n", - "Dab = 1.816e-5 #in m^2/s\n", - "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", - "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", - "Nb = -(Ha/Hb)*Na\n", - "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", - "#Answers may vary due to round off errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.8 pgno:27" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of pA1 is 0.937 atm\n" - ] - } - ], - "source": [ - "#Equimolar counterdiffusion in an interconnected system\n", - "\n", - "#given values\n", - "from math import exp\n", - "V1 = 3000 #in cm^3\n", - "V2 = 4000 #in cm^3\n", - "Dab = 0.23 #in cm^2/s\n", - "Dba = 0.23 #in cm^2/s\n", - "l1 = 4 #in cm\n", - "d1 = 0.5 #in cm\n", - "l2 = 2 #in cm\n", - "d2 = 0.3 #in cm\n", - "pA3 = 1 #in atm\n", - "#unknowns\n", - "# pA1 and pA2\n", - "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", - "#on integrating using Laplace trandformation\n", - "# initial conditions\n", - "t=18000 #in seconds\n", - "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", - "print 'Value of pA1 is %0.3f'%pA1,'atm'" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.10 pgno:34" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#Diffusion of only one component in a three-component mixture\n", - "\n", - "#given values\n", - "from math import log\n", - "y1l = 0 #mol fraction of dry air\n", - "y10 = (17.53/760) #mol fraction of water\n", - "l = 1.5 #in mm\n", - "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", - "D12 = 0.923 #Diffusivity of hydrogen over water\n", - "D13 = 0.267 #Diffusivity of oxygen over water\n", - "y2 = 0.6 #mole fraction of hydrogen\n", - "y3 = 0.4 #mole fraction of oxygen\n", - "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", - "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", - "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.11 pgno:35" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flux of ethane 4.804E-05 gmol/cm^2.s\n" - ] - } - ], - "source": [ - "#Multicomponent diffusion\n", - "\n", - "from math import log\n", - "#given data\n", - "y1 = 0.4 #mole fraction of ethane(1)\n", - "y2 = 0.3 #mole fraction of ethylene(2)\n", - "y3 = 0.3 #mole fraction of hydrogen(3)\n", - "#calculating D13\n", - "#The Lennard-Jones parameters are\n", - "sigma1 = 4.443 #in angstrom\n", - "sigma2 = 4.163 #in angstrom\n", - "sigma3 = 2.827 #in angstrom\n", - "e1byk = 215.7\n", - "e2byk = 224.7\n", - "e3byk = 59.7\n", - "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", - "e13byk = (e1byk*e3byk)**0.5\n", - "kTbye13 = 993/113.5\n", - "ohmD13 = 0.76 #from collision integral table\n", - "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", - "#calculating D23\n", - "sigma23 = (sigma2+sigma3)/2\n", - "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", - "ohmD23 = 0.762\n", - "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", - "D = (D13+D23)/2 #in cm^2/s\n", - "l = 0.15 #in cm\n", - "#at z=0 (bulk gas)\n", - "y10 = 0.6\n", - "y20 = 0.2\n", - "y30 = 0.2\n", - "#at z=l (catalyst surface)\n", - "y1l = 0.4\n", - "y2l = 0.3\n", - "y3l = 0.3\n", - "C = 2.0/(82.1*993) #calculated by P/RT\n", - "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", - "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.12 pgno:43" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The liquid-film thickness is: 0.0004 m\n" - ] - } - ], - "source": [ - "#Liquid-phase diffusion\n", - "\n", - "#given data\n", - "from math import pi\n", - "rc = 5e-4 #in m\n", - "D = 7e-10 #in m^2/s\n", - "Cab = 1 #in kmol/m^3\n", - "Na = 3.15e-6 #in kmol/m^2.s\n", - "W = 4*pi*(rc**2)*Na #the rate of reaction\n", - "#let (rc+delta)/delta = 1\n", - "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", - "rcplusdelta = W/w1\n", - "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", - "print 'The liquid-film thickness is: ',delta,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.13 pgno:46" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tortuosity factor is: 2.5\n" - ] - } - ], - "source": [ - "#Diffusivity determination--diaphragm cell\n", - "\n", - "#given data\n", - "from math import log\n", - "from math import pi\n", - "V1 = 60.2 #in cm^3; volume of compartment 1\n", - "V2 = 59.3 #volume of compartment 2 in cm^3\n", - "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", - "Ca2i = 0 #initial concentration of KCl in compartment 2\n", - "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", - "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", - "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", - "tf = 55.2*3600 #time of the experiment in s\n", - "#calcutaling cell constant\n", - "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", - "#diffusion of propionic acid\n", - "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", - "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", - "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", - "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", - "tfp = 56.4*3600 #time for the experiment\n", - "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", - "#calculating tortusity factor\n", - "A= (pi/4)*(3.5**2) #area of the diaphragm\n", - "epsilon = 0.39 #average porosity of the diaphragm\n", - "l = 0.18 #thickness of hte diaphragm\n", - "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", - "print 'Tortuosity factor is: ',round(tou,1)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PrashantSahu/Chapter_2_Molecular.ipynb b/sample_notebooks/PrashantSahu/Chapter_2_Molecular.ipynb new file mode 100755 index 00000000..7df6880b --- /dev/null +++ b/sample_notebooks/PrashantSahu/Chapter_2_Molecular.ipynb @@ -0,0 +1,657 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter 2 : Molecular Diffusion\n", + "##Example 2.1 " + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Molar average velocity of gas mixture is: 0.0303\n", + "Mass average velocity of gas mixture is: 0.029\n" + ] + } + ], + "source": [ + "import math\n", + "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", + "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", + "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", + "Ar = 0.04 #mole fraction of Argon denoted as 4\n", + "u1 = 0.03\n", + "u2 = 0.035\n", + "u3 = 0.03\n", + "u4 = 0.02\n", + "#Calculating molar average velocity\n", + "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", + "print 'Molar average velocity of gas mixture is: %.4f'%U\n", + "#Calculating of mass average velocity\n", + "M1 = 28\n", + "M2 = 2\n", + "M3 = 17\n", + "M4 = 40\n", + "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", + "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", + "print 'Mass average velocity of gas mixture is: %.3f'%u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " ##Example 2.2" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Time for complete evaporation is: 15.93 hours\n", + "(b) Time for disappearance of water is: 8.87 hours\n" + ] + } + ], + "source": [ + "import math\n", + "import numpy as np\n", + "\n", + "#Calcualtion for (a) part\n", + "#calculating vapor pressure of water at 301K\n", + "pv = math.exp(13.8573 - (5160.2/301)) #in bar\n", + "#wet-bulb temperature is 22.5 degree centigrade\n", + "#calculating mean air-film temperature\n", + "Tm = ((28+22.5)/2)+273 #in kelvin\n", + "#calculating diffusion coefficient\n", + "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", + "l = 2.5e-3 #in m\n", + "P = 1.013 #in bar\n", + "R = 0.08317 #Gas constant\n", + "pAo = math.exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", + "pAl = 0.6*round(pv,4)\n", + "Na = (((round(Dab,7)*P)/(R*298.2*l))*math.log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", + "#amount of water per m^2 of floor area is\n", + "thickness = 2e-3\n", + "Amount = thickness*1 #in m^3 \n", + "#density of water is 1000kg/m^3\n", + "#therefore in kg it is\n", + "amount = Amount*1000\n", + "Time_for_completion = amount/Na #in seconds\n", + "Time_for_completion_hours = Time_for_completion/3600\n", + "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", + "\n", + "#Calculation for (b) part\n", + "water_loss = 0.1 #in kg/m^2.h\n", + "water_loss_by_evaporation = Na*3600\n", + "total_water_loss = water_loss + water_loss_by_evaporation\n", + "time_for_disappearance = amount/total_water_loss\n", + "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.3" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", + "(b) and (c)\n", + "Velocity of A is 0.522 cm/s\n", + "Velocity of B is 0.000 cm/s\n", + "Mass average velocity of A is 0.439 cm/s\n", + "Molar average velocity of A is 0.47 cm/s\n", + "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eD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fldz5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%matplotlib inline\n", + "import matplotlib\n", + "import math\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "#calculation for (a) part\n", + "l = 1 #thickness of air in cm\n", + "pAo = 0.9 #in atm\n", + "pAl = 0.1 #in atm\n", + "Dab = 0.214 #in cm^2/s\n", + "T = 298 #in K\n", + "P = 1 #in atm\n", + "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", + "#calculating molar flux of ammonia\n", + "Na = ((Dab*P)/(R*T*l))*math.log((P-pAl)/(P-pAo))\n", + "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", + "\n", + "#calculation for (b) and (c) part\n", + "Nb = 0 #air is non-diffusing\n", + "U = (Na/(P/(R*T))) #molar average velocity\n", + "yA = pAo/P\n", + "yB = pAl/P\n", + "uA = U/yA #\n", + "uB = 0 #since Nb=0\n", + "Ma = 17\n", + "Mb = 29\n", + "M = Ma*yA + Mb*yB\n", + "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", + "print '(b) and (c)'\n", + "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", + "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", + "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", + "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", + "\n", + "#calculation for (d) part\n", + "Ca = pAo/(R*T)\n", + "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", + " #with the mass average velocity \n", + "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", + "\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(1-(0.1*math.exp(2.197*z[i])))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.4" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", + "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", + "(c)\n", + "Molar average velocity and diffusion velocities at \"midway\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 7.9E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"top of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 3.72E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen is not infinity\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "(d)\n", + "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", + "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3Xm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ARkYyS3PQkIiIJoEQhIiIZKVGIiEhGShQiIpKREoWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#calculation of (a) part\n", + "#given data\n", + "import math\n", + "T = 298 #in kelvin\n", + "P = 1.013 #in bar\n", + "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", + "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", + "l = 0.05 #length of diffusion path in m\n", + "Dab = 2.1e-5 #diffusivity in m^2/s\n", + "R = 0.08317 #in m^3.bar.kmol.K\n", + "Na = Dab*P*math.log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", + "area = (math.pi/4)*(0.015)**2\n", + "rate = area*Na\n", + "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(P-(P-pAo)*math.exp((R*T*Na*z[i])/(Dab*P)))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "\n", + "#calculation of (b) part\n", + "z = 0.025 #diffusion path\n", + "pA = 0.113 #in bar\n", + "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", + "#let dpA/dz = ppd\n", + "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", + "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", + "\n", + "#calculation of (c) part\n", + "uA = Na*(R*T/pA) #velocity of oxygen\n", + "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", + "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", + "vAd = uA - U #diffusion velocity of oxygen\n", + "vBd = uB - U #diffusion velocity of nitrogen\n", + "print '(c)'\n", + "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0(at top of tube)\n", + "uA = Na*(R*T/pAo)\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0.05(at bottom of tube)\n", + "#uA = inf\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen is not infinity'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "\n", + "#calculation of (d) part\n", + "V = -2*U\n", + "pA = 0.113\n", + "Nad = round(Na,8) - V*(pA/(R*T))\n", + "Nbd = 0 - (P - pA)*V/(R*T)\n", + "print '(d)'\n", + "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", + "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.5" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The air-film thickness is :0.00193 m\n" + ] + } + ], + "source": [ + "#given data\n", + "area = 3*4 #in m^2\n", + "mperarea = 3.0/12 #in kg/m^2\n", + "#part (a)\n", + "P = 1.013 #in bar\n", + "Dab = 9.95e-6 #in m^2/s\n", + "R = 0.08317 #in m^3.bar./K.kmol\n", + "T = 273+27 #in K\n", + "#let d=1\n", + "d = 1 #in m\n", + "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", + "pAd = 0 #partial pressure over d length of stagnant film of air\n", + "Na = (Dab*P*math.log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", + "Na = Na*60 #in kg/m^2.s\n", + "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", + "#now we have to find the value of d\n", + "d = Na/flux\n", + "print '(a) The air-film thickness is :%0.5f'%d,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.6" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)\n", + "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", + "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", + "(b)\n", + "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", + "(c)\n", + "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", + "(d)\n", + "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#given data\n", + "#part (a)\n", + "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", + "pA1 = 2*0.8 #in atm\n", + "pA2 = 2*0.2 #in atm\n", + "l = 0.15 #in m\n", + "R = 0.0821 #in m^3.atm./K.kmol\n", + "T = 293 #in K\n", + "Ma = 28\n", + "Mb = 32\n", + "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", + "area = math.pi/4*(0.05)**2 #in m^2\n", + "rate = area*Na\n", + "print '(a)'\n", + "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", + "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", + "\n", + "#part (b)\n", + "Nb = -Na\n", + "print '(b)'\n", + "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", + "\n", + "#part (c)\n", + "#let dpA/dz = ppg\n", + "dz = 0.05 #in m\n", + "ppg = (pA2 - pA1)/l #in atm/m\n", + "pA = pA1 + (ppg)*dz #in atm\n", + "print '(c)'\n", + "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", + "\n", + "#part (d)\n", + "nt = Ma*Na + Mb*Nb\n", + "print '(d)'\n", + "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.7" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Methanol flux: 4.64e-05 kmol/m^2.s\n", + "Water flux: -4.06e-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#given data\n", + "Ha = 274.6*32 #molar latent heat of methanol(a)\n", + "Hb = 557.7*18 #molar latent heat of water(b)\n", + "yAl = 0.76 #mole fraction of methanol in the vapour\n", + "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", + "P = 1 #in atm\n", + "l = 1e-3 #in m\n", + "T =344.2 #in K\n", + "R = 0.0821 #m^3.atm./K.kmol\n", + "Dab = 1.816e-5 #in m^2/s\n", + "Na = Dab*P*math.log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", + "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", + "Nb = -(Ha/Hb)*Na\n", + "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.8" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of pA1 is 0.937 atm\n" + ] + } + ], + "source": [ + "#given values\n", + "import math\n", + "V1 = 3000 #in cm^3\n", + "V2 = 4000 #in cm^3\n", + "Dab = 0.23 #in cm^2/s\n", + "Dba = 0.23 #in cm^2/s\n", + "l1 = 4 #in cm\n", + "d1 = 0.5 #in cm\n", + "l2 = 2 #in cm\n", + "d2 = 0.3 #in cm\n", + "pA3 = 1 #in atm\n", + "#unknowns\n", + "# pA1 and pA2\n", + "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", + "#on integrating using Laplace trandformation\n", + "# initial conditions\n", + "t=18000 #in seconds\n", + "pA1 = 1-0.57*(math.exp((-1.005)*(10**(-6))*t)-math.exp((-7.615)*(10**(-6))*t))\n", + "print 'Value of pA1 is %0.3f'%pA1,'atm'" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.10" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#given values\n", + "import math\n", + "y1l = 0 #mol fraction of dry air\n", + "y10 = (17.53/760) #mol fraction of water\n", + "l = 1.5 #in mm\n", + "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", + "D12 = 0.923 #Diffusivity of hydrogen over water\n", + "D13 = 0.267 #Diffusivity of oxygen over water\n", + "y2 = 0.6 #mole fraction of hydrogen\n", + "y3 = 0.4 #mole fraction of oxygen\n", + "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", + "Ni = (D1m*C*1000/(l*10000))*math.log((1-y1l)/(1-y10))\n", + "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.11" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Flux of ethane 4.804E-05 gmol/cm^2.s\n" + ] + } + ], + "source": [ + "#given data\n", + "y1 = 0.4 #mole fraction of ethane(1)\n", + "y2 = 0.3 #mole fraction of ethylene(2)\n", + "y3 = 0.3 #mole fraction of hydrogen(3)\n", + "#calculating D13\n", + "#The Lennard-Jones parameters are\n", + "sigma1 = 4.443 #in angstrom\n", + "sigma2 = 4.163 #in angstrom\n", + "sigma3 = 2.827 #in angstrom\n", + "e1byk = 215.7\n", + "e2byk = 224.7\n", + "e3byk = 59.7\n", + "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", + "e13byk = (e1byk*e3byk)**0.5\n", + "kTbye13 = 993/113.5\n", + "ohmD13 = 0.76 #from collision integral table\n", + "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", + "#calculating D23\n", + "sigma23 = (sigma2+sigma3)/2\n", + "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", + "ohmD23 = 0.762\n", + "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", + "D = (D13+D23)/2 #in cm^2/s\n", + "l = 0.15 #in cm\n", + "#at z=0 (bulk gas)\n", + "y10 = 0.6\n", + "y20 = 0.2\n", + "y30 = 0.2\n", + "#at z=l (catalyst surface)\n", + "y1l = 0.4\n", + "y2l = 0.3\n", + "y3l = 0.3\n", + "C = 2.0/(82.1*993) #calculated by P/RT\n", + "N1 = (D*C/l)*math.log((y10+y20)/(y1l+y2l))\n", + "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PrashantSahu/Chapter_2_Molecular_Diffusion.ipynb b/sample_notebooks/PrashantSahu/Chapter_2_Molecular_Diffusion.ipynb deleted file mode 100755 index 7df6880b..00000000 --- a/sample_notebooks/PrashantSahu/Chapter_2_Molecular_Diffusion.ipynb +++ /dev/null @@ -1,657 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#Chapter 2 : Molecular Diffusion\n", - "##Example 2.1 " - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Molar average velocity of gas mixture is: 0.0303\n", - "Mass average velocity of gas mixture is: 0.029\n" - ] - } - ], - "source": [ - "import math\n", - "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", - "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", - "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", - "Ar = 0.04 #mole fraction of Argon denoted as 4\n", - "u1 = 0.03\n", - "u2 = 0.035\n", - "u3 = 0.03\n", - "u4 = 0.02\n", - "#Calculating molar average velocity\n", - "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", - "print 'Molar average velocity of gas mixture is: %.4f'%U\n", - "#Calculating of mass average velocity\n", - "M1 = 28\n", - "M2 = 2\n", - "M3 = 17\n", - "M4 = 40\n", - "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", - "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", - "print 'Mass average velocity of gas mixture is: %.3f'%u" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - " ##Example 2.2" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false, - "scrolled": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Time for complete evaporation is: 15.93 hours\n", - "(b) Time for disappearance of water is: 8.87 hours\n" - ] - } - ], - "source": [ - "import math\n", - "import numpy as np\n", - "\n", - "#Calcualtion for (a) part\n", - "#calculating vapor pressure of water at 301K\n", - "pv = math.exp(13.8573 - (5160.2/301)) #in bar\n", - "#wet-bulb temperature is 22.5 degree centigrade\n", - "#calculating mean air-film temperature\n", - "Tm = ((28+22.5)/2)+273 #in kelvin\n", - "#calculating diffusion coefficient\n", - "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", - "l = 2.5e-3 #in m\n", - "P = 1.013 #in bar\n", - "R = 0.08317 #Gas constant\n", - "pAo = math.exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", - "pAl = 0.6*round(pv,4)\n", - "Na = (((round(Dab,7)*P)/(R*298.2*l))*math.log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", - "#amount of water per m^2 of floor area is\n", - "thickness = 2e-3\n", - "Amount = thickness*1 #in m^3 \n", - "#density of water is 1000kg/m^3\n", - "#therefore in kg it is\n", - "amount = Amount*1000\n", - "Time_for_completion = amount/Na #in seconds\n", - "Time_for_completion_hours = Time_for_completion/3600\n", - "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", - "\n", - "#Calculation for (b) part\n", - "water_loss = 0.1 #in kg/m^2.h\n", - "water_loss_by_evaporation = Na*3600\n", - "total_water_loss = water_loss + water_loss_by_evaporation\n", - "time_for_disappearance = amount/total_water_loss\n", - "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.3" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", - "(b) and (c)\n", - "Velocity of A is 0.522 cm/s\n", - "Velocity of B is 0.000 cm/s\n", - "Mass average velocity of A is 0.439 cm/s\n", - "Molar average velocity of A is 0.47 cm/s\n", - "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERH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Jmz681vgd0A/d/+3mXUjrE/VJ3Xe0t0/MbOJwM7u\nfraZnQL8hbCR0hLCfuaXuPui1LXfBrq7++YY/tNE0qKmJJFvux14wd2fAvYpt8bOAOCRbefu/km5\n33ky9fNN4P+7+1sevnW9RdhpbJsPqLjSpUjOyZlF9ERyQWpv4HbufkUVLzvV7/XwdepnGfBVuefL\nqPh3ZhTmHiJSQFRjEEkxsyMI/Qfldz5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "%matplotlib inline\n", - "import matplotlib\n", - "import math\n", - "import numpy as np\n", - "from matplotlib import pyplot as plt\n", - "#calculation for (a) part\n", - "l = 1 #thickness of air in cm\n", - "pAo = 0.9 #in atm\n", - "pAl = 0.1 #in atm\n", - "Dab = 0.214 #in cm^2/s\n", - "T = 298 #in K\n", - "P = 1 #in atm\n", - "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", - "#calculating molar flux of ammonia\n", - "Na = ((Dab*P)/(R*T*l))*math.log((P-pAl)/(P-pAo))\n", - "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", - "\n", - "#calculation for (b) and (c) part\n", - "Nb = 0 #air is non-diffusing\n", - "U = (Na/(P/(R*T))) #molar average velocity\n", - "yA = pAo/P\n", - "yB = pAl/P\n", - "uA = U/yA #\n", - "uB = 0 #since Nb=0\n", - "Ma = 17\n", - "Mb = 29\n", - "M = Ma*yA + Mb*yB\n", - "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", - "print '(b) and (c)'\n", - "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", - "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", - "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", - "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", - "\n", - "#calculation for (d) part\n", - "Ca = pAo/(R*T)\n", - "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", - " #with the mass average velocity \n", - "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", - "\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(1-(0.1*math.exp(2.197*z[i])))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.4" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", - "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", - "(c)\n", - "Molar average velocity and diffusion velocities at \"midway\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 7.9E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"top of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen 3.72E-04 m/s\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", - "Molar average velocity in z-direction is 9.9E-05 m/s\n", - "The diffusion velocity of oxygen is not infinity\n", - "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", - "(d)\n", - "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", - "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" - ] - }, - { - "data": { - "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX\nqNFwxVl81USjETXCfZfG+Y3xGl1elWgS0TglKlEQ0HKIIoiKIoKgIIOKEyJBhIZ+3j92td1gd3V1\nd506p6p/n7X2qlOnTp/zcBZdT++9z97b3B0REZHabBV3ACIikmxKFCIikpEShYiIZKREISIiGSlR\niIhIRkoUIiKSUUncATSEmemZXhGRBnB3q+/PFGyNwt1V3Bk3blzsMSSl6F7oXuheZC4NVbCJQkRE\n8kOJQkREMlKiKHBlZWVxh5AYuhdVdC+q6F40njWm3SouZuaFGLeISJzMDG9KndkiIpIfShQiIpKR\nEoWIiGSkRCEiIhkpUYiISEZKFCIikpEShYiIZKREISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZ\nJTJRmNlwM5tvZgvN7NdxxyMi0pQlbvZYM2sGLACGASuAWcAp7v5+tWM0e6yISD0V0+yxg4BF7r7E\n3cuBh4GRWx70/fdQUZH32EREmpySuAOoQRdgWbX3y4EDtjyoTRvYsAFKSmCbbULZeuvw2qJF1b4W\nLeouLVtWvdZUtt02lOrbLVrAVklMsyIiOZbERJFVm9LYseNxD7WKgw4qY9CgMjZsCDWN9es3L99/\nD+vW/fj999+H8u23sHJl2FdZKo/57ruq17Vrq7bXrw/JolWrkDhatdq8bLddKJXbrVtX7at8X72U\nlobSvHnUt1dEmopUKkUqlWr0eZLYR3EgMN7dh6ffjwUq3P3GasfE3kdRURGSxtq1tZd//SuU6ttr\n1lS9VpZvv616bd68KmmUloaaU2kptG0bttu2/XFp166qtG4NVu8WSBFpChraR5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T3O/IkcIiZNTOzbQmdl/PyHGc+ZHMv5gPDANJt\n8rsCH+U1ymSo9/dmYmsU7r7RzP4PMIXwRMN97v6+mZ2b/vxud3/GzEaY2SJgLTA6xpAjk829AK4B\n2gF3pf+SLnf3QXHFHJUs70WTkOXvyHwzmwy8A1QA97h70SWKLP9f/Bb4o5nNIfyRfLm7fx1b0BEx\ns4eAw4EOZrYMGEdogmzw96am8BARkYyS3PQkIiIJoEQhIiIZKVGIiEhGShQiIpKREoWIiGSkRCEi\nIhkpUYjUk5lNM7PWOTjP9FycRyRqShQi9WBmQ4AFOZof6GHg7BycRyRSGnAnUov0qN7z0m/bAEuA\nD4FH3f259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "#calculation of (a) part\n", - "#given data\n", - "import math\n", - "T = 298 #in kelvin\n", - "P = 1.013 #in bar\n", - "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", - "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", - "l = 0.05 #length of diffusion path in m\n", - "Dab = 2.1e-5 #diffusivity in m^2/s\n", - "R = 0.08317 #in m^3.bar.kmol.K\n", - "Na = Dab*P*math.log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", - "area = (math.pi/4)*(0.015)**2\n", - "rate = area*Na\n", - "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", - "z = []\n", - "pa =[]\n", - "for i in np.arange(0,1,0.01):\n", - " z.append(i)\n", - " \n", - "for i in range(0,len(z)):\n", - " pa.append(P-(P-pAo)*math.exp((R*T*Na*z[i])/(Dab*P)))\n", - " \n", - "from matplotlib.pyplot import*\n", - "plot(z,pa);\n", - "plt.xlabel('z(cm)');\n", - "plt.ylabel('pA(atm)');\n", - "\n", - "#calculation of (b) part\n", - "z = 0.025 #diffusion path\n", - "pA = 0.113 #in bar\n", - "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", - "#let dpA/dz = ppd\n", - "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", - "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", - "\n", - "#calculation of (c) part\n", - "uA = Na*(R*T/pA) #velocity of oxygen\n", - "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", - "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", - "vAd = uA - U #diffusion velocity of oxygen\n", - "vBd = uB - U #diffusion velocity of nitrogen\n", - "print '(c)'\n", - "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0(at top of tube)\n", - "uA = Na*(R*T/pAo)\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "#at z=0.05(at bottom of tube)\n", - "#uA = inf\n", - "uB = 0\n", - "U = pAo*uA/P\n", - "vAd = uA - U\n", - "vBd = uB - U\n", - "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", - "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", - "print 'The diffusion velocity of oxygen is not infinity'\n", - "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", - "\n", - "#calculation of (d) part\n", - "V = -2*U\n", - "pA = 0.113\n", - "Nad = round(Na,8) - V*(pA/(R*T))\n", - "Nbd = 0 - (P - pA)*V/(R*T)\n", - "print '(d)'\n", - "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", - "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.5" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a) The air-film thickness is :0.00193 m\n" - ] - } - ], - "source": [ - "#given data\n", - "area = 3*4 #in m^2\n", - "mperarea = 3.0/12 #in kg/m^2\n", - "#part (a)\n", - "P = 1.013 #in bar\n", - "Dab = 9.95e-6 #in m^2/s\n", - "R = 0.08317 #in m^3.bar./K.kmol\n", - "T = 273+27 #in K\n", - "#let d=1\n", - "d = 1 #in m\n", - "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", - "pAd = 0 #partial pressure over d length of stagnant film of air\n", - "Na = (Dab*P*math.log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", - "Na = Na*60 #in kg/m^2.s\n", - "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", - "#now we have to find the value of d\n", - "d = Na/flux\n", - "print '(a) The air-film thickness is :%0.5f'%d,'m'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.6" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(a)\n", - "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", - "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", - "(b)\n", - "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", - "(c)\n", - "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", - "(d)\n", - "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#given data\n", - "#part (a)\n", - "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", - "pA1 = 2*0.8 #in atm\n", - "pA2 = 2*0.2 #in atm\n", - "l = 0.15 #in m\n", - "R = 0.0821 #in m^3.atm./K.kmol\n", - "T = 293 #in K\n", - "Ma = 28\n", - "Mb = 32\n", - "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", - "area = math.pi/4*(0.05)**2 #in m^2\n", - "rate = area*Na\n", - "print '(a)'\n", - "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", - "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", - "\n", - "#part (b)\n", - "Nb = -Na\n", - "print '(b)'\n", - "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", - "\n", - "#part (c)\n", - "#let dpA/dz = ppg\n", - "dz = 0.05 #in m\n", - "ppg = (pA2 - pA1)/l #in atm/m\n", - "pA = pA1 + (ppg)*dz #in atm\n", - "print '(c)'\n", - "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", - "\n", - "#part (d)\n", - "nt = Ma*Na + Mb*Nb\n", - "print '(d)'\n", - "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.7" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Methanol flux: 4.64e-05 kmol/m^2.s\n", - "Water flux: -4.06e-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#given data\n", - "Ha = 274.6*32 #molar latent heat of methanol(a)\n", - "Hb = 557.7*18 #molar latent heat of water(b)\n", - "yAl = 0.76 #mole fraction of methanol in the vapour\n", - "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", - "P = 1 #in atm\n", - "l = 1e-3 #in m\n", - "T =344.2 #in K\n", - "R = 0.0821 #m^3.atm./K.kmol\n", - "Dab = 1.816e-5 #in m^2/s\n", - "Na = Dab*P*math.log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", - "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", - "Nb = -(Ha/Hb)*Na\n", - "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.8" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of pA1 is 0.937 atm\n" - ] - } - ], - "source": [ - "#given values\n", - "import math\n", - "V1 = 3000 #in cm^3\n", - "V2 = 4000 #in cm^3\n", - "Dab = 0.23 #in cm^2/s\n", - "Dba = 0.23 #in cm^2/s\n", - "l1 = 4 #in cm\n", - "d1 = 0.5 #in cm\n", - "l2 = 2 #in cm\n", - "d2 = 0.3 #in cm\n", - "pA3 = 1 #in atm\n", - "#unknowns\n", - "# pA1 and pA2\n", - "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", - "#on integrating using Laplace trandformation\n", - "# initial conditions\n", - "t=18000 #in seconds\n", - "pA1 = 1-0.57*(math.exp((-1.005)*(10**(-6))*t)-math.exp((-7.615)*(10**(-6))*t))\n", - "print 'Value of pA1 is %0.3f'%pA1,'atm'" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "##Example 2.10" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" - ] - } - ], - "source": [ - "#given values\n", - "import math\n", - "y1l = 0 #mol fraction of dry air\n", - "y10 = (17.53/760) #mol fraction of water\n", - "l = 1.5 #in mm\n", - "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", - "D12 = 0.923 #Diffusivity of hydrogen over water\n", - "D13 = 0.267 #Diffusivity of oxygen over water\n", - "y2 = 0.6 #mole fraction of hydrogen\n", - "y3 = 0.4 #mole fraction of oxygen\n", - "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", - "Ni = (D1m*C*1000/(l*10000))*math.log((1-y1l)/(1-y10))\n", - "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 2.11" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Flux of ethane 4.804E-05 gmol/cm^2.s\n" - ] - } - ], - "source": [ - "#given data\n", - "y1 = 0.4 #mole fraction of ethane(1)\n", - "y2 = 0.3 #mole fraction of ethylene(2)\n", - "y3 = 0.3 #mole fraction of hydrogen(3)\n", - "#calculating D13\n", - "#The Lennard-Jones parameters are\n", - "sigma1 = 4.443 #in angstrom\n", - "sigma2 = 4.163 #in angstrom\n", - "sigma3 = 2.827 #in angstrom\n", - "e1byk = 215.7\n", - "e2byk = 224.7\n", - "e3byk = 59.7\n", - "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", - "e13byk = (e1byk*e3byk)**0.5\n", - "kTbye13 = 993/113.5\n", - "ohmD13 = 0.76 #from collision integral table\n", - "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", - "#calculating D23\n", - "sigma23 = (sigma2+sigma3)/2\n", - "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", - "ohmD23 = 0.762\n", - "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", - "D = (D13+D23)/2 #in cm^2/s\n", - "l = 0.15 #in cm\n", - "#at z=0 (bulk gas)\n", - "y10 = 0.6\n", - "y20 = 0.2\n", - "y30 = 0.2\n", - "#at z=l (catalyst surface)\n", - "y1l = 0.4\n", - "y2l = 0.3\n", - "y3l = 0.3\n", - "C = 2.0/(82.1*993) #calculated by P/RT\n", - "N1 = (D*C/l)*math.log((y10+y20)/(y1l+y2l))\n", - "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K.ipynb b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K.ipynb new file mode 100755 index 00000000..3f6a6b0c --- /dev/null +++ b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K.ipynb @@ -0,0 +1,753 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter 2 : Molecular Diffusion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.1 Page no. 10" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Molar average velocity of gas mixture is: 0.0303 m/s\n", + "Mass average velocity of gas mixture is: 0.029 m/s\n" + ] + } + ], + "source": [ + "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", + "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", + "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", + "Ar = 0.04 #mole fraction of Argon denoted as 4\n", + "u1 = 0.03\n", + "u2 = 0.035\n", + "u3 = 0.03\n", + "u4 = 0.02\n", + "#Calculating molar average velocity\n", + "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", + "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", + "#Calculating of mass average velocity\n", + "M1 = 28\n", + "M2 = 2\n", + "M3 = 17\n", + "M4 = 40\n", + "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", + "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", + "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " ##Example 2.2 Page no. 16" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Time for complete evaporation is: 15.93 hours\n", + "(b) Time for disappearance of water is: 8.87 hours\n" + ] + } + ], + "source": [ + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "\n", + "#Calcualtion for (a) part\n", + "#calculating vapor pressure of water at 301K\n", + "pv = exp(13.8573 - (5160.2/301)) #in bar\n", + "#wet-bulb temperature is 22.5 degree centigrade\n", + "#calculating mean air-film temperature\n", + "Tm = ((28+22.5)/2)+273 #in kelvin\n", + "#calculating diffusion coefficient\n", + "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", + "l = 2.5e-3 #in m\n", + "P = 1.013 #in bar\n", + "R = 0.08317 #Gas constant\n", + "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", + "pAl = 0.6*round(pv,4)\n", + "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", + "#amount of water per m^2 of floor area is\n", + "thickness = 2e-3\n", + "Amount = thickness*1 #in m^3 \n", + "#density of water is 1000kg/m^3\n", + "#therefore in kg it is\n", + "amount = Amount*1000\n", + "Time_for_completion = amount/Na #in seconds\n", + "Time_for_completion_hours = Time_for_completion/3600\n", + "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", + "\n", + "#Calculation for (b) part\n", + "water_loss = 0.1 #in kg/m^2.h\n", + "water_loss_by_evaporation = Na*3600\n", + "total_water_loss = water_loss + water_loss_by_evaporation\n", + "time_for_disappearance = amount/total_water_loss\n", + "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.3 Page no. 17" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", + "(b) and (c)\n", + "Velocity of A is 0.522 cm/s\n", + "Velocity of B is 0.000 cm/s\n", + "Mass average velocity of A is 0.439 cm/s\n", + "Molar average velocity of A is 0.47 cm/s\n", + "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb981yruGsM04HwAM+sNfOLuH1RV0N11uHP99dfHHkOu\nHLoXuhe6FzUf9RVpjcHMHgKOAVqb2RrgeqAJgLuPd/dnzGywma0ENgMXRRmPiIjULtLE4O7D0ygz\nMsoYRESkbuJuSpI6SiQScYeQM3QvdtC92EH3ouGsIe1Q2WJmng9xiojkEjPD87DzWUREcowSg4iI\nVKDEICIiFSgxiIhIBUoMIiJSgRKDiIhUoMQgIiIVKDGIiEgFSgwiIlKBEoOIiFSgxCAiIhUoMYiI\nSAVKDCIiUoESg4iIVBBpYjCzEjNbZmYrzGxUFa+3MrPHzWyRmc0xs25RxiMiIrWLLDGYWREwDigB\nDgKGm1nXSsWuARa4+yGEvZ9viyoeERFJT5Q1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ZQ4zZUuu9cPfvufv+7r4/oZ/h\n8gJLCpDe38cTwFFmVmRmzQkdjUuyHGc2pHMvlgEDAVLt6Z2Bt7MaZe6o8+dmztQY3H2rmY0EZrBj\nMtzS8pPh3P0ZMxtsZiuBzcBFMYYcmXTuBXAd0Aq4I/VNeYu794or5qikeS8KXpp/H8vMbDrwBmGy\n6F3uXnCJIc1/E78BJprZIsIX4F+4+79jCzpCZvYQcAzQ2szWANcTmhXr/bmpCW4iIlJBLjUliYhI\nDlBiEBGRCpQYRESkAiUGERGpQIlBREQqUGIQEZEKlBhEamFmz5vZbhm4zguZuI5I1JQYRGpgZgOA\n5RlaY2cycFkGriMSKU1wE0lJzZz9cep0D2A1sAr4q7v/LVXmfOA/CYuQLXL3C8zsXuBzwpr4/0FY\n7fYioCcwx90vSv1uG+DJQpyhLoVFiUGkEjMrJmz681vgd0A/d/+3mXUjrE/VJ3Xe0t0/MbOJwM7u\nfraZnQL8hbCR0hLCfuaXuPui1LXfBrq7++YY/tNE0qKmJJFvux14wd2fAvYpt8bOAOCRbefu/km5\n33ky9fNN4P+7+1sevnW9RdhpbJsPqLjSpUjOyZlF9ERyQWpv4HbufkUVLzvV7/XwdepnGfBVuefL\nqPh3ZhTmHiJSQFRjEEkxsyMI/Qfldz5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "%matplotlib inline\n", + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "#calculation for (a) part\n", + "l = 1 #thickness of air in cm\n", + "pAo = 0.9 #in atm\n", + "pAl = 0.1 #in atm\n", + "Dab = 0.214 #in cm^2/s\n", + "T = 298 #in K\n", + "P = 1 #in atm\n", + "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", + "#calculating molar flux of ammonia\n", + "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", + "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", + "\n", + "#calculation for (b) and (c) part\n", + "Nb = 0 #air is non-diffusing\n", + "U = (Na/(P/(R*T))) #molar average velocity\n", + "yA = pAo/P\n", + "yB = pAl/P\n", + "uA = U/yA #\n", + "uB = 0 #since Nb=0\n", + "Ma = 17\n", + "Mb = 29\n", + "M = Ma*yA + Mb*yB\n", + "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", + "print '(b) and (c)'\n", + "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", + "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", + "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", + "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", + "\n", + "#calculation for (d) part\n", + "Ca = pAo/(R*T)\n", + "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", + " #with the mass average velocity \n", + "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", + "\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(1-(0.1*exp(2.197*z[i])))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.4 Page no. 19" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", + "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", + "(c)\n", + "Molar average velocity and diffusion velocities at \"midway\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 7.9E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"top of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 3.72E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen is not infinity\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "(d)\n", + "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", + "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX\nqNFwxVl81USjETXCfZfG+Y3xGl1elWgS0TglKlEQ0HKIIoiKIoKgIIOKEyJBhIZ+3j92td1gd3V1\nd506p6p/n7X2qlOnTp/zcBZdT++9z97b3B0REZHabBV3ACIikmxKFCIikpEShYiIZKREISIiGSlR\niIhIRkoUIiKSUUncATSEmemZXhGRBnB3q+/PFGyNwt1V3Bk3blzsMSSl6F7oXuheZC4NVbCJQkRE\n8kOJQkREMlKiKHBlZWVxh5AYuhdVdC+q6F40njWm3SouZuaFGLeISJzMDG9KndkiIpIfShQiIpKR\nEoWIiGSkRCEiIhkpUYiISEZKFCIikp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\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#calculation of (a) part\n", + "#given data\n", + "from math import log\n", + "from math import pi\n", + "from math import exp\n", + "import numpy as np\n", + "T = 298 #in kelvin\n", + "P = 1.013 #in bar\n", + "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", + "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", + "l = 0.05 #length of diffusion path in m\n", + "Dab = 2.1e-5 #diffusivity in m^2/s\n", + "R = 0.08317 #in m^3.bar.kmol.K\n", + "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", + "area = (pi/4)*(0.015)**2\n", + "rate = area*Na\n", + "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "\n", + "#calculation of (b) part\n", + "z = 0.025 #diffusion path\n", + "pA = 0.113 #in bar\n", + "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", + "#let dpA/dz = ppd\n", + "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", + "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", + "\n", + "#calculation of (c) part\n", + "uA = Na*(R*T/pA) #velocity of oxygen\n", + "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", + "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", + "vAd = uA - U #diffusion velocity of oxygen\n", + "vBd = uB - U #diffusion velocity of nitrogen\n", + "print '(c)'\n", + "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0(at top of tube)\n", + "uA = Na*(R*T/pAo)\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0.05(at bottom of tube)\n", + "#uA = inf\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen is not infinity'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "\n", + "#calculation of (d) part\n", + "V = -2*U\n", + "pA = 0.113\n", + "Nad = round(Na,8) - V*(pA/(R*T))\n", + "Nbd = 0 - (P - pA)*V/(R*T)\n", + "print '(d)'\n", + "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", + "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.5 Page no. 21" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The air-film thickness is :0.00193 m\n" + ] + } + ], + "source": [ + "from math import log\n", + "#given data\n", + "area = 3*4 #in m^2\n", + "mperarea = 3.0/12 #in kg/m^2\n", + "#part (a)\n", + "P = 1.013 #in bar\n", + "Dab = 9.95e-6 #in m^2/s\n", + "R = 0.08317 #in m^3.bar./K.kmol\n", + "T = 273+27 #in K\n", + "#let d=1\n", + "d = 1 #in m\n", + "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", + "pAd = 0 #partial pressure over d length of stagnant film of air\n", + "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", + "Na = Na*60 #in kg/m^2.s\n", + "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", + "#now we have to find the value of d\n", + "d = Na/flux\n", + "print '(a) The air-film thickness is :%0.5f'%d,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.6 Page no. 24" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)\n", + "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", + "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", + "(b)\n", + "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", + "(c)\n", + "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", + "(d)\n", + "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "from math import pi\n", + "#given data\n", + "#part (a)\n", + "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", + "pA1 = 2*0.8 #in atm\n", + "pA2 = 2*0.2 #in atm\n", + "l = 0.15 #in m\n", + "R = 0.0821 #in m^3.atm./K.kmol\n", + "T = 293 #in K\n", + "Ma = 28\n", + "Mb = 32\n", + "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", + "area = pi/4*(0.05)**2 #in m^2\n", + "rate = area*Na\n", + "print '(a)'\n", + "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", + "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", + "\n", + "#part (b)\n", + "Nb = -Na\n", + "print '(b)'\n", + "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", + "\n", + "#part (c)\n", + "#let dpA/dz = ppg\n", + "dz = 0.05 #in m\n", + "ppg = (pA2 - pA1)/l #in atm/m\n", + "pA = pA1 + (ppg)*dz #in atm\n", + "print '(c)'\n", + "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", + "\n", + "#part (d)\n", + "nt = Ma*Na + Mb*Nb\n", + "print '(d)'\n", + "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.7 Page no. 25" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Methanol flux: 4.64e-05 kmol/m^2.s\n", + "Water flux: -4.06e-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "from math import log\n", + "#given data\n", + "Ha = 274.6*32 #molar latent heat of methanol(a)\n", + "Hb = 557.7*18 #molar latent heat of water(b)\n", + "yAl = 0.76 #mole fraction of methanol in the vapour\n", + "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", + "P = 1 #in atm\n", + "l = 1e-3 #in m\n", + "T =344.2 #in K\n", + "R = 0.0821 #m^3.atm./K.kmol\n", + "Dab = 1.816e-5 #in m^2/s\n", + "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", + "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", + "Nb = -(Ha/Hb)*Na\n", + "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.8 Page no. 27" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of pA1 is 0.937 atm\n" + ] + } + ], + "source": [ + "#given values\n", + "from math import exp\n", + "V1 = 3000 #in cm^3\n", + "V2 = 4000 #in cm^3\n", + "Dab = 0.23 #in cm^2/s\n", + "Dba = 0.23 #in cm^2/s\n", + "l1 = 4 #in cm\n", + "d1 = 0.5 #in cm\n", + "l2 = 2 #in cm\n", + "d2 = 0.3 #in cm\n", + "pA3 = 1 #in atm\n", + "#unknowns\n", + "# pA1 and pA2\n", + "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", + "#on integrating using Laplace trandformation\n", + "# initial conditions\n", + "t=18000 #in seconds\n", + "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", + "print 'Value of pA1 is %0.3f'%pA1,'atm'" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.10 Page no.34" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#given values\n", + "from math import log\n", + "y1l = 0 #mol fraction of dry air\n", + "y10 = (17.53/760) #mol fraction of water\n", + "l = 1.5 #in mm\n", + "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", + "D12 = 0.923 #Diffusivity of hydrogen over water\n", + "D13 = 0.267 #Diffusivity of oxygen over water\n", + "y2 = 0.6 #mole fraction of hydrogen\n", + "y3 = 0.4 #mole fraction of oxygen\n", + "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", + "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", + "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.11 Page no. 35" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Flux of ethane 4.804E-05 gmol/cm^2.s\n" + ] + } + ], + "source": [ + "from math import log\n", + "#given data\n", + "y1 = 0.4 #mole fraction of ethane(1)\n", + "y2 = 0.3 #mole fraction of ethylene(2)\n", + "y3 = 0.3 #mole fraction of hydrogen(3)\n", + "#calculating D13\n", + "#The Lennard-Jones parameters are\n", + "sigma1 = 4.443 #in angstrom\n", + "sigma2 = 4.163 #in angstrom\n", + "sigma3 = 2.827 #in angstrom\n", + "e1byk = 215.7\n", + "e2byk = 224.7\n", + "e3byk = 59.7\n", + "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", + "e13byk = (e1byk*e3byk)**0.5\n", + "kTbye13 = 993/113.5\n", + "ohmD13 = 0.76 #from collision integral table\n", + "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", + "#calculating D23\n", + "sigma23 = (sigma2+sigma3)/2\n", + "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", + "ohmD23 = 0.762\n", + "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", + "D = (D13+D23)/2 #in cm^2/s\n", + "l = 0.15 #in cm\n", + "#at z=0 (bulk gas)\n", + "y10 = 0.6\n", + "y20 = 0.2\n", + "y30 = 0.2\n", + "#at z=l (catalyst surface)\n", + "y1l = 0.4\n", + "y2l = 0.3\n", + "y3l = 0.3\n", + "C = 2.0/(82.1*993) #calculated by P/RT\n", + "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", + "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.12 Page no. 43" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The liquid-film thickness is: 0.0004 m\n" + ] + } + ], + "source": [ + "#given data\n", + "from math import pi\n", + "rc = 5e-4 #in m\n", + "D = 7e-10 #in m^2/s\n", + "Cab = 1 #in kmol/m^3\n", + "Na = 3.15e-6 #in kmol/m^2.s\n", + "W = 4*pi*(rc**2)*Na #the rate of reaction\n", + "#let (rc+delta)/delta = 1\n", + "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", + "rcplusdelta = W/w1\n", + "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", + "print 'The liquid-film thickness is: ',delta,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.13 Page no. 46" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tortuosity factor is: 2.5\n" + ] + } + ], + "source": [ + "#given data\n", + "from math import log\n", + "V1 = 60.2 #in cm^3; volume of compartment 1\n", + "V2 = 59.3 #volume of compartment 2 in cm^3\n", + "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", + "Ca2i = 0 #initial concentration of KCl in compartment 2\n", + "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", + "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", + "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", + "tf = 55.2*3600 #time of the experiment in s\n", + "#calcutaling cell constant\n", + "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", + "#diffusion of propionic acid\n", + "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", + "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", + "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", + "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", + "tfp = 56.4*3600 #time for the experiment\n", + "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", + "#calculating tortusity factor\n", + "A= (math.pi/4)*(3.5**2) #area of the diaphragm\n", + "epsilon = 0.39 #average porosity of the diaphragm\n", + "l = 0.18 #thickness of hte diaphragm\n", + "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", + "print 'Tortuosity factor is: ',round(tou,1)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb new file mode 100755 index 00000000..958c7769 --- /dev/null +++ b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_1.ipynb @@ -0,0 +1,789 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter 2 Molecular Diffusion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.1 pgno:10" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Molar average velocity of gas mixture is: 0.0303 m/s\n", + "Mass average velocity of gas mixture is: 0.029 m/s\n" + ] + } + ], + "source": [ + "#Calculation of average velocities\n", + "\n", + "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", + "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", + "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", + "Ar = 0.04 #mole fraction of Argon denoted as 4\n", + "u1 = 0.03\n", + "u2 = 0.035\n", + "u3 = 0.03\n", + "u4 = 0.02\n", + "#Calculating molar average velocity\n", + "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", + "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", + "#Calculating of mass average velocity\n", + "M1 = 28\n", + "M2 = 2\n", + "M3 = 17\n", + "M4 = 40\n", + "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", + "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", + "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + " ##Example 2.2 pgno:16" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Time for complete evaporation is: 15.93 hours\n", + "(b) Time for disappearance of water is: 8.87 hours\n" + ] + } + ], + "source": [ + "#Diffusion of A through non-diffusing B\n", + "\n", + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "\n", + "#Calcualtion for (a) part\n", + "#calculating vapor pressure of water at 301K\n", + "pv = exp(13.8573 - (5160.2/301)) #in bar\n", + "#wet-bulb temperature is 22.5 degree centigrade\n", + "#calculating mean air-film temperature\n", + "Tm = ((28+22.5)/2)+273 #in kelvin\n", + "#calculating diffusion coefficient\n", + "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", + "l = 2.5e-3 #in m\n", + "P = 1.013 #in bar\n", + "R = 0.08317 #Gas constant\n", + "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", + "pAl = 0.6*round(pv,4)\n", + "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", + "#amount of water per m^2 of floor area is\n", + "thickness = 2e-3\n", + "Amount = thickness*1 #in m^3 \n", + "#density of water is 1000kg/m^3\n", + "#therefore in kg it is\n", + "amount = Amount*1000\n", + "Time_for_completion = amount/Na #in seconds\n", + "Time_for_completion_hours = Time_for_completion/3600\n", + "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", + "\n", + "#Calculation for (b) part\n", + "water_loss = 0.1 #in kg/m^2.h\n", + "water_loss_by_evaporation = Na*3600\n", + "total_water_loss = water_loss + water_loss_by_evaporation\n", + "time_for_disappearance = amount/total_water_loss\n", + "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.3 pgno:17" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", + "(b) and (c)\n", + "Velocity of A is 0.522 cm/s\n", + "Velocity of B is 0.000 cm/s\n", + "Mass average velocity of A is 0.439 cm/s\n", + "Molar average velocity of A is 0.47 cm/s\n", + "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb981yruGsM04HwAM+sNfOLuH1RV0N11uHP99dfHHkOu\nHLoXuhe6FzUf9RVpjcHMHgKOAVqb2RrgeqAJgLuPd/dnzGywma0ENgMXRRmPiIjULtLE4O7D0ygz\nMsoYRESkbuJuSpI6SiQScYeQM3QvdtC92EH3ouGsIe1Q2WJmng9xiojkEjPD87DzWUREcowSg4iI\nVKDEICIiFSgxiIhIBUoMIiJSgRKDiIhUoMQgIiIVKDGIiEgFSgwiIlKBEoOIiFSgxCAiIhUoMYiI\nSAVKDCIiUoESg4iIVBBpYjCzEjNbZmYrzGxUFa+3MrPHzWyRmc0xs25RxiMiIrWLLDGYWREwDigB\nDgKGm1nXSsWuARa4+yGEvZ9viyoeERFJT5Q1hl7ASndf7e5bgMnA0EplugIvAbj7cqCDme0dYUwi\nI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TwFFmVmRmzQkdjUuyHGc2pHMvlgEDAVLt6Z2Bt7MaZe6o8+dmztQY3H2rmY0EZrBj\nMtzS8pPh3P0ZMxtsZiuBzcBFMYYcmXTuBXAd0Aq4I/VNeYu794or5qikeS8KXpp/H8vMbDrwBmGy\n6F3uXnCJIc1/E78BJprZIsIX4F+4+79jCzpCZvYQcAzQ2szWANcTmhXr/bmpCW4iIlJBLjUliYhI\nDlBiEBGRCpQYRESkAiUGERGpQIlBREQqUGIQEZEKlBhEamFmz5vZbhm4zguZuI5I1JQYRGpgZgOA\n5RlaY2cycFkGriMSKU1wE0lJzZz9cep0D2A1sAr4q7v/LVXmfOA/CYuQLXL3C8zsXuBzwpr4/0FY\n7fYioCcwx90vSv1uG+DJQpyhLoVFiUGkEjMrJmz681vgd0A/d/+3mXUjrE/VJ3Xe0t0/MbOJwM7u\nfraZnQL8hbCR0hLCfuaXuPui1LXfBrq7++YY/tNE0qKmJJFvux14wd2fAvYpt8bOAOCRbefu/km5\n33ky9fNN4P+7+1sevnW9RdhpbJsPqLjSpUjOyZlF9ERyQWpv4HbufkUVLzvV7/XwdepnGfBVuefL\nqPh3ZhTmHiJSQFRjEEkxsyMI/Qfldz5bb2Z7ph6/CJyx7dzMWtXjbdpQxd4aIrlENQaRHX5CWMr8\npdRS5vOAmYRO5BnuvsTMfg28bGbfAAsIu+dBxVpA5RqBA5jZdwh7D6t/QXKaOp9FamBmCWCYu1+e\ngWv9CNjV3X/f4MBEIqSmJJEauHuSsFtYJiamDSNsxSqS01RjEBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#Calculation of flux and velocity\n", + "\n", + "%matplotlib inline\n", + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "#calculation for (a) part\n", + "l = 1 #thickness of air in cm\n", + "pAo = 0.9 #in atm\n", + "pAl = 0.1 #in atm\n", + "Dab = 0.214 #in cm^2/s\n", + "T = 298 #in K\n", + "P = 1 #in atm\n", + "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", + "#calculating molar flux of ammonia\n", + "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", + "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", + "\n", + "#calculation for (b) and (c) part\n", + "Nb = 0 #air is non-diffusing\n", + "U = (Na/(P/(R*T))) #molar average velocity\n", + "yA = pAo/P\n", + "yB = pAl/P\n", + "uA = U/yA #\n", + "uB = 0 #since Nb=0\n", + "Ma = 17\n", + "Mb = 29\n", + "M = Ma*yA + Mb*yB\n", + "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", + "print '(b) and (c)'\n", + "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", + "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", + "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", + "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", + "\n", + "#calculation for (d) part\n", + "Ca = pAo/(R*T)\n", + "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", + " #with the mass average velocity \n", + "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", + "\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(1-(0.1*exp(2.197*z[i])))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.4 pgno:19" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", + "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", + "(c)\n", + "Molar average velocity and diffusion velocities at \"midway\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 7.9E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"top of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 3.72E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen is not infinity\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "(d)\n", + "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", + "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX\nqNFwxVl81USjETXCfZfG+Y3xGl1elWgS0TglKlEQ0HKIIoiKIoKgIIOKEyJBhIZ+3j92td1gd3V1\nd506p6p/n7X2qlOnTp/zcBZdT++9z97b3B0REZHabBV3ACIikmxKFCIikpEShYiIZKREISIiGSlR\niIhIRkoUIiKSUUncATSEmemZXhGRBnB3q+/PFGyNwt1V3Bk3blzsMSSl6F7oXuheZC4NVbCJQkRE\n8kOJQkREMlKiKHBlZWVxh5AYuhdVdC+q6F40njWm3SouZuaFGLeISJzMDG9KndkiIpIfShQiIpKR\nEoWIiGSkRCEiIhkpUYiISEZKFCIikpEShYiIZKREISIiGSlRiIh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PnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#Flux, velocity and pressure gradient\n", + "\n", + "#calculation of (a) part\n", + "#given data\n", + "from math import log\n", + "from math import pi\n", + "from math import exp\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "T = 298 #in kelvin\n", + "P = 1.013 #in bar\n", + "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", + "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", + "l = 0.05 #length of diffusion path in m\n", + "Dab = 2.1e-5 #diffusivity in m^2/s\n", + "R = 0.08317 #in m^3.bar.kmol.K\n", + "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", + "area = (pi/4)*(0.015)**2\n", + "rate = area*Na\n", + "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "\n", + "#calculation of (b) part\n", + "z = 0.025 #diffusion path\n", + "pA = 0.113 #in bar\n", + "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", + "#let dpA/dz = ppd\n", + "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", + "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", + "\n", + "#calculation of (c) part\n", + "uA = Na*(R*T/pA) #velocity of oxygen\n", + "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", + "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", + "vAd = uA - U #diffusion velocity of oxygen\n", + "vBd = uB - U #diffusion velocity of nitrogen\n", + "print '(c)'\n", + "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0(at top of tube)\n", + "uA = Na*(R*T/pAo)\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0.05(at bottom of tube)\n", + "#uA = inf\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen is not infinity'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "\n", + "#calculation of (d) part\n", + "V = -2*U\n", + "pA = 0.113\n", + "Nad = round(Na,8) - V*(pA/(R*T))\n", + "Nbd = 0 - (P - pA)*V/(R*T)\n", + "print '(d)'\n", + "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", + "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.5 pgno:21" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The air-film thickness is :0.00193 m\n" + ] + } + ], + "source": [ + "#Diffusion with changing bulk concentration\n", + "\n", + "from math import log\n", + "#given data\n", + "area = 3*4 #in m^2\n", + "mperarea = 3.0/12 #in kg/m^2\n", + "#part (a)\n", + "P = 1.013 #in bar\n", + "Dab = 9.95e-6 #in m^2/s\n", + "R = 0.08317 #in m^3.bar./K.kmol\n", + "T = 273+27 #in K\n", + "#let d=1\n", + "d = 1 #in m\n", + "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", + "pAd = 0 #partial pressure over d length of stagnant film of air\n", + "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", + "Na = Na*60 #in kg/m^2.s\n", + "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", + "#now we have to find the value of d\n", + "d = Na/flux\n", + "print '(a) The air-film thickness is :%0.5f'%d,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.6 pgno:24" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)\n", + "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", + "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", + "(b)\n", + "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", + "(c)\n", + "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", + "(d)\n", + "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Equimolar counterdiffusion\n", + "\n", + "from math import pi\n", + "#given data\n", + "#part (a)\n", + "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", + "pA1 = 2*0.8 #in atm\n", + "pA2 = 2*0.2 #in atm\n", + "l = 0.15 #in m\n", + "R = 0.0821 #in m^3.atm./K.kmol\n", + "T = 293 #in K\n", + "Ma = 28\n", + "Mb = 32\n", + "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", + "area = pi/4*(0.05)**2 #in m^2\n", + "rate = area*Na\n", + "print '(a)'\n", + "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", + "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", + "\n", + "#part (b)\n", + "Nb = -Na\n", + "print '(b)'\n", + "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", + "\n", + "#part (c)\n", + "#let dpA/dz = ppg\n", + "dz = 0.05 #in m\n", + "ppg = (pA2 - pA1)/l #in atm/m\n", + "pA = pA1 + (ppg)*dz #in atm\n", + "print '(c)'\n", + "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", + "\n", + "#part (d)\n", + "nt = Ma*Na + Mb*Nb\n", + "print '(d)'\n", + "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.7 pgno:25" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Methanol flux: 4.64e-05 kmol/m^2.s\n", + "Water flux: -4.06e-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Non-equimolar counterdiffusion in distillation of a binary mixture\n", + "\n", + "from math import log\n", + "#given data\n", + "Ha = 274.6*32 #molar latent heat of methanol(a)\n", + "Hb = 557.7*18 #molar latent heat of water(b)\n", + "yAl = 0.76 #mole fraction of methanol in the vapour\n", + "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", + "P = 1 #in atm\n", + "l = 1e-3 #in m\n", + "T =344.2 #in K\n", + "R = 0.0821 #m^3.atm./K.kmol\n", + "Dab = 1.816e-5 #in m^2/s\n", + "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", + "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", + "Nb = -(Ha/Hb)*Na\n", + "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.8 pgno:27" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of pA1 is 0.937 atm\n" + ] + } + ], + "source": [ + "#Equimolar counterdiffusion in an interconnected system\n", + "\n", + "#given values\n", + "from math import exp\n", + "V1 = 3000 #in cm^3\n", + "V2 = 4000 #in cm^3\n", + "Dab = 0.23 #in cm^2/s\n", + "Dba = 0.23 #in cm^2/s\n", + "l1 = 4 #in cm\n", + "d1 = 0.5 #in cm\n", + "l2 = 2 #in cm\n", + "d2 = 0.3 #in cm\n", + "pA3 = 1 #in atm\n", + "#unknowns\n", + "# pA1 and pA2\n", + "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", + "#on integrating using Laplace trandformation\n", + "# initial conditions\n", + "t=18000 #in seconds\n", + "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", + "print 'Value of pA1 is %0.3f'%pA1,'atm'" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "##Example 2.10 pgno:34" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Diffusion of only one component in a three-component mixture\n", + "\n", + "#given values\n", + "from math import log\n", + "y1l = 0 #mol fraction of dry air\n", + "y10 = (17.53/760) #mol fraction of water\n", + "l = 1.5 #in mm\n", + "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", + "D12 = 0.923 #Diffusivity of hydrogen over water\n", + "D13 = 0.267 #Diffusivity of oxygen over water\n", + "y2 = 0.6 #mole fraction of hydrogen\n", + "y3 = 0.4 #mole fraction of oxygen\n", + "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", + "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", + "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.11 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Flux of ethane 4.804E-05 gmol/cm^2.s\n" + ] + } + ], + "source": [ + "#Multicomponent diffusion\n", + "\n", + "from math import log\n", + "#given data\n", + "y1 = 0.4 #mole fraction of ethane(1)\n", + "y2 = 0.3 #mole fraction of ethylene(2)\n", + "y3 = 0.3 #mole fraction of hydrogen(3)\n", + "#calculating D13\n", + "#The Lennard-Jones parameters are\n", + "sigma1 = 4.443 #in angstrom\n", + "sigma2 = 4.163 #in angstrom\n", + "sigma3 = 2.827 #in angstrom\n", + "e1byk = 215.7\n", + "e2byk = 224.7\n", + "e3byk = 59.7\n", + "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", + "e13byk = (e1byk*e3byk)**0.5\n", + "kTbye13 = 993/113.5\n", + "ohmD13 = 0.76 #from collision integral table\n", + "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", + "#calculating D23\n", + "sigma23 = (sigma2+sigma3)/2\n", + "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", + "ohmD23 = 0.762\n", + "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", + "D = (D13+D23)/2 #in cm^2/s\n", + "l = 0.15 #in cm\n", + "#at z=0 (bulk gas)\n", + "y10 = 0.6\n", + "y20 = 0.2\n", + "y30 = 0.2\n", + "#at z=l (catalyst surface)\n", + "y1l = 0.4\n", + "y2l = 0.3\n", + "y3l = 0.3\n", + "C = 2.0/(82.1*993) #calculated by P/RT\n", + "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", + "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.12 pgno:43" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The liquid-film thickness is: 0.0004 m\n" + ] + } + ], + "source": [ + "#Liquid-phase diffusion\n", + "\n", + "#given data\n", + "from math import pi\n", + "rc = 5e-4 #in m\n", + "D = 7e-10 #in m^2/s\n", + "Cab = 1 #in kmol/m^3\n", + "Na = 3.15e-6 #in kmol/m^2.s\n", + "W = 4*pi*(rc**2)*Na #the rate of reaction\n", + "#let (rc+delta)/delta = 1\n", + "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", + "rcplusdelta = W/w1\n", + "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", + "print 'The liquid-film thickness is: ',delta,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 2.13 pgno:46" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tortuosity factor is: 2.5\n" + ] + } + ], + "source": [ + "#Diffusivity determination--diaphragm cell\n", + "\n", + "#given data\n", + "from math import log\n", + "from math import pi\n", + "V1 = 60.2 #in cm^3; volume of compartment 1\n", + "V2 = 59.3 #volume of compartment 2 in cm^3\n", + "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", + "Ca2i = 0 #initial concentration of KCl in compartment 2\n", + "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", + "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", + "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", + "tf = 55.2*3600 #time of the experiment in s\n", + "#calcutaling cell constant\n", + "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", + "#diffusion of propionic acid\n", + "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", + "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", + "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", + "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", + "tfp = 56.4*3600 #time for the experiment\n", + "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", + "#calculating tortusity factor\n", + "A= (pi/4)*(3.5**2) #area of the diaphragm\n", + "epsilon = 0.39 #average porosity of the diaphragm\n", + "l = 0.18 #thickness of hte diaphragm\n", + "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", + "print 'Tortuosity factor is: ',round(tou,1)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb new file mode 100755 index 00000000..b67d0cbd --- /dev/null +++ b/sample_notebooks/PrashantSahu/PrashantSahu_version_backup/Chapter-2-Molecular_Diffusion_-_Principles_of_Mass_Transfer_and_Separation_Process_by_Binay_K_Dutta_2.ipynb @@ -0,0 +1,789 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Molecular Diffusion" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1 pgno:10" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Molar average velocity of gas mixture is: 0.0303 m/s\n", + "Mass average velocity of gas mixture is: 0.029 m/s\n" + ] + } + ], + "source": [ + "#Calculation of average velocities\n", + "\n", + "N2 = 0.05 #mole fraction of Nitrogen denoted as 1\n", + "H2 = 0.15 #mole fraction of Hydrogen denoted as 2\n", + "NH3 = 0.76 #mole fraction of Ammonia denoted as 3\n", + "Ar = 0.04 #mole fraction of Argon denoted as 4\n", + "u1 = 0.03\n", + "u2 = 0.035\n", + "u3 = 0.03\n", + "u4 = 0.02\n", + "#Calculating molar average velocity\n", + "U = N2*u1 + H2*u2 + NH3*u3 + Ar*u4\n", + "print 'Molar average velocity of gas mixture is: %.4f m/s'%U\n", + "#Calculating of mass average velocity\n", + "M1 = 28\n", + "M2 = 2\n", + "M3 = 17\n", + "M4 = 40\n", + "M = N2*M1 + H2*M2 + NH3*M3 + Ar*M4\n", + "u = (1/M)*(N2*M1*u1 + H2*M2*u2 + NH3*M3*u3 + Ar*M4*u4)\n", + "print 'Mass average velocity of gas mixture is: %.3f m/s'%u" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2 pgno:16" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false, + "scrolled": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Time for complete evaporation is: 15.93 hours\n", + "(b) Time for disappearance of water is: 8.87 hours\n" + ] + } + ], + "source": [ + "#Diffusion of A through non-diffusing B\n", + "\n", + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "\n", + "#Calcualtion for (a) part\n", + "#calculating vapor pressure of water at 301K\n", + "pv = exp(13.8573 - (5160.2/301)) #in bar\n", + "#wet-bulb temperature is 22.5 degree centigrade\n", + "#calculating mean air-film temperature\n", + "Tm = ((28+22.5)/2)+273 #in kelvin\n", + "#calculating diffusion coefficient\n", + "Dab = ((0.853*(30.48**2))*((298.2/273)**1.75))/(3600*10000) #in m^2/s\n", + "l = 2.5e-3 #in m\n", + "P = 1.013 #in bar\n", + "R = 0.08317 #Gas constant\n", + "pAo = exp(13.8573 - (5160.2/295.2)) #vapor pressure of water at the wet-bulb temperature, 22.2C\n", + "pAl = 0.6*round(pv,4)\n", + "Na = (((round(Dab,7)*P)/(R*298.2*l))*log((P-pAl)/(P-round(pAo,3))))*18 #in kg/m^2s\n", + "#amount of water per m^2 of floor area is\n", + "thickness = 2e-3\n", + "Amount = thickness*1 #in m^3 \n", + "#density of water is 1000kg/m^3\n", + "#therefore in kg it is\n", + "amount = Amount*1000\n", + "Time_for_completion = amount/Na #in seconds\n", + "Time_for_completion_hours = Time_for_completion/3600\n", + "print '(a) Time for complete evaporation is: %.2f'%Time_for_completion_hours,'hours'\n", + "\n", + "#Calculation for (b) part\n", + "water_loss = 0.1 #in kg/m^2.h\n", + "water_loss_by_evaporation = Na*3600\n", + "total_water_loss = water_loss + water_loss_by_evaporation\n", + "time_for_disappearance = amount/total_water_loss\n", + "print '(b) Time for disappearance of water is: %0.2f'%time_for_disappearance,'hours'\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3 pgno:17" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The molar flux of Ammonia is:1.922E-05 gmol/cm^2.s\n", + "(b) and (c)\n", + "Velocity of A is 0.522 cm/s\n", + "Velocity of B is 0.000 cm/s\n", + "Mass average velocity of A is 0.439 cm/s\n", + "Molar average velocity of A is 0.47 cm/s\n", + "(d) Molar flux of NH3 is 3.062E-06 gmol/cm^2.s\n" + ] + }, + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAEPCAYAAABGP2P1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XmUVOW19/HvthsURAXFSyIiGERABKeADIolojYoojGK\nOI8hGjRZud4Q9I329Zogid6oITGoiENENIqIE8SpNBBEJhFlCKAog68ag4g4gb3vH08B3W0P1d11\n6lRV/z5rndV1qp4+tT3SteuZzd0RERHZZqe4AxARkdyixCAiIhUoMYiISAVKDCIiUoESg4iIVKDE\nICIiFUSaGMzsHjP7wMwW11DmdjNbYWaLzOywKOMREZHaRV1jmAiUVPeimQ0GDnD3TsCPgDsijkdE\nRGoRaWJw978DG2oocgpwX6rsHKClmbWJMiYREalZ3H0MbYE15c7XAvvGFIuIiBB/YgCwSudao0NE\nJEbFMb//OqBdufN9U89VYGZKFiIi9eDulb981yruGsM04HwAM+sNfOLuH1RV0N11uHP99dfHHkOu\nHLoXuhe6FzUf9RVpjcHMHgKOAVqb2RrgeqAJgLuPd/dnzGywma0ENgMXRRmPiIjULtLE4O7D0ygz\nMsoYRESkbuJuSpI6SiQScYeQM3QvdtC92EH3ouGsIe1Q2WJmng9xiojkEjPD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EBGRClRjEBGRCpQYRESkAiUGERGp\nQIlBREQqUGIQEZEKlBhERKSC/wMlMWMmKfP/ywAAAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#Calculation of flux and velocity\n", + "\n", + "%matplotlib inline\n", + "from math import log\n", + "from math import exp\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "#calculation for (a) part\n", + "l = 1 #thickness of air in cm\n", + "pAo = 0.9 #in atm\n", + "pAl = 0.1 #in atm\n", + "Dab = 0.214 #in cm^2/s\n", + "T = 298 #in K\n", + "P = 1 #in atm\n", + "R = 82.1 #in (cm^3)(atm)/(K)(gmol)\n", + "#calculating molar flux of ammonia\n", + "Na = ((Dab*P)/(R*T*l))*log((P-pAl)/(P-pAo))\n", + "print '(a) The molar flux of Ammonia is:%0.3E'%Na,'gmol/cm^2.s'\n", + "\n", + "#calculation for (b) and (c) part\n", + "Nb = 0 #air is non-diffusing\n", + "U = (Na/(P/(R*T))) #molar average velocity\n", + "yA = pAo/P\n", + "yB = pAl/P\n", + "uA = U/yA #\n", + "uB = 0 #since Nb=0\n", + "Ma = 17\n", + "Mb = 29\n", + "M = Ma*yA + Mb*yB\n", + "u = uA*yA*Ma/M #since u =(uA*phoA + uB*phoB)/pho\n", + "print '(b) and (c)'\n", + "print 'Velocity of A is %0.3f'%uA,'cm/s'\n", + "print 'Velocity of B is %0.3f'%uB,'cm/s'\n", + "print 'Mass average velocity of A is %0.3f'%u,'cm/s'\n", + "print 'Molar average velocity of A is %0.2f'%U,'cm/s'\n", + "\n", + "#calculation for (d) part\n", + "Ca = pAo/(R*T)\n", + "Ia = Ca*(uA - u) #molar flux of NH3 relative to an observer moving\n", + " #with the mass average velocity \n", + "print '(d) Molar flux of NH3 is %0.3E'%Ia,'gmol/cm^2.s'\n", + "\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(1-(0.1*exp(2.197*z[i])))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "#Answers may vary due to round off error" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.4 pgno:19" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) Rate of diffusion of oxygen 7.151E-10 kmol/s\n", + "(b) The partial pressure gradient of oxygen at midway in diffusion path is: -4.25 bar/m\n", + "(c)\n", + "Molar average velocity and diffusion velocities at \"midway\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 7.9E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"top of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen 3.72E-04 m/s\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "Molar average velocity and diffusion velocities at \"bottom of tube\"\n", + "Molar average velocity in z-direction is 9.9E-05 m/s\n", + "The diffusion velocity of oxygen is not infinity\n", + "The diffusion velocity of Nitrogen -9.9E-05 m/s\n", + "(d)\n", + "New molar flux of (A) 4.95E-06 kmol/m^2.s\n", + "New molar flux of (B) 7.19E-06 kmol/m^2.s\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAEKCAYAAAAMzhLIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHi1JREFUeJzt3XmUVNW59/HvI42CSDOIoAwCMqioiAM44NACKuLAvbnX\nqNFwxVl81USjETXCfZfG+Y3xGl1elWgS0TglKlEQ0HKIIoiKIoKgIIOKEyJBhIZ+3j92td1gd3V1\nd506p6p/n7X2qlOnTp/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259DGjgEsJk6rNcff/MrP7ge8IawJ0JMzmOxoYCLzu7qPTP9sJeLoYR9BLcVGiEKmDmZUQ\nFkG6CbgZGOzuX5vZHoT5tQ5Kv2/r7t+Y2R+Bbdz9Z2Z2AvAXwsJS84BZwJnuPid97o+Avdx9bQz/\nNJGsqOlJpG63A9PdfRLQudr8QEOARyrfu/s31X7m6fTrXOAzd3/Pw19l7xFWYau0ks1n8hRJnMRO\nCiiSBOl1lbu5+5gaPnZqX+tiQ/q1AlhfbX8Fm//eGcW5hooUEdUoRGphZvsR+h+qrwr3iZm1T28/\nD5xY+d7M2jXgMp2oYW0RkSRRjUKkdhcQpm5/IT11+xvAK4RO6SnuPs/MrgNeNLNNwJuE1QVh81rC\nljUGBzCzHQnrNqt/QhJNndki9WBmZcBJ7n5+Ds51DtDK3X/X6MBEIqSmJ5F6cPcUYSW1XAyUO4mw\ndK1IoqlGISIiGalGISIiGSlRiIhIRkoUIiKSkRKFiIhkpEQhIiIZKVGIiEhG/x/dtbi5bQDtAwAA\nAABJRU5ErkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "#Flux, velocity and pressure gradient\n", + "\n", + "#calculation of (a) part\n", + "#given data\n", + "from math import log\n", + "from math import pi\n", + "from math import exp\n", + "import numpy as np\n", + "from matplotlib import pyplot as plt\n", + "T = 298 #in kelvin\n", + "P = 1.013 #in bar\n", + "pAl = 0 #partial pressure of oxygen(A) at liquid surface\n", + "pAo = 0.21*1.013 #partial pressure of oxygen at open mouth\n", + "l = 0.05 #length of diffusion path in m\n", + "Dab = 2.1e-5 #diffusivity in m^2/s\n", + "R = 0.08317 #in m^3.bar.kmol.K\n", + "Na = Dab*P*log((P-pAl)/(P-pAo))/(R*T*l) #in kmol/m^2.s\n", + "area = (pi/4)*(0.015)**2\n", + "rate = area*Na\n", + "print '(a) Rate of diffusion of oxygen %0.3E'%rate,'kmol/s'\n", + "z = []\n", + "pa =[]\n", + "for i in np.arange(0,1,0.01):\n", + " z.append(i)\n", + " \n", + "for i in range(0,len(z)):\n", + " pa.append(P-(P-pAo)*exp((R*T*Na*z[i])/(Dab*P)))\n", + " \n", + "from matplotlib.pyplot import*\n", + "plot(z,pa);\n", + "plt.xlabel('z(cm)');\n", + "plt.ylabel('pA(atm)');\n", + "\n", + "#calculation of (b) part\n", + "z = 0.025 #diffusion path\n", + "pA = 0.113 #in bar\n", + "#we have to find partial pressure gradient of oxygen at mid way of diffusion path\n", + "#let dpA/dz = ppd\n", + "ppd = -(R*T*round(Na,8)*(P-pA))/(Dab*P)\n", + "print '(b) The partial pressure gradient of oxygen at midway in diffusion path is: %0.2f'%ppd,'bar/m'\n", + "\n", + "#calculation of (c) part\n", + "uA = Na*(R*T/pA) #velocity of oxygen\n", + "uB = 0 #since nitrogen is non-diffusing hence Nb = 0\n", + "U = pA*uA/P #since U=1/C*(uA*Ca + uB*Cb)\n", + "vAd = uA - U #diffusion velocity of oxygen\n", + "vBd = uB - U #diffusion velocity of nitrogen\n", + "print '(c)'\n", + "print 'Molar average velocity and diffusion velocities at \"midway\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.1E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0(at top of tube)\n", + "uA = Na*(R*T/pAo)\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"top of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen %0.2E'%vAd,'m/s'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "#at z=0.05(at bottom of tube)\n", + "#uA = inf\n", + "uB = 0\n", + "U = pAo*uA/P\n", + "vAd = uA - U\n", + "vBd = uB - U\n", + "print 'Molar average velocity and diffusion velocities at \"bottom of tube\"'\n", + "print 'Molar average velocity in z-direction is %0.1E'%U,'m/s'\n", + "print 'The diffusion velocity of oxygen is not infinity'\n", + "print 'The diffusion velocity of Nitrogen %0.1E'%vBd,'m/s'\n", + "\n", + "#calculation of (d) part\n", + "V = -2*U\n", + "pA = 0.113\n", + "Nad = round(Na,8) - V*(pA/(R*T))\n", + "Nbd = 0 - (P - pA)*V/(R*T)\n", + "print '(d)'\n", + "print 'New molar flux of (A) %0.2E'%Nad,'kmol/m^2.s'\n", + "print 'New molar flux of (B) %0.2E'%Nbd,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5 pgno:21" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a) The air-film thickness is :0.00193 m\n" + ] + } + ], + "source": [ + "#Diffusion with changing bulk concentration\n", + "\n", + "from math import log\n", + "#given data\n", + "area = 3*4 #in m^2\n", + "mperarea = 3.0/12 #in kg/m^2\n", + "#part (a)\n", + "P = 1.013 #in bar\n", + "Dab = 9.95e-6 #in m^2/s\n", + "R = 0.08317 #in m^3.bar./K.kmol\n", + "T = 273+27 #in K\n", + "#let d=1\n", + "d = 1 #in m\n", + "pAo = 0.065 #partial pressure of alcohol on liquid surface\n", + "pAd = 0 #partial pressure over d length of stagnant film of air\n", + "Na = (Dab*P*log((P-pAd)/(P-pAo)))/(R*T*d) #in kmol/m^2.s\n", + "Na = Na*60 #in kg/m^2.s\n", + "flux = mperarea/(5*60) #since the liquid evaporates completely in 5 minutes\n", + "#now we have to find the value of d\n", + "d = Na/flux\n", + "print '(a) The air-film thickness is :%0.5f'%d,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6 pgno:24" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(a)\n", + "The steady-state flux is: 3.35E-06 kmol/m^2.s\n", + "The rate of transport of N2 from vessel 1 to 2: 6.6E-09 kmol/s\n", + "(b)\n", + "The flux and the rate of transport of oxygen is: -3.35E-06 kmol/m^2.s\n", + "(c)\n", + "Partial pressure at a point 0.05m from vessel 1 is: 1.2 atm\n", + "(d)\n", + "Net or total mass flux: -1.340E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Equimolar counterdiffusion\n", + "\n", + "from math import pi\n", + "#given data\n", + "#part (a)\n", + "Dab = 0.23e-4*0.5*(293.0/316)**1.75 #in m^2/s\n", + "pA1 = 2*0.8 #in atm\n", + "pA2 = 2*0.2 #in atm\n", + "l = 0.15 #in m\n", + "R = 0.0821 #in m^3.atm./K.kmol\n", + "T = 293 #in K\n", + "Ma = 28\n", + "Mb = 32\n", + "Na = Dab*(pA1-pA2)/(R*T*l) #in kmol/m^2.s\n", + "area = pi/4*(0.05)**2 #in m^2\n", + "rate = area*Na\n", + "print '(a)'\n", + "print 'The steady-state flux is: %0.2E'%Na,'kmol/m^2.s'\n", + "print 'The rate of transport of N2 from vessel 1 to 2: %0.1E'%rate,'kmol/s'\n", + "\n", + "#part (b)\n", + "Nb = -Na\n", + "print '(b)'\n", + "print 'The flux and the rate of transport of oxygen is: %0.2E'%Nb,'kmol/m^2.s'\n", + "\n", + "#part (c)\n", + "#let dpA/dz = ppg\n", + "dz = 0.05 #in m\n", + "ppg = (pA2 - pA1)/l #in atm/m\n", + "pA = pA1 + (ppg)*dz #in atm\n", + "print '(c)'\n", + "print 'Partial pressure at a point 0.05m from vessel 1 is: %0.1f'%pA,'atm'\n", + "\n", + "#part (d)\n", + "nt = Ma*Na + Mb*Nb\n", + "print '(d)'\n", + "print 'Net or total mass flux: %0.3E'%nt,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7 pgno:25" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Methanol flux: 4.64e-05 kmol/m^2.s\n", + "Water flux: -4.06e-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Non-equimolar counterdiffusion in distillation of a binary mixture\n", + "\n", + "from math import log\n", + "#given data\n", + "Ha = 274.6*32 #molar latent heat of methanol(a)\n", + "Hb = 557.7*18 #molar latent heat of water(b)\n", + "yAl = 0.76 #mole fraction of methanol in the vapour\n", + "yAo = 0.825 #mole fraction of methanol in the vapour at the liquid-vapour interface\n", + "P = 1 #in atm\n", + "l = 1e-3 #in m\n", + "T =344.2 #in K\n", + "R = 0.0821 #m^3.atm./K.kmol\n", + "Dab = 1.816e-5 #in m^2/s\n", + "Na = Dab*P*log((1-0.1247*yAl)/(1-0.1247*yAo))/(0.1247*R*T*l)\n", + "print 'Methanol flux: %0.2e'%Na,'kmol/m^2.s'\n", + "Nb = -(Ha/Hb)*Na\n", + "print 'Water flux: %0.2e'%Nb,'kmol/m^2.s'\n", + "#Answers may vary due to round off errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8 pgno:27" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of pA1 is 0.937 atm\n" + ] + } + ], + "source": [ + "#Equimolar counterdiffusion in an interconnected system\n", + "\n", + "#given values\n", + "from math import exp\n", + "V1 = 3000 #in cm^3\n", + "V2 = 4000 #in cm^3\n", + "Dab = 0.23 #in cm^2/s\n", + "Dba = 0.23 #in cm^2/s\n", + "l1 = 4 #in cm\n", + "d1 = 0.5 #in cm\n", + "l2 = 2 #in cm\n", + "d2 = 0.3 #in cm\n", + "pA3 = 1 #in atm\n", + "#unknowns\n", + "# pA1 and pA2\n", + "# dpA1bydt = (Dab/V1*l1)*((pA1)-(pA2))*((math.pi*(d1**2))/4)\n", + "#on integrating using Laplace trandformation\n", + "# initial conditions\n", + "t=18000 #in seconds\n", + "pA1 = 1-0.57*(exp((-1.005)*(10**(-6))*t)-exp((-7.615)*(10**(-6))*t))\n", + "print 'Value of pA1 is %0.3f'%pA1,'atm'" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.10 pgno:34" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Value of flux of water vapour: 2.96E-05 kmol/m^2.s\n" + ] + } + ], + "source": [ + "#Diffusion of only one component in a three-component mixture\n", + "\n", + "#given values\n", + "from math import log\n", + "y1l = 0 #mol fraction of dry air\n", + "y10 = (17.53/760) #mol fraction of water\n", + "l = 1.5 #in mm\n", + "C = 0.0409 #in kmol/m^3 : calculated by P/RT\n", + "D12 = 0.923 #Diffusivity of hydrogen over water\n", + "D13 = 0.267 #Diffusivity of oxygen over water\n", + "y2 = 0.6 #mole fraction of hydrogen\n", + "y3 = 0.4 #mole fraction of oxygen\n", + "D1m = 1/((y2/D12)+(y3/D13)) #calculating mean diffusivity\n", + "Ni = (D1m*C*1000/(l*10000))*log((1-y1l)/(1-y10))\n", + "print 'Value of flux of water vapour: %0.2E'%Ni,'kmol/m^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.11 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Flux of ethane 4.804E-05 gmol/cm^2.s\n" + ] + } + ], + "source": [ + "#Multicomponent diffusion\n", + "\n", + "from math import log\n", + "#given data\n", + "y1 = 0.4 #mole fraction of ethane(1)\n", + "y2 = 0.3 #mole fraction of ethylene(2)\n", + "y3 = 0.3 #mole fraction of hydrogen(3)\n", + "#calculating D13\n", + "#The Lennard-Jones parameters are\n", + "sigma1 = 4.443 #in angstrom\n", + "sigma2 = 4.163 #in angstrom\n", + "sigma3 = 2.827 #in angstrom\n", + "e1byk = 215.7\n", + "e2byk = 224.7\n", + "e3byk = 59.7\n", + "sigma13 = (sigma1 + sigma3)/2 #in angstrom\n", + "e13byk = (e1byk*e3byk)**0.5\n", + "kTbye13 = 993/113.5\n", + "ohmD13 = 0.76 #from collision integral table\n", + "D13 = ((0.001858)*(993**1.5)*((1.0/30)+(1.0/2))**0.5)/((2)*(sigma13**2)*(ohmD13))\n", + "#calculating D23\n", + "sigma23 = (sigma2+sigma3)/2\n", + "kTbye23 = ((993/224.7)*(993/59.7))*0.5\n", + "ohmD23 = 0.762\n", + "D23 = (0.001858*(993**1.5)*((1.0/28)+(1.0/2))**0.5)/(2*(sigma23**2)*ohmD23)\n", + "D = (D13+D23)/2 #in cm^2/s\n", + "l = 0.15 #in cm\n", + "#at z=0 (bulk gas)\n", + "y10 = 0.6\n", + "y20 = 0.2\n", + "y30 = 0.2\n", + "#at z=l (catalyst surface)\n", + "y1l = 0.4\n", + "y2l = 0.3\n", + "y3l = 0.3\n", + "C = 2.0/(82.1*993) #calculated by P/RT\n", + "N1 = (D*C/l)*log((y10+y20)/(y1l+y2l))\n", + "print 'Flux of ethane %0.3E'%N1,'gmol/cm^2.s'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.12 pgno:43" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The liquid-film thickness is: 0.0004 m\n" + ] + } + ], + "source": [ + "#Liquid-phase diffusion\n", + "\n", + "#given data\n", + "from math import pi\n", + "rc = 5e-4 #in m\n", + "D = 7e-10 #in m^2/s\n", + "Cab = 1 #in kmol/m^3\n", + "Na = 3.15e-6 #in kmol/m^2.s\n", + "W = 4*pi*(rc**2)*Na #the rate of reaction\n", + "#let (rc+delta)/delta = 1\n", + "w1 = 4*pi*D*Cab*rc*1 #flux of the reactant to the surface of the catalyst\n", + "rcplusdelta = W/w1\n", + "delta = rc/(rcplusdelta-1) #stagnant liquid-film thickness \n", + "print 'The liquid-film thickness is: ',delta,'m'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.13 pgno:46" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tortuosity factor is: 2.5\n" + ] + } + ], + "source": [ + "#Diffusivity determination--diaphragm cell\n", + "\n", + "#given data\n", + "from math import log\n", + "from math import pi\n", + "V1 = 60.2 #in cm^3; volume of compartment 1\n", + "V2 = 59.3 #volume of compartment 2 in cm^3\n", + "Ca1i = 0.3 #initial concentration of KCl in compartment 1\n", + "Ca2i = 0 #initial concentration of KCl in compartment 2\n", + "Ca1f = 0.215 #final concentration of KCl in compartment 1\n", + "Ca2f = 0.0863 #final concentration of KCl in compartment 2\n", + "D = 1.51e-5 #diffusivity of KCl in cm^2/s\n", + "tf = 55.2*3600 #time of the experiment in s\n", + "#calcutaling cell constant\n", + "beta = (1/(D*tf))*log((Ca1i - Ca2i)/(Ca1f - Ca2f))\n", + "#diffusion of propionic acid\n", + "Cpa1i = 0.4 #initial concentration of propionic acid in compartment 1\n", + "Cpa2i = 0 #initial concentration of propionic acid in compartment 2\n", + "Cpa1f = 0.32 #final concentration of propionic acid in compartment 1\n", + "Cpa2f = 0.0812 #final concentration of propionic acid in compartment 2 by mass balance\n", + "tfp = 56.4*3600 #time for the experiment\n", + "Dp = (1/(beta*tfp))*log((Cpa1i-Cpa2i)/(Cpa1f-Cpa2f)) #diffusivity of the propionic acid\n", + "#calculating tortusity factor\n", + "A= (pi/4)*(3.5**2) #area of the diaphragm\n", + "epsilon = 0.39 #average porosity of the diaphragm\n", + "l = 0.18 #thickness of hte diaphragm\n", + "tou = (A*epsilon/(beta*l))*(1/V1 + 1/V2)\n", + "print 'Tortuosity factor is: ',round(tou,1)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter1.ipynb b/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter1.ipynb new file mode 100755 index 00000000..0d151d06 --- /dev/null +++ b/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter1.ipynb @@ -0,0 +1,1600 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 - Semiconductor Material & Junction Diode" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.1 Page No 51" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The electron drift velocity = 40.00 m/s\n", + "The time required for an electron to move across the thickness = 12.50 micro seconds\n" + ] + } + ], + "source": [ + "# Given data\n", + "miu = 0.2# m**2/V-s\n", + "V = 100# mV\n", + "V = V * 10**-3# V\n", + "d = 0.5# mm\n", + "d = d * 10**-3# m\n", + "# mobility, miu = Vd/E and\n", + "E = V/d\n", + "# Drift velocity,\n", + "Vd = miu*E# m/s\n", + "print \"The electron drift velocity = %.2f m/s\"%Vd\n", + "# Time required,\n", + "T = d/Vd# sec\n", + "T=T*10**6# µs\n", + "print \"The time required for an electron to move across the thickness = %.2f micro seconds\"%T" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.2 Page No 52" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The intrinsic conductivity = 2.24 (ohm-m)**-1\n" + ] + } + ], + "source": [ + "# Given data\n", + "q = 1.6*10**-19# C\n", + "n_i = 2.5*10**19# /m**3\n", + "miu_n = 0.38# m**2/V-s\n", + "miu_p = 0.18# m**2/V-s\n", + "# The intrinsic conductivity for germanium,\n", + "sigma_i = q*n_i*(miu_n+miu_p)# (ohm-m)**-1\n", + "print \"The intrinsic conductivity = %.2f (ohm-m)**-1\"%sigma_i" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.3 Page No 52" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The intrinsic carrier concentration = 2.16e+19 per m**3\n" + ] + } + ], + "source": [ + "# Given data\n", + "rho = 0.50# ohm-m\n", + "q = 1.6*10**-19# C\n", + "miu_n = 0.39# m**2/V-s\n", + "miu_p = 0.19# m**2/V-s\n", + "sigma = 1/rho# (ohm-m)**-1\n", + "#conductivity of a semiconductor, sigma = q*n_i*(miu_p+miu_n) or\n", + "n_i = sigma/(q*(miu_n+miu_p))# /m**3\n", + "print \"The intrinsic carrier concentration = %.2e per m**3\"%n_i" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.4 Page No 52" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The conductivity of Si sample = 14.40 (ohm-m)**-1\n" + ] + } + ], + "source": [ + "# Given data\n", + "N_D = 10**21# /m**3\n", + "N_A = 5*10**20# /m**3\n", + "NdasD = N_D-N_A# /m**3\n", + "n = NdasD# /m**3\n", + "miu_n = 0.18# m**2/V-s\n", + "q = 1.6*10**-19# C\n", + "# The conductivity of silicon,\n", + "sigma = q*n*miu_n# (ohm-m)**-1\n", + "print \"The conductivity of Si sample = %.2f (ohm-m)**-1\"%sigma" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.5 Page No 53" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The conductivity of copper = 4.79e+05 mho/cm\n" + ] + } + ], + "source": [ + "# Given data\n", + "At = 63.54## atomic weight of copper\n", + "d = 8.9## density = %.2f gm/cm**3\n", + "n = 6.023*10**23/At*d# electron/cm**3\n", + "q = 1.63*10**-19# C\n", + "miu = 34.8# m**2/V-s\n", + "# The conductivity of copper,\n", + "sigma = n*q*miu# mho/cm\n", + "print \"The conductivity of copper = %.2e mho/cm\"%sigma" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.6 Page No 53" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Concentration of holes in a p-type Ge = 3.47e+17 /cm**3\n", + "The concentration of electrons in a p-type Ge = 1.80e+09 /cm**3\n", + "The concentration of electrons in n-type Si = 4.81e+14 /cm**3\n", + "The concentration of holes in n-type Si = 4.68e+05 /cm**3\n" + ] + } + ], + "source": [ + "# Given data\n", + "sigma = 100# (ohm-m)**-1\n", + "n_i = 2.5*10**13# /cm**3\n", + "miu_n = 3800# cm**2/V-s\n", + "miu_p = 1800# cm**2/V-s\n", + "q = 1.6*10**-19# C\n", + "# Conductivity of a p-type germanium, sigma = q*p*miu_p or\n", + "p = sigma/(q*miu_p)# /cm**3\n", + "print \"Concentration of holes in a p-type Ge = %.2e /cm**3\"%p\n", + "# The concentration of electrons = %.2f a p-type Ge\n", + "n = (n_i**2)/p# /cm**3\n", + "print \"The concentration of electrons in a p-type Ge = %.2e /cm**3\"%n\n", + "#Given for Si\n", + "sigma= 0.1# (ohm m)**-1\n", + "miu_n= 1300# cm**2/V-sec\n", + "n_i= 1.5*10**10# /cm**3\n", + "#sigma = q*n*miu_n\n", + "n = sigma/(q*miu_n)# /cm**3\n", + "print \"The concentration of electrons in n-type Si = %.2e /cm**3\"%n\n", + "# The concentration of holes = %.2f n-type Si\n", + "p = (n_i**2)/n# /cm**3\n", + "print \"The concentration of holes in n-type Si = %.2e /cm**3\"%p" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.7 Page No 54" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The resistivity of a dopped Ge = 3.72 ohm-cm\n" + ] + } + ], + "source": [ + "# Given data\n", + "miu_n = 3800## cm**2/V-s\n", + "miu_p = 1800## cm**2/V-s\n", + "n_i = 2.5*10**13# /cm**3\n", + "Nge = 4.41*10**22# /cm**3\n", + "q = 1.602*10**-19# C\n", + "impurity = 10**8\n", + "# The number of donor atoms,\n", + "N_D = Nge/impurity##in /cm**3\n", + "# The number of holes\n", + "p = (n_i**2)/N_D# /cm**3\n", + "# Conductivity of an N-type Ge,\n", + "sigma = q*N_D*miu_n# (ohm-cm)**-1\n", + "# The resistivity of the Ge\n", + "rho = 1/sigma# ohm-cm\n", + "print \"The resistivity of a dopped Ge = %.2f ohm-cm\"% rho" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.8 Page No 54" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The resistivity of intrinsic silicon = 2.25e+05 ohm-cm\n", + "The resistivity of doped silicon = 4.67 ohm-cm\n" + ] + } + ], + "source": [ + "# Given data\n", + "Nsi = 4.96*10**22# /cm**3\n", + "n_i = 1.52*10**10# /cm**2\n", + "q = 1.6*10**-19# C\n", + "miu_n = 0.135# m**2/V-s\n", + "miu_n = miu_n * 10**4# cm**2/V-s\n", + "miu_p = 0.048# m**2/V-s\n", + "miu_p = miu_p * 10**4# cm**2/V-s\n", + "# The conductivity of an intrinsic silicon,\n", + "sigma = q*n_i*(miu_n+miu_p)# (ohm-cm)**-1\n", + "# The resistivity of intrinsic silicon \n", + "rho = 1/sigma# ohm-cm\n", + "print \"The resistivity of intrinsic silicon = %.2e ohm-cm\"%rho\n", + "\n", + "impurity = 50*10**6\n", + "# The number of donor atoms,\n", + "N_D = Nsi/impurity# /cm**3\n", + "# Total free electrons,\n", + "n = N_D# /cm**3\n", + "# Total holes = %.2f a doped Si,\n", + "p = (n_i**2)/n# /cm**3\n", + "# Conductivity of a doped Si,\n", + "sigma = q*n*miu_n# (ohm-m)**-1\n", + "# The resistivity of doped silicon\n", + "rho = 1/sigma# ohm-cm\n", + "print \"The resistivity of doped silicon = %.2f ohm-cm\"%rho" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.9 Page No 55" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of temperature = 0.14 K\n" + ] + } + ], + "source": [ + "# Given data\n", + "N_D= 5.0*10**28/(2.0*10**8)\n", + "# The Fermi level, E_F= E_C if,\n", + "N_C= N_D\n", + "# Formula N_C= 4.82*10**21*T**(3/2)\n", + "T= (N_C/(4.82*10**21.0))**(2.0/3)# K\n", + "print \"The value of temperature = %.2f K\"%T" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.10 Page No 55" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The miniority carrier concentration = 0.10 m**2/V-s\n", + "The resistivity = 0.60 ohm-m\n", + "The position of Fermi level = 0.23 eV\n", + "Minority carrier concentration = 9.00e+12 atoms/cm**3\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "n_i = 1.5*10**16##m**3\n", + "impurity = 10**20\n", + "minority = (n_i**2)/impurity# atoms/m**3\n", + "q = 1.6*10**-19# C\n", + "rho = 2*10**3# ohm-m\n", + "# The miniority carrier concentration \n", + "miu_n = 1/(q*rho*n_i*2)##in m**2/V-s\n", + "print \"The miniority carrier concentration = %.2f m**2/V-s\"%miu_n\n", + "n = impurity\n", + "# The conductivity,\n", + "sigma = q*impurity*miu_n# (ohm-m)**-1\n", + "# The resistivity \n", + "rho = 1/sigma# ohm-m\n", + "print \"The resistivity = %.2f ohm-m\"%rho\n", + "kT = 0.026# eV\n", + "n_o = n\n", + "# The position of Fermi level \n", + "E_FdividedEi = kT*math.log(n_o/n_i)# eV\n", + "print \"The position of Fermi level = %.2f eV\"%E_FdividedEi\n", + "# Minority carrier concentration \n", + "M = ((n_i*2)**2)/n_o# atoms/cm**3\n", + "print \"Minority carrier concentration = %.2e atoms/cm**3\"%M" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.11 Page No 56" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The resistivity = 9.62 ohm-cm\n" + ] + } + ], + "source": [ + "# Given data\n", + "d = 5.0*10**22# atoms/cm**3\n", + "impurity = 10**8# atoms\n", + "N_D = d/impurity\n", + "n_i = 1.45*10**10\n", + "n = N_D\n", + "#Low of mass action, n*p = (n_i**2)\n", + "p = (n_i**2)/n# /cm**3\n", + "q = 1.6*10**-19# C\n", + "miu_n = 1300# cm/V-s\n", + "n_i = n\n", + "#The Conductivity\n", + "sigma = q*miu_n*n_i# (ohm-cm)**-1\n", + "# The resistivity\n", + "rho = 1/sigma# ohm-cm\n", + "print \"The resistivity = %.2f ohm-cm\"%rho" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.12 Page No 57" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The resistivity = 9.62 ohm-cm\n" + ] + } + ], + "source": [ + "# Given data\n", + "d = 5.0*10**22# atoms/cm**3\n", + "impurity = 10**8# atoms\n", + "N_D = d/impurity\n", + "n_i = 1.45*10**10\n", + "n = N_D\n", + "#Low of mass action, n*p = (n_i**2)\n", + "p = (n_i**2)/n# /cm**3\n", + "q = 1.6*10**-19# C\n", + "miu_n = 1300# cm/V-s\n", + "n_i = n\n", + "#The Conductivity\n", + "sigma = q*miu_n*n_i# (ohm-cm)**-1\n", + "# The resistivity\n", + "rho = 1/sigma# ohm-cm\n", + "print \"The resistivity = %.2f ohm-cm\"%rho" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.14 Page No 58" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The minority carrier concentration = 2.25e+03 holes/cm**3\n", + "The location of Fermi level = 0.409 eV\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "n_i = 1.5*10**10# electrons/cm**3\n", + "N_D = 10**17# electrons/cm**3\n", + "n = N_D# electrons/cm**3\n", + "# The minority carrier concentration\n", + "p = (n_i**2)/n# holes/cm**3\n", + "print \"The minority carrier concentration = %.2e holes/cm**3\"%p\n", + "kT = 0.026\n", + "# The location of Fermi level \n", + "E_FminusEi = kT*math.log(N_D/n_i)# eV\n", + "print \"The location of Fermi level = %.3f eV\"%E_FminusEi" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.15 Page No 59" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The doping level = 1.92e+15 /cm**3\n", + "The drift velocity = 650.00 cm/sec\n" + ] + } + ], + "source": [ + "# Given data\n", + "V = 1# V\n", + "I = 8# mA\n", + "I = I * 10**-3# A\n", + "R = V/I# ohm\n", + "l = 2# mm\n", + "l = l * 10**-1# cm\n", + "b = 2# mm\n", + "b = b * 10**-1# cm\n", + "A = l*b# cm**2\n", + "L = 2# cm\n", + "# R = (rho*L)/A\n", + "sigma = L/(R*A)# (ohm-cm)**-1\n", + "# n = N_D\n", + "miu_n = 1300# cm**2/V-s\n", + "q = 1.6 * 10**-19# C\n", + "# sigma = n*q*miu_n\n", + "N_D = sigma/( miu_n*q )# /cm**3\n", + "print \"The doping level = %.2e /cm**3\"%N_D\n", + "d = 2.0\n", + "E = V/d\n", + "# The drift velocity \n", + "Vd = miu_n * E# cm/s\n", + "print \"The drift velocity = %.2f cm/sec\"%Vd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.17 Page No 60" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The conductivity = 4.68e+05 mho/m\n", + "The mobility = 3.48e-05 m**2/V-s\n", + "The drift velocity = 1.79e-04 m/s\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "l = 1000# ft\n", + "l = l * 12*2.54# cm\n", + "R = 6.51# ohm\n", + "rho = R/l# ohm/cm\n", + "# The conductivity \n", + "sigma = 1/rho# mho/cm\n", + "sigma = sigma * 10**2# mho/m\n", + "D= 1.03*10**-3# m\n", + "A= math.pi*D**2/4# m**2\n", + "print \"The conductivity = %.2e mho/m\"%sigma\n", + "q = 1.6*10**-19# C\n", + "n = 8.4*10**28# electrons/m**3\n", + "# sigma = n*q*miu\n", + "miu = sigma/(n*q)# m**2/V-s\n", + "print \"The mobility = %.2e m**2/V-s\"%miu\n", + "T = 2\n", + "# The drift velocity \n", + "V = T/(n*q*A)# m/s\n", + "print \"The drift velocity = %.2e m/s\"%V" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.18 Page No 61" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The concentration of holes = 1.50e+16 /cm**3\n", + "The concentartion of electrons = 6.67e+07 /cm**3\n" + ] + } + ], + "source": [ + "# Given data\n", + "N_D = 2*10**16# /cm**3\n", + "N_A = 5*10**15# /cm**3\n", + "# The concentration of holes \n", + "Pp = N_D-N_A# /cm**3\n", + "print \"The concentration of holes = %.2e /cm**3\"%Pp\n", + "n_i = 10**12\n", + "# The concentartion of electrons \n", + "n_p = (n_i**2)/Pp# /cm**3\n", + "print \"The concentartion of electrons = %.2e /cm**3\"%n_p" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.19 Page No 62" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The hall angle = 1.95 degree\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "rho = 0.005# ohm-m\n", + "Bz = 0.48# Wb/m**2\n", + "R_H = 3.55*10**-4# m**3/C\n", + "ExByJx= rho\n", + "# R_H = Ey/(Bz*Jx)\n", + "EyByJx= R_H*Bz\n", + "# The hall angle \n", + "theta_H = math.degrees(math.atan(EyByJx/ExByJx))# °\n", + "print \"The hall angle = %.2f degree\"%theta_H" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.20 Page No 63" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage between contacts = 0.0026 V\n" + ] + } + ], + "source": [ + "# Given data\n", + "R_H = 3.55 * 10**-4# m**3/C\n", + "Ix = 15# mA\n", + "Ix = Ix * 10**-3# A\n", + "A = 15*1# mm\n", + "A = A * 10**-6# m**2\n", + "Bz = 0.48# Wb/m**2\n", + "Jx = Ix/A# A/m**2\n", + "# R_H = Ey/(Bz*Jx)\n", + "Ey = R_H*Bz*Jx# V/m\n", + "# voltage between contacts \n", + "Voltage = Ey*Ix# V\n", + "print \"The voltage between contacts = %.4f V\"%Voltage" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.21 Page No 63" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The concentration of donor atoms = 4.630e+13 cm**-3\n" + ] + } + ], + "source": [ + "# Given data\n", + "A = 0.001# cm**2\n", + "l = 20# µm\n", + "l = l * 10**-4# cm\n", + "V = 20# V\n", + "I = 100# mA\n", + "I = I * 10**-3# A\n", + "R = V/I# ohm\n", + "# R = l/(sigma*A)\n", + "sigma = l/(R*A)# (ohm-cm)**-1\n", + "miu_n = 1350# cm**2/V-s\n", + "q = 1.6*10**-19# C\n", + "# sigma = n*q*miu_n or\n", + "# The concentration of donor atoms \n", + "n = sigma/(q*miu_n)# cm**-3\n", + "print \"The concentration of donor atoms = %.3e cm**-3\"%n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.22 Page No 64" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The doping needed = 8.681e+15 cm**-3\n" + ] + } + ], + "source": [ + "# Given data\n", + "R = 2# k ohm\n", + "R = R * 10**3# ohm\n", + "L = 200# µm\n", + "L = L * 10**-4# cm\n", + "A = 10**-6# cm**2\n", + "miu_n = 8000# cm**2/V-s\n", + "q = 1.6*10**-19# C\n", + "n = '0.9*N_D'\n", + "# R = (rho*l)/A= (1/(n*q*miu_n))*(l/A)\n", + "# rho = L/(R*q*miu_n*A)\n", + "n = L/(R*q*miu_n*A)# /cm**-3\n", + "# The doping needed \n", + "Nd= n/0.9\n", + "print \"The doping needed = %.3e cm**-3\"%Nd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.23 Page No 65" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The position of the Fermi level = 0.29 eV\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "KT = 26*10**-3\n", + "Nd = 10**15\n", + "n_i = 1.5*10**10\n", + "# The position of the Fermi level \n", + "E_FminusE_Fi = KT*math.log(abs( Nd/n_i ))# eV\n", + "print \"The position of the Fermi level = %.2f eV\"%E_FminusE_Fi" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.24 Page No 65" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The concentration of donors atoms = 1.2176e+16 cm**-3\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "Na = 5 * 10**15# cm**-3\n", + "Nc = 2.8 * 10**19# cm**-3\n", + "E_CminusE_F = 0.215# eV\n", + "KT = 26* 10**-3# eV\n", + "# The concentration of donors atoms \n", + "Nd = Na + Nc * (math.exp( -E_CminusE_F/KT ))# cm**-3\n", + "print \"The concentration of donors atoms = %.4e cm**-3\"%Nd" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.25 Page No 65" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The percentage doping efficiency = 78.12 %\n" + ] + } + ], + "source": [ + "# Given data\n", + "Nd = 10**18\n", + "R = 10# ohm\n", + "A =10**-6# cm**2\n", + "L = 10# mm\n", + "L = L * 10**-4# cm\n", + "miu_n = 800# cm**2/V-s\n", + "q = 1.6*10**-19# C\n", + "#Formula used, n = L/(q*miu_n*A*R)\n", + "n = L/(q*miu_n*A*R)# cm**-3\n", + "# The percentage doping efficiency \n", + "doping = (n/Nd)*100## % doping efficiency in %\n", + "print \"The percentage doping efficiency = %.2f %%\"%doping" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.26 Page No 66" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current through the diode under forward bias = 10.72 µA\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "Io = 2*10**-7# A\n", + "V = 0.1# V\n", + "# Current through the diode under forward bias,\n", + "I = Io*( (math.exp(40*V))-1 )# A\n", + "I = I * 10**6# µA\n", + "print \"The current through the diode under forward bias = %.2f µA\"%I\n", + "\n", + "# Note: Calculated value of I in the book is wrong." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.28 Page No 67" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The dynamic resistance in forward direction = 3.36 ohm\n", + "The dynamic resistance in reverse direction = 0.39 Mohm\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "T = 125.0# degree C\n", + "T = T + 273.0# K\n", + "V_T = T/11600.0\n", + "Io = 30# µA\n", + "Io = Io * 10**-6# A\n", + "V = 0.2# V\n", + "# The dynamic resistance = %.2f forward direction,\n", + "r_f = V_T/( Io * (math.exp(V/V_T)) )# ohm\n", + "print \"The dynamic resistance in forward direction = %.2f ohm\"%r_f\n", + "r_f = V_T/( Io * (math.exp(-V/V_T)) )# ohm\n", + "# The dynamic resistance = %.2f reverse direction \n", + "r_f = r_f * 10**-6# Mohm\n", + "print \"The dynamic resistance in reverse direction = %.2f Mohm\"%r_f" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.29 Page No 68" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage = -59.87 mV\n", + "The ratio of diode current with a forward bias to current with a reverse bias = -6.842\n", + "The value of I1 = 458.13 µA\n", + "The value of I2 = 21.90 mA\n", + "The value of I3 = 1.03 A\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "Eta = 1\n", + "V_T = 0.026\n", + "# I = Io*( (exp(V/(Eta*V_T))) - 1 ) and I = -Io\n", + "# I = -0.9*Io\n", + "# -0.9*Io = Io*( (exp(V/(Eta*V_T))) - 1 )\n", + "V = Eta*V_T*math.log(0.1)# V\n", + "V = V * 10**3# mV\n", + "print \"The voltage = %.2f mV\"%V\n", + "V = 0.05# V\n", + "# The ratio of diode current with a forward bias to current with a reverse bias \n", + "If_by_Ir= ( (math.exp(V/V_T))-1 )/( (math.exp(-V/V_T))-1 )\n", + "print \"The ratio of diode current with a forward bias to current with a reverse bias = %.3f\"%If_by_Ir\n", + "Io = 10# µA\n", + "V = 0.1# V\n", + "# The value of I1 \n", + "I1 = Io*( (math.exp(V/V_T))-1 )# µA\n", + "print \"The value of I1 = %.2f µA\"%I1\n", + "V = 0.2# V\n", + "# The value of I2\n", + "I2 = Io*( (math.exp(V/V_T))-1 )# µA \n", + "I2 = I2 * 10**-3# mA\n", + "print \"The value of I2 = %.2f mA\"%I2\n", + "V = 0.3# V\n", + "# The value of I3\n", + "I3 = Io*( (math.exp(V/V_T))-1 )# µA\n", + "I3 = I3 * 10**-6# A\n", + "print \"The value of I3 = %.2f A\"%I3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.30 Page No 69" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The factor by which current will get multiplied = 638.025\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "# Io150 = Io25 * 2**((150-25)/10)\n", + "#Io150 = 5800*Io25\n", + "T = 150# degree C\n", + "T = T + 273# K\n", + "V_T = 8.62*10**-5 * T# V\n", + "V = 0.4# V\n", + "Eta = 2\n", + "Vt = 0.026# V \n", + "# The factor by which current will get multiplied \n", + "I150byI25= 5800*math.exp(V/(Eta*V_T))/math.exp(V/(Eta*Vt))\n", + "print \"The factor by which current will get multiplied = %.3f\"%I150byI25" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.31 Page No 69" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The operating point of the diode is : (0.50V,4.50mA)\n" + ] + } + ], + "source": [ + "# Given data\n", + "R = 1# ohm\n", + "V = 5# V\n", + "V1 = 0.5# V\n", + "R1 = 1# k ohm\n", + "R1 = R1 * 10**3# ohm\n", + "# V-(I_D*R1)-(I_D*R) - V1 = 0\n", + "I_D = (V-V1)/(R1+R)# A\n", + "I_D = I_D * 10**3# mA\n", + "V_D = (I_D*10**-3*R) + V1# V\n", + "print \"The operating point of the diode is : (%.2fV,%.2fmA)\"%(V_D,I_D)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.32 Page No 70" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage drop across the forward biased diode, = 0.0180 V\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "Eta = 1\n", + "kT = 26# meV\n", + "# (%e**((e*V1)/kT)) = 2 or\n", + "#The voltage drop across the forward biased diode\n", + "V1 = math.log(2)*kT# mV\n", + "V1= V1*10**-3# V\n", + "print \"The voltage drop across the forward biased diode, = %.4f V\"%V1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.33 Page No 71" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The space charge capacitance = 70.74 pF\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "epsilon_Ge = 16/(36*math.pi*10**11)# F/cm\n", + "d = 2*10**-4# cm\n", + "A = 1# mm**2\n", + "A = A * 10**-2# cm**2\n", + "epsilon_o = epsilon_Ge# F/cm\n", + "# The space charge capacitance \n", + "C_T = (epsilon_o*A)/d# F\n", + "C_T = C_T * 10**12# pF\n", + "print \"The space charge capacitance = %.2f pF\"%C_T" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.34 Page No 71" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of C_T = 61.68 pf/cm**2\n" + ] + } + ], + "source": [ + "import math \n", + "# Given data\n", + "D = 0.102# cm \n", + "A = (math.pi*(D**2))/4# cm**2\n", + "sigma_p = 0.286# (ohm-cm)**-1\n", + "q = 1.6*10**-19# C\n", + "miu_p = 500\n", + "# Formula used, sigma_p = q*miu_p*N_A\n", + "N_A = sigma_p/(q*miu_p)# atoms/cm**3\n", + "V1 = 5# V\n", + "V2 = 0.35# V\n", + "Vb = V1+V2# V\n", + "# The transition capacitance,\n", + "C_T = 2.92*10**-4*((N_A/Vb)**(1./2))*A# pF/cm**2\n", + "print \"The value of C_T = %.2f pf/cm**2\"%C_T" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.35 Page No 71" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of C_T for reverse bias = 15.00 pF\n" + ] + } + ], + "source": [ + "# Given data\n", + "C_T1 = 15# pF\n", + "Vb1 = 8# V\n", + "Vb2 = 12# V\n", + "# C_T1/C_T2 = (Vb2/Vb1)**(1/2)\n", + "C_T2 = C_T1 * ((Vb1/Vb2)**(1/2))# pF\n", + "print \"The value of C_T for reverse bias = %.2f pF\"%C_T2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.36 Page No 72" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage = -59.87 mV\n" + ] + } + ], + "source": [ + "import math\n", + "# Given data\n", + "V_T = 0.026# V\n", + "Eta = 1\n", + "I = '-0.9*Io'\n", + "# T = Io*((%e**(V/(Eta*V_T)))-1 )\n", + "# I = Io*((%e**(V/(Eta*V_T)))-1 )\n", + "V = math.log(0.1)*V_T# V \n", + "V = V * 10**3# mV\n", + "print \"The voltage = %.2f mV\"%V" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.37 Page No 72" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Part (a) : The value of I_D for first circuit = 0.97 mA\n", + "Part (b) : The value of I_D for second circuit = 0.10 mA\n" + ] + } + ], + "source": [ + "# Given data\n", + "Vin = 20# V\n", + "Vgamma = 0.7# V\n", + "R = 20# k ohm\n", + "R = R * 10**3# ohm\n", + "# Vin-(I_D*Vin) - Vgamma = 0 or\n", + "# The value of I_D,\n", + "I_D = (Vin-Vgamma)/R# A\n", + "I_D = I_D * 10**3# mA\n", + "print \"Part (a) : The value of I_D for first circuit = %.2f mA\"%I_D\n", + "\n", + "# Part (b)\n", + "Vin= 10.# V\n", + "Vgamma = 0.7# V\n", + "R = 100# k ohm\n", + "# Drain current,\n", + "I_D= Vin/R# mV\n", + "print \"Part (b) : The value of I_D for second circuit = %.2f mA\"%I_D" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.38 Page No 73" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of I_D = 3.10 mA\n", + "The value of Vo = 6.90 V\n" + ] + } + ], + "source": [ + "# Given data\n", + "R1 = 1# k ohm\n", + "R1 = R1 * 10**3# ohm\n", + "R2 = 2# k ohm\n", + "R2 = R2 * 10**3# ohm\n", + "V = 10# V\n", + "V1 = 0.7# V \n", + "# V * (I_D*R1) - (R2*I_D) - V1 = 0\n", + "I_D = (V-V1)/(R1+R2)# A\n", + "I_D = I_D * 10**3# mA\n", + "print \"The value of I_D = %.2f mA\"%I_D\n", + "# The output voltage,\n", + "Vo = (I_D*10**-3 * R2) +V1# V\n", + "print \"The value of Vo = %.2f V\"%Vo" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.39 Page No 73" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Part (a): The current through resistance = 1.00 A\n", + "Part (b) : Current through 10 ohm resistance will be Zero\n", + "Part (c): Current will be zero\n", + "Part (d): The diode will be ON and current = 1.00 A\n" + ] + } + ], + "source": [ + "# Given data\n", + "V = 10.# V\n", + "R = 10# ohm\n", + "# Current through resistance,\n", + "I = V/R# A\n", + "print \"Part (a): The current through resistance = %.2f A\"%I\n", + "print \"Part (b) : Current through 10 ohm resistance will be Zero\"\n", + "print \"Part (c): Current will be zero\"\n", + "print \"Part (d): The diode will be ON and current = %.2f A\"%I" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.40 Page No 74" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The operating point is : (0.50V,4.50mA)\n" + ] + } + ], + "source": [ + "# Given data\n", + "Vth= 0.5# V\n", + "R_F= 1*10**3# ohm\n", + "V= 5# V\n", + "# Applying KVL for loop, V-Vd-R_F*Ii= 0 (i)\n", + "# When Ii=0\n", + "Vd= V# V\n", + "# When Vd= 0\n", + "Ii= V/R_F# A\n", + "# From eq(i)\n", + "Ii= (V-Vth)/R_F# A\n", + "Vd= V-R_F*Ii# V\n", + "print \"The operating point is : (%.2fV,%.2fmA)\"%(Vd,Ii*1000)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.43 Page No 76" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage at V1 = 6.00 volts\n", + "The voltage at V2 = 5.40 volts\n" + ] + } + ], + "source": [ + "# Given data\n", + "V_CC = 6# V\n", + "Vr = 0.6# V\n", + "V1= V_CC##in V\n", + "V2 = V1-Vr# V\n", + "print \"The voltage at V1 = %.2f volts\"%V1\n", + "print \"The voltage at V2 = %.2f volts\"%V2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.44 Page No 76" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of I1 = 1.80 mA\n", + "The value of I2 = 1.80 mA\n" + ] + } + ], + "source": [ + "# Given data\n", + "V_T = 0.7# V\n", + "V = 5# V\n", + "R = 2# k ohm\n", + "R = R * 10**3# ohm\n", + "Vs = 0.7\n", + "Vx = Vs+V_T# V\n", + "# The value of I1 \n", + "I1 = (V-Vx)/R# A\n", + "I1 = I1 * 10**3# mA\n", + "print \"The value of I1 = %.2f mA\"%I1\n", + "# The value of I2 \n", + "I2 = I1# mA\n", + "print \"The value of I2 = %.2f mA\"%I2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 1.45 Page No 77" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of Vo = 1.00 V\n" + ] + } + ], + "source": [ + "# Given data\n", + "Rf = 300.# ohm\n", + "V = 0.5# V\n", + "R = 600.# ohm\n", + "Vi = 2.# V\n", + "# The output voltage \n", + "Vo = (Vi-V)*( R/(R+Rf) )# V\n", + "print \"The value of Vo = %.2f V\"%Vo" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter2.ipynb b/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter2.ipynb new file mode 100755 index 00000000..3d7aab33 --- /dev/null +++ b/sample_notebooks/PraveenKumar/PraveenKumar_version_backup/chapter2.ipynb @@ -0,0 +1,429 @@ +{ + "metadata": { + "name": "", + "signature": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "chapter-2, Economics of generation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex1, Page 73" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "#To Determine the Demand and Supply Parameters for 15 bulbs\n", + "\n", + "W=60 #Wattage of the bulb\n", + "N=15 #No. of bulbs\n", + "CL=W*N #Connected Load \n", + "Wih=2*(10**3) #Wattage of immersion heater\n", + "Wh=2*(10**3) #Wattage of heater\n", + "\n", + "#Usage of Bulbs at different time periods\n", + "N1=5 \n", + "N2=10 \n", + "N3=6\n", + "\n", + "#Time periods for bulbs\n", + "T1=2 #6pm - 8pm\n", + "T2=2 #8pm - 10pm\n", + "T3=2 #10pm - 12pm\n", + "#Time Periods for heaters\n", + "T4=4 #1pm - 5pm\n", + "T5=3 #8pm - 11pm\n", + "\n", + "#CASE 1\n", + "MD1=W*N2 #Maximum Demand\n", + "DF=MD1*100/CL #Demand Factor\n", + "EC1=(N1*W*T1)+(N2*W*T2)+(N3*W*T3) #Energy Consumed\n", + "DLF1=EC1*100/(24*MD1) #Daily Load Factor\n", + "\n", + "#CASE 2\n", + "MD2=(W*N2)+Wh #From 8pm - 10pm\n", + "EC2=(T4*Wih)+(T5*Wh)+EC1 #Energy Consumed\n", + "DLF2=EC2*100/(24*MD2) #Daily Load Factor\n", + "\n", + "print '''i)a) Connected Load is %0.2f W\\nb) The Maximum Demand is %0.2f W\n", + "c) The Demand Factor is %0.2f percent\\nd) The Daily Load Factor is %0.2f percent''' %(CL,MD1,DF,DLF1)\n", + "print 'ii) The Improved Daily Load Factor is %0.2f percent' %DLF2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i)a) Connected Load is 900.00 W\n", + "b) The Maximum Demand is 600.00 W\n", + "c) The Demand Factor is 66.67 percent\n", + "d) The Daily Load Factor is 17.50 percent\n", + "ii) The Improved Daily Load Factor is 26.47 percent\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex2, Page 74" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "\n", + "#To determine the Demand and supply parameter of four consumers\n", + "\n", + "\n", + "#Maximum Demands of various users\n", + "MD1=2*(10**3) #9pm\n", + "MD2=2*(10**3) #12 noon\n", + "MD3=8*(10**3) #5pm\n", + "MD4=4*(10**3) #8pm\n", + "MDT=MD1+MD2+MD3+MD4 #Sum of all Maximum Demands\n", + "\n", + "#Demands of various users\n", + "D1=1.6*(10**3) #8pm\n", + "D2=1*(10**3) #8pm\n", + "D3=5*(10**3) #8pm\n", + "\n", + "#The Number after the Alphabets represents the Consumer\n", + "\n", + "#Maximum Demand of the System arises at 8.00 PM\n", + "MDS = D1+D2+D3+MD4 \n", + "\n", + "TDF=MDT/MDS #Diversity Factor\n", + "#Given Values\n", + "#Average Loads\n", + "AL2=500 \n", + "AL4=1000 \n", + "#Load Factors\n", + "LF1=15/100 \n", + "LF3=25/100 \n", + "#Calculated Values\n", + "#Average Loads\n", + "AL1=LF1*MD1 \n", + "AL3=LF3*MD3 \n", + "#Load Factors\n", + "LF2=AL2*100/MD2 \n", + "LF4=AL4*100/MD4 \n", + "\n", + "ALS=AL1+AL2+AL3+AL4 #Combined Average Loads\n", + "LFS=ALS*100/MDS #Combined Load Factor\n", + "\n", + "#Load Percent\n", + "LF1*=100 # %\n", + "LF3*=100 # %\n", + "\n", + "print 'i) The Diversity Factor is %0.2f' %TDF\n", + "print 'ii) The Average load and Load factor of:'\n", + "print ' Consumer 1 : %0.2f W and %0.2f percent' %(AL1,LF1)\n", + "print ' Consumer 2 : %0.2f W and %0.2f percent' %(AL2,LF2)\n", + "print ' Consumer 3 : %0.2f W and %0.2f percent' %(AL3,LF3)\n", + "print ' Consumer 4 : %0.2f W and %0.2f percent' %(AL4,LF4)\n", + "print 'iii) The Combined Load Factor and the Combined Average Load is %0.2f percent and %0.2f W respectively\\n' %(LFS,ALS)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "i) The Diversity Factor is 1.38\n", + "ii) The Average load and Load factor of:\n", + " Consumer 1 : 300.00 W and 15.00 percent\n", + " Consumer 2 : 500.00 W and 25.00 percent\n", + " Consumer 3 : 2000.00 W and 25.00 percent\n", + " Consumer 4 : 1000.00 W and 25.00 percent\n", + "iii) The Combined Load Factor and the Combined Average Load is 32.76 percent and 3800.00 W respectively\n", + "\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex3, Page 75" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "\n", + "#To Determine the Yearly Cost of the substation\n", + "\n", + "Teff=95/100 #Transmission Efficiency\n", + "Deff=85/100 #Distribution Efficiency\n", + "DFT=1.2 #Diversity Factor For Transmission\n", + "DFD=1.3 #Diversity Factor For Distribution\n", + "MDGS=100*(10**6) #Maximum Demand of Generating Station\n", + "ALF=40/100 #Annual Load Factor\n", + "ACCT=2.5*(10**6) #Annual Capital Charge for Transmission\n", + "ACCD=2*(10**6) #Annual Capital Charge for Distribution\n", + "GCC=100 #Generating Cost per kW demand\n", + "GCCU=5/100 # Per Unit Cost\n", + "#Fixed Charges from Supply to Substation Annually\n", + "GFC=GCC*MDGS/1000 #Generating\n", + "TFC=ACCT #Transmission\n", + "TotFCS=GFC+TFC #Total\n", + "#Fixed Charges for supply upto Consumer Annually\n", + "DFC=ACCD #Distribution\n", + "TotFCC=TotFCS+DFC #Total\n", + "\n", + "AMDS= DFT*MDGS/1000 #Aggregate of Maximum Demand at Supply\n", + "AMDC= DFD*AMDS #Aggregate of Maximum Demand for Consumers\n", + "\n", + "FCS=TotFCS/AMDS #Fixed Charges Per KW at substation\n", + "CES=GCCU/Teff #Cost of energy at the substation\n", + "\n", + "FCC=TotFCC/AMDC #Fixed Charges per KW at the consumer premises\n", + "CEC=CES/Deff #Cost of Energy at the consumer premises\n", + "\n", + "CEC*=100 # converting from rupee to paise\n", + "\n", + "print 'The Yealy Cost per KW demand and the cost per KWhr at:'\n", + "print 'a) The substation is %0.2f rupees per KW and %0.2f paise per kWhr'%(FCS,CES)\n", + "print 'b) The consumer premises is %g rupees per KW and %g paise per kWhr' %(FCC,CEC)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Yealy Cost per KW demand and the cost per KWhr at:\n", + "a) The substation is 104.17 rupees per KW and 0.05 paise per kWhr\n", + "b) The consumer premises is 92.9487 rupees per KW and 6.19195 paise per kWhr\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex4, Page 78" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To determine the Load factor and suitable units for 24 hr operation of the plant\n", + "\n", + "\n", + "#Demands at Various Time Periods starting from 12PM to 12PM\n", + "D1=500*(10**3) \n", + "D2=800*(10**3) \n", + "D3=2000*(10**3) \n", + "D4=1000*(10**3) \n", + "D5=2500*(10**3) \n", + "D6=2000*(10**3) \n", + "D7=1500*(10**3) \n", + "D8=1000*(10**3) \n", + "\n", + "MD=D5 #Maximum Demand\n", + "#Time Periods of demands from 12PM\n", + "T1=5 \n", + "T2=5 \n", + "T3=2 \n", + "T4=2 \n", + "T5=3 \n", + "T6=3 \n", + "T7=2 \n", + "T8=2 \n", + "\n", + "#Total Energy Demand in 24hrs\n", + "TED=(T1*D1)+(T2*D2)+(T3*D3)+(D4*T4)+(T5*D5)+(D6*T6)+(D7*T7)+(T8*D8) \n", + "\n", + "LF=TED*100/(24*MD) \n", + "\n", + "C1000=3*1000*(10**3) #1000 unit \n", + "C500=1*500*(10**3) #500 Unit\n", + "\n", + "TCP=C1000+C500 #Total capacity of the plant\n", + "PCF=TED*100/(24*TCP) #Plant Capacity Factor\n", + "\n", + "#Operating Schedule, Units operated can be seen in the textbook\n", + "G1=500*(10**3) \n", + "G2=1000*(10**3) \n", + "G3=2000*(10**3) \n", + "G4=1000*(10**3) \n", + "G5=2500*(10**3) \n", + "G6=2000*(10**3) \n", + "G7=1500*(10**3) \n", + "G8=1000*(10**3) \n", + "\n", + "TEG=(T1*G1)+(T2*G2)+(T3*G3)+(G4*T4)+(T5*G5)+(G6*T6)+(G7*T7)+(T8*G8) #Total Energy Generated\n", + "PUF=TED*100/(TEG) #Plant Use Factor\n", + "\n", + "print 'a) The Reserve Capacity is a 1000kW Unit and Load Factor is %0.2f percent' %LF\n", + "print 'b) The Plant Capacity Factor is %0.2f percent' %PCF\n", + "print 'c) The Plant Use Factor is %0.2f percent' %PUF" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "a) The Reserve Capacity is a 1000kW Unit and Load Factor is 51.67 percent\n", + "b) The Plant Capacity Factor is 36.90 percent\n", + "c) The Plant Use Factor is 96.88 percent\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex5, Page 80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To determine the Plant use factore of each unit\n", + "\n", + "\n", + "MDS=25*(10**6) #Maximum Demand on the System\n", + "U1=15*(10**6) #Load Supplied By Unit 1\n", + "U2=12.5*(10**6) #Load Supplied By Unit 2\n", + "#Running Time Factor of the Unit\n", + "T1=1 \n", + "T2=40/100 \n", + "\n", + "#Energy generated by each unit\n", + "E1=1*(10**8) \n", + "E2=1*(10**7) \n", + "Et=E1+E2 #Total Energy\n", + "\n", + "#Maximum Demands on Each Units\n", + "MD1=U1 \n", + "MD2=MDS-U1 \n", + "\n", + "#Annual Load Factor for the Units\n", + "ALF1=E1*1000*100/(MD1*8760) \n", + "ALF2=E2*1000*100/(MD2*8760) \n", + "\n", + "LF2=E2*1000*100/(MD2*0.4*8760) #Load Factor for the it is loaded\n", + "\n", + "\n", + "PUF1=ALF1 #Plant Use Factor\n", + "PCF1=ALF1 # Plant Capacity Factor\n", + "\n", + "PCF2=E2*1000*100/(U2*8760) #Plant Capacity Factor for Unit 2\n", + "PUF2=E2*1000*100/(U2*0.4*8760) #Plant Use Factor for Unit 2\n", + "\n", + "LFP=Et*100*1000/(MDS*8760) #Annual Load Factor of the Complete Plant\n", + "\n", + "print 'The Load Factor, Plant Capacity Factor, Plant Use Factor of:'\n", + "print 'Unit 1 : %0.2f percent, %0.2f percent, %0.2f percent' %(ALF1,PCF1,PUF1)\n", + "print 'Unit 2 : %0.2f percent, %0.2f percent, %0.2f percent' %(ALF2,PCF2,PUF2)\n", + "print 'The Annual Load Factor of the Entire Plant is %0.2f percent' %LFP" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Load Factor, Plant Capacity Factor, Plant Use Factor of:\n", + "Unit 1 : 76.10 percent, 76.10 percent, 76.10 percent\n", + "Unit 2 : 11.42 percent, 9.13 percent, 22.83 percent\n", + "The Annual Load Factor of the Entire Plant is 50.23 percent\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex6, Page 91" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#To determine the most economic power factor\n", + "\n", + "from numpy import sqrt\n", + "\n", + "P=200*(10**3) #Maximum Demand\n", + "pf=0.707 #Power Factor Lagging\n", + "\n", + "a=100 #Tariff per kVA per year\n", + "\n", + "b=200 #Power factor improvement cost Per kVA.\n", + "r=20 #Interest Depriciation, maintenance and cost of losses amount to 20% of capital cost per year\n", + "\n", + "# Economic PF = sqrt(1-((b1/a)**2))\n", + "\n", + "b1=r*b/100 # b' term accrding to the equation above\n", + "\n", + "pfeco=sqrt(1-((b1/a)**2)) #Economic Power Factor\n", + "\n", + "print 'The Economic Power Factor is %0.2f ' %pfeco\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Economic Power Factor is 0.92 \n" + ] + } + ], + "prompt_number": 22 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/PraveenKumar/chapter1.ipynb b/sample_notebooks/PraveenKumar/chapter1.ipynb deleted file mode 100755 index 0d151d06..00000000 --- a/sample_notebooks/PraveenKumar/chapter1.ipynb +++ /dev/null @@ -1,1600 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 - Semiconductor Material & Junction Diode" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.1 Page No 51" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The electron drift velocity = 40.00 m/s\n", - "The time required for an electron to move across the thickness = 12.50 micro seconds\n" - ] - } - ], - "source": [ - "# Given data\n", - "miu = 0.2# m**2/V-s\n", - "V = 100# mV\n", - "V = V * 10**-3# V\n", - "d = 0.5# mm\n", - "d = d * 10**-3# m\n", - "# mobility, miu = Vd/E and\n", - "E = V/d\n", - "# Drift velocity,\n", - "Vd = miu*E# m/s\n", - "print \"The electron drift velocity = %.2f m/s\"%Vd\n", - "# Time required,\n", - "T = d/Vd# sec\n", - "T=T*10**6# µs\n", - "print \"The time required for an electron to move across the thickness = %.2f micro seconds\"%T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.2 Page No 52" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The intrinsic conductivity = 2.24 (ohm-m)**-1\n" - ] - } - ], - "source": [ - "# Given data\n", - "q = 1.6*10**-19# C\n", - "n_i = 2.5*10**19# /m**3\n", - "miu_n = 0.38# m**2/V-s\n", - "miu_p = 0.18# m**2/V-s\n", - "# The intrinsic conductivity for germanium,\n", - "sigma_i = q*n_i*(miu_n+miu_p)# (ohm-m)**-1\n", - "print \"The intrinsic conductivity = %.2f (ohm-m)**-1\"%sigma_i" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.3 Page No 52" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The intrinsic carrier concentration = 2.16e+19 per m**3\n" - ] - } - ], - "source": [ - "# Given data\n", - "rho = 0.50# ohm-m\n", - "q = 1.6*10**-19# C\n", - "miu_n = 0.39# m**2/V-s\n", - "miu_p = 0.19# m**2/V-s\n", - "sigma = 1/rho# (ohm-m)**-1\n", - "#conductivity of a semiconductor, sigma = q*n_i*(miu_p+miu_n) or\n", - "n_i = sigma/(q*(miu_n+miu_p))# /m**3\n", - "print \"The intrinsic carrier concentration = %.2e per m**3\"%n_i" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.4 Page No 52" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The conductivity of Si sample = 14.40 (ohm-m)**-1\n" - ] - } - ], - "source": [ - "# Given data\n", - "N_D = 10**21# /m**3\n", - "N_A = 5*10**20# /m**3\n", - "NdasD = N_D-N_A# /m**3\n", - "n = NdasD# /m**3\n", - "miu_n = 0.18# m**2/V-s\n", - "q = 1.6*10**-19# C\n", - "# The conductivity of silicon,\n", - "sigma = q*n*miu_n# (ohm-m)**-1\n", - "print \"The conductivity of Si sample = %.2f (ohm-m)**-1\"%sigma" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.5 Page No 53" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The conductivity of copper = 4.79e+05 mho/cm\n" - ] - } - ], - "source": [ - "# Given data\n", - "At = 63.54## atomic weight of copper\n", - "d = 8.9## density = %.2f gm/cm**3\n", - "n = 6.023*10**23/At*d# electron/cm**3\n", - "q = 1.63*10**-19# C\n", - "miu = 34.8# m**2/V-s\n", - "# The conductivity of copper,\n", - "sigma = n*q*miu# mho/cm\n", - "print \"The conductivity of copper = %.2e mho/cm\"%sigma" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.6 Page No 53" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Concentration of holes in a p-type Ge = 3.47e+17 /cm**3\n", - "The concentration of electrons in a p-type Ge = 1.80e+09 /cm**3\n", - "The concentration of electrons in n-type Si = 4.81e+14 /cm**3\n", - "The concentration of holes in n-type Si = 4.68e+05 /cm**3\n" - ] - } - ], - "source": [ - "# Given data\n", - "sigma = 100# (ohm-m)**-1\n", - "n_i = 2.5*10**13# /cm**3\n", - "miu_n = 3800# cm**2/V-s\n", - "miu_p = 1800# cm**2/V-s\n", - "q = 1.6*10**-19# C\n", - "# Conductivity of a p-type germanium, sigma = q*p*miu_p or\n", - "p = sigma/(q*miu_p)# /cm**3\n", - "print \"Concentration of holes in a p-type Ge = %.2e /cm**3\"%p\n", - "# The concentration of electrons = %.2f a p-type Ge\n", - "n = (n_i**2)/p# /cm**3\n", - "print \"The concentration of electrons in a p-type Ge = %.2e /cm**3\"%n\n", - "#Given for Si\n", - "sigma= 0.1# (ohm m)**-1\n", - "miu_n= 1300# cm**2/V-sec\n", - "n_i= 1.5*10**10# /cm**3\n", - "#sigma = q*n*miu_n\n", - "n = sigma/(q*miu_n)# /cm**3\n", - "print \"The concentration of electrons in n-type Si = %.2e /cm**3\"%n\n", - "# The concentration of holes = %.2f n-type Si\n", - "p = (n_i**2)/n# /cm**3\n", - "print \"The concentration of holes in n-type Si = %.2e /cm**3\"%p" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.7 Page No 54" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The resistivity of a dopped Ge = 3.72 ohm-cm\n" - ] - } - ], - "source": [ - "# Given data\n", - "miu_n = 3800## cm**2/V-s\n", - "miu_p = 1800## cm**2/V-s\n", - "n_i = 2.5*10**13# /cm**3\n", - "Nge = 4.41*10**22# /cm**3\n", - "q = 1.602*10**-19# C\n", - "impurity = 10**8\n", - "# The number of donor atoms,\n", - "N_D = Nge/impurity##in /cm**3\n", - "# The number of holes\n", - "p = (n_i**2)/N_D# /cm**3\n", - "# Conductivity of an N-type Ge,\n", - "sigma = q*N_D*miu_n# (ohm-cm)**-1\n", - "# The resistivity of the Ge\n", - "rho = 1/sigma# ohm-cm\n", - "print \"The resistivity of a dopped Ge = %.2f ohm-cm\"% rho" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.8 Page No 54" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The resistivity of intrinsic silicon = 2.25e+05 ohm-cm\n", - "The resistivity of doped silicon = 4.67 ohm-cm\n" - ] - } - ], - "source": [ - "# Given data\n", - "Nsi = 4.96*10**22# /cm**3\n", - "n_i = 1.52*10**10# /cm**2\n", - "q = 1.6*10**-19# C\n", - "miu_n = 0.135# m**2/V-s\n", - "miu_n = miu_n * 10**4# cm**2/V-s\n", - "miu_p = 0.048# m**2/V-s\n", - "miu_p = miu_p * 10**4# cm**2/V-s\n", - "# The conductivity of an intrinsic silicon,\n", - "sigma = q*n_i*(miu_n+miu_p)# (ohm-cm)**-1\n", - "# The resistivity of intrinsic silicon \n", - "rho = 1/sigma# ohm-cm\n", - "print \"The resistivity of intrinsic silicon = %.2e ohm-cm\"%rho\n", - "\n", - "impurity = 50*10**6\n", - "# The number of donor atoms,\n", - "N_D = Nsi/impurity# /cm**3\n", - "# Total free electrons,\n", - "n = N_D# /cm**3\n", - "# Total holes = %.2f a doped Si,\n", - "p = (n_i**2)/n# /cm**3\n", - "# Conductivity of a doped Si,\n", - "sigma = q*n*miu_n# (ohm-m)**-1\n", - "# The resistivity of doped silicon\n", - "rho = 1/sigma# ohm-cm\n", - "print \"The resistivity of doped silicon = %.2f ohm-cm\"%rho" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.9 Page No 55" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of temperature = 0.14 K\n" - ] - } - ], - "source": [ - "# Given data\n", - "N_D= 5.0*10**28/(2.0*10**8)\n", - "# The Fermi level, E_F= E_C if,\n", - "N_C= N_D\n", - "# Formula N_C= 4.82*10**21*T**(3/2)\n", - "T= (N_C/(4.82*10**21.0))**(2.0/3)# K\n", - "print \"The value of temperature = %.2f K\"%T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.10 Page No 55" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The miniority carrier concentration = 0.10 m**2/V-s\n", - "The resistivity = 0.60 ohm-m\n", - "The position of Fermi level = 0.23 eV\n", - "Minority carrier concentration = 9.00e+12 atoms/cm**3\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "n_i = 1.5*10**16##m**3\n", - "impurity = 10**20\n", - "minority = (n_i**2)/impurity# atoms/m**3\n", - "q = 1.6*10**-19# C\n", - "rho = 2*10**3# ohm-m\n", - "# The miniority carrier concentration \n", - "miu_n = 1/(q*rho*n_i*2)##in m**2/V-s\n", - "print \"The miniority carrier concentration = %.2f m**2/V-s\"%miu_n\n", - "n = impurity\n", - "# The conductivity,\n", - "sigma = q*impurity*miu_n# (ohm-m)**-1\n", - "# The resistivity \n", - "rho = 1/sigma# ohm-m\n", - "print \"The resistivity = %.2f ohm-m\"%rho\n", - "kT = 0.026# eV\n", - "n_o = n\n", - "# The position of Fermi level \n", - "E_FdividedEi = kT*math.log(n_o/n_i)# eV\n", - "print \"The position of Fermi level = %.2f eV\"%E_FdividedEi\n", - "# Minority carrier concentration \n", - "M = ((n_i*2)**2)/n_o# atoms/cm**3\n", - "print \"Minority carrier concentration = %.2e atoms/cm**3\"%M" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.11 Page No 56" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The resistivity = 9.62 ohm-cm\n" - ] - } - ], - "source": [ - "# Given data\n", - "d = 5.0*10**22# atoms/cm**3\n", - "impurity = 10**8# atoms\n", - "N_D = d/impurity\n", - "n_i = 1.45*10**10\n", - "n = N_D\n", - "#Low of mass action, n*p = (n_i**2)\n", - "p = (n_i**2)/n# /cm**3\n", - "q = 1.6*10**-19# C\n", - "miu_n = 1300# cm/V-s\n", - "n_i = n\n", - "#The Conductivity\n", - "sigma = q*miu_n*n_i# (ohm-cm)**-1\n", - "# The resistivity\n", - "rho = 1/sigma# ohm-cm\n", - "print \"The resistivity = %.2f ohm-cm\"%rho" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.12 Page No 57" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The resistivity = 9.62 ohm-cm\n" - ] - } - ], - "source": [ - "# Given data\n", - "d = 5.0*10**22# atoms/cm**3\n", - "impurity = 10**8# atoms\n", - "N_D = d/impurity\n", - "n_i = 1.45*10**10\n", - "n = N_D\n", - "#Low of mass action, n*p = (n_i**2)\n", - "p = (n_i**2)/n# /cm**3\n", - "q = 1.6*10**-19# C\n", - "miu_n = 1300# cm/V-s\n", - "n_i = n\n", - "#The Conductivity\n", - "sigma = q*miu_n*n_i# (ohm-cm)**-1\n", - "# The resistivity\n", - "rho = 1/sigma# ohm-cm\n", - "print \"The resistivity = %.2f ohm-cm\"%rho" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.14 Page No 58" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The minority carrier concentration = 2.25e+03 holes/cm**3\n", - "The location of Fermi level = 0.409 eV\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "n_i = 1.5*10**10# electrons/cm**3\n", - "N_D = 10**17# electrons/cm**3\n", - "n = N_D# electrons/cm**3\n", - "# The minority carrier concentration\n", - "p = (n_i**2)/n# holes/cm**3\n", - "print \"The minority carrier concentration = %.2e holes/cm**3\"%p\n", - "kT = 0.026\n", - "# The location of Fermi level \n", - "E_FminusEi = kT*math.log(N_D/n_i)# eV\n", - "print \"The location of Fermi level = %.3f eV\"%E_FminusEi" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.15 Page No 59" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The doping level = 1.92e+15 /cm**3\n", - "The drift velocity = 650.00 cm/sec\n" - ] - } - ], - "source": [ - "# Given data\n", - "V = 1# V\n", - "I = 8# mA\n", - "I = I * 10**-3# A\n", - "R = V/I# ohm\n", - "l = 2# mm\n", - "l = l * 10**-1# cm\n", - "b = 2# mm\n", - "b = b * 10**-1# cm\n", - "A = l*b# cm**2\n", - "L = 2# cm\n", - "# R = (rho*L)/A\n", - "sigma = L/(R*A)# (ohm-cm)**-1\n", - "# n = N_D\n", - "miu_n = 1300# cm**2/V-s\n", - "q = 1.6 * 10**-19# C\n", - "# sigma = n*q*miu_n\n", - "N_D = sigma/( miu_n*q )# /cm**3\n", - "print \"The doping level = %.2e /cm**3\"%N_D\n", - "d = 2.0\n", - "E = V/d\n", - "# The drift velocity \n", - "Vd = miu_n * E# cm/s\n", - "print \"The drift velocity = %.2f cm/sec\"%Vd" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.17 Page No 60" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The conductivity = 4.68e+05 mho/m\n", - "The mobility = 3.48e-05 m**2/V-s\n", - "The drift velocity = 1.79e-04 m/s\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "l = 1000# ft\n", - "l = l * 12*2.54# cm\n", - "R = 6.51# ohm\n", - "rho = R/l# ohm/cm\n", - "# The conductivity \n", - "sigma = 1/rho# mho/cm\n", - "sigma = sigma * 10**2# mho/m\n", - "D= 1.03*10**-3# m\n", - "A= math.pi*D**2/4# m**2\n", - "print \"The conductivity = %.2e mho/m\"%sigma\n", - "q = 1.6*10**-19# C\n", - "n = 8.4*10**28# electrons/m**3\n", - "# sigma = n*q*miu\n", - "miu = sigma/(n*q)# m**2/V-s\n", - "print \"The mobility = %.2e m**2/V-s\"%miu\n", - "T = 2\n", - "# The drift velocity \n", - "V = T/(n*q*A)# m/s\n", - "print \"The drift velocity = %.2e m/s\"%V" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.18 Page No 61" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The concentration of holes = 1.50e+16 /cm**3\n", - "The concentartion of electrons = 6.67e+07 /cm**3\n" - ] - } - ], - "source": [ - "# Given data\n", - "N_D = 2*10**16# /cm**3\n", - "N_A = 5*10**15# /cm**3\n", - "# The concentration of holes \n", - "Pp = N_D-N_A# /cm**3\n", - "print \"The concentration of holes = %.2e /cm**3\"%Pp\n", - "n_i = 10**12\n", - "# The concentartion of electrons \n", - "n_p = (n_i**2)/Pp# /cm**3\n", - "print \"The concentartion of electrons = %.2e /cm**3\"%n_p" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.19 Page No 62" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The hall angle = 1.95 degree\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "rho = 0.005# ohm-m\n", - "Bz = 0.48# Wb/m**2\n", - "R_H = 3.55*10**-4# m**3/C\n", - "ExByJx= rho\n", - "# R_H = Ey/(Bz*Jx)\n", - "EyByJx= R_H*Bz\n", - "# The hall angle \n", - "theta_H = math.degrees(math.atan(EyByJx/ExByJx))# °\n", - "print \"The hall angle = %.2f degree\"%theta_H" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.20 Page No 63" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage between contacts = 0.0026 V\n" - ] - } - ], - "source": [ - "# Given data\n", - "R_H = 3.55 * 10**-4# m**3/C\n", - "Ix = 15# mA\n", - "Ix = Ix * 10**-3# A\n", - "A = 15*1# mm\n", - "A = A * 10**-6# m**2\n", - "Bz = 0.48# Wb/m**2\n", - "Jx = Ix/A# A/m**2\n", - "# R_H = Ey/(Bz*Jx)\n", - "Ey = R_H*Bz*Jx# V/m\n", - "# voltage between contacts \n", - "Voltage = Ey*Ix# V\n", - "print \"The voltage between contacts = %.4f V\"%Voltage" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.21 Page No 63" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The concentration of donor atoms = 4.630e+13 cm**-3\n" - ] - } - ], - "source": [ - "# Given data\n", - "A = 0.001# cm**2\n", - "l = 20# µm\n", - "l = l * 10**-4# cm\n", - "V = 20# V\n", - "I = 100# mA\n", - "I = I * 10**-3# A\n", - "R = V/I# ohm\n", - "# R = l/(sigma*A)\n", - "sigma = l/(R*A)# (ohm-cm)**-1\n", - "miu_n = 1350# cm**2/V-s\n", - "q = 1.6*10**-19# C\n", - "# sigma = n*q*miu_n or\n", - "# The concentration of donor atoms \n", - "n = sigma/(q*miu_n)# cm**-3\n", - "print \"The concentration of donor atoms = %.3e cm**-3\"%n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.22 Page No 64" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The doping needed = 8.681e+15 cm**-3\n" - ] - } - ], - "source": [ - "# Given data\n", - "R = 2# k ohm\n", - "R = R * 10**3# ohm\n", - "L = 200# µm\n", - "L = L * 10**-4# cm\n", - "A = 10**-6# cm**2\n", - "miu_n = 8000# cm**2/V-s\n", - "q = 1.6*10**-19# C\n", - "n = '0.9*N_D'\n", - "# R = (rho*l)/A= (1/(n*q*miu_n))*(l/A)\n", - "# rho = L/(R*q*miu_n*A)\n", - "n = L/(R*q*miu_n*A)# /cm**-3\n", - "# The doping needed \n", - "Nd= n/0.9\n", - "print \"The doping needed = %.3e cm**-3\"%Nd" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.23 Page No 65" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The position of the Fermi level = 0.29 eV\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "KT = 26*10**-3\n", - "Nd = 10**15\n", - "n_i = 1.5*10**10\n", - "# The position of the Fermi level \n", - "E_FminusE_Fi = KT*math.log(abs( Nd/n_i ))# eV\n", - "print \"The position of the Fermi level = %.2f eV\"%E_FminusE_Fi" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.24 Page No 65" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The concentration of donors atoms = 1.2176e+16 cm**-3\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "Na = 5 * 10**15# cm**-3\n", - "Nc = 2.8 * 10**19# cm**-3\n", - "E_CminusE_F = 0.215# eV\n", - "KT = 26* 10**-3# eV\n", - "# The concentration of donors atoms \n", - "Nd = Na + Nc * (math.exp( -E_CminusE_F/KT ))# cm**-3\n", - "print \"The concentration of donors atoms = %.4e cm**-3\"%Nd" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.25 Page No 65" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The percentage doping efficiency = 78.12 %\n" - ] - } - ], - "source": [ - "# Given data\n", - "Nd = 10**18\n", - "R = 10# ohm\n", - "A =10**-6# cm**2\n", - "L = 10# mm\n", - "L = L * 10**-4# cm\n", - "miu_n = 800# cm**2/V-s\n", - "q = 1.6*10**-19# C\n", - "#Formula used, n = L/(q*miu_n*A*R)\n", - "n = L/(q*miu_n*A*R)# cm**-3\n", - "# The percentage doping efficiency \n", - "doping = (n/Nd)*100## % doping efficiency in %\n", - "print \"The percentage doping efficiency = %.2f %%\"%doping" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.26 Page No 66" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The current through the diode under forward bias = 10.72 µA\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "Io = 2*10**-7# A\n", - "V = 0.1# V\n", - "# Current through the diode under forward bias,\n", - "I = Io*( (math.exp(40*V))-1 )# A\n", - "I = I * 10**6# µA\n", - "print \"The current through the diode under forward bias = %.2f µA\"%I\n", - "\n", - "# Note: Calculated value of I in the book is wrong." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.28 Page No 67" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The dynamic resistance in forward direction = 3.36 ohm\n", - "The dynamic resistance in reverse direction = 0.39 Mohm\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "T = 125.0# degree C\n", - "T = T + 273.0# K\n", - "V_T = T/11600.0\n", - "Io = 30# µA\n", - "Io = Io * 10**-6# A\n", - "V = 0.2# V\n", - "# The dynamic resistance = %.2f forward direction,\n", - "r_f = V_T/( Io * (math.exp(V/V_T)) )# ohm\n", - "print \"The dynamic resistance in forward direction = %.2f ohm\"%r_f\n", - "r_f = V_T/( Io * (math.exp(-V/V_T)) )# ohm\n", - "# The dynamic resistance = %.2f reverse direction \n", - "r_f = r_f * 10**-6# Mohm\n", - "print \"The dynamic resistance in reverse direction = %.2f Mohm\"%r_f" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.29 Page No 68" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage = -59.87 mV\n", - "The ratio of diode current with a forward bias to current with a reverse bias = -6.842\n", - "The value of I1 = 458.13 µA\n", - "The value of I2 = 21.90 mA\n", - "The value of I3 = 1.03 A\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "Eta = 1\n", - "V_T = 0.026\n", - "# I = Io*( (exp(V/(Eta*V_T))) - 1 ) and I = -Io\n", - "# I = -0.9*Io\n", - "# -0.9*Io = Io*( (exp(V/(Eta*V_T))) - 1 )\n", - "V = Eta*V_T*math.log(0.1)# V\n", - "V = V * 10**3# mV\n", - "print \"The voltage = %.2f mV\"%V\n", - "V = 0.05# V\n", - "# The ratio of diode current with a forward bias to current with a reverse bias \n", - "If_by_Ir= ( (math.exp(V/V_T))-1 )/( (math.exp(-V/V_T))-1 )\n", - "print \"The ratio of diode current with a forward bias to current with a reverse bias = %.3f\"%If_by_Ir\n", - "Io = 10# µA\n", - "V = 0.1# V\n", - "# The value of I1 \n", - "I1 = Io*( (math.exp(V/V_T))-1 )# µA\n", - "print \"The value of I1 = %.2f µA\"%I1\n", - "V = 0.2# V\n", - "# The value of I2\n", - "I2 = Io*( (math.exp(V/V_T))-1 )# µA \n", - "I2 = I2 * 10**-3# mA\n", - "print \"The value of I2 = %.2f mA\"%I2\n", - "V = 0.3# V\n", - "# The value of I3\n", - "I3 = Io*( (math.exp(V/V_T))-1 )# µA\n", - "I3 = I3 * 10**-6# A\n", - "print \"The value of I3 = %.2f A\"%I3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.30 Page No 69" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The factor by which current will get multiplied = 638.025\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "# Io150 = Io25 * 2**((150-25)/10)\n", - "#Io150 = 5800*Io25\n", - "T = 150# degree C\n", - "T = T + 273# K\n", - "V_T = 8.62*10**-5 * T# V\n", - "V = 0.4# V\n", - "Eta = 2\n", - "Vt = 0.026# V \n", - "# The factor by which current will get multiplied \n", - "I150byI25= 5800*math.exp(V/(Eta*V_T))/math.exp(V/(Eta*Vt))\n", - "print \"The factor by which current will get multiplied = %.3f\"%I150byI25" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.31 Page No 69" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The operating point of the diode is : (0.50V,4.50mA)\n" - ] - } - ], - "source": [ - "# Given data\n", - "R = 1# ohm\n", - "V = 5# V\n", - "V1 = 0.5# V\n", - "R1 = 1# k ohm\n", - "R1 = R1 * 10**3# ohm\n", - "# V-(I_D*R1)-(I_D*R) - V1 = 0\n", - "I_D = (V-V1)/(R1+R)# A\n", - "I_D = I_D * 10**3# mA\n", - "V_D = (I_D*10**-3*R) + V1# V\n", - "print \"The operating point of the diode is : (%.2fV,%.2fmA)\"%(V_D,I_D)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.32 Page No 70" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage drop across the forward biased diode, = 0.0180 V\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "Eta = 1\n", - "kT = 26# meV\n", - "# (%e**((e*V1)/kT)) = 2 or\n", - "#The voltage drop across the forward biased diode\n", - "V1 = math.log(2)*kT# mV\n", - "V1= V1*10**-3# V\n", - "print \"The voltage drop across the forward biased diode, = %.4f V\"%V1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.33 Page No 71" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The space charge capacitance = 70.74 pF\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "epsilon_Ge = 16/(36*math.pi*10**11)# F/cm\n", - "d = 2*10**-4# cm\n", - "A = 1# mm**2\n", - "A = A * 10**-2# cm**2\n", - "epsilon_o = epsilon_Ge# F/cm\n", - "# The space charge capacitance \n", - "C_T = (epsilon_o*A)/d# F\n", - "C_T = C_T * 10**12# pF\n", - "print \"The space charge capacitance = %.2f pF\"%C_T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.34 Page No 71" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of C_T = 61.68 pf/cm**2\n" - ] - } - ], - "source": [ - "import math \n", - "# Given data\n", - "D = 0.102# cm \n", - "A = (math.pi*(D**2))/4# cm**2\n", - "sigma_p = 0.286# (ohm-cm)**-1\n", - "q = 1.6*10**-19# C\n", - "miu_p = 500\n", - "# Formula used, sigma_p = q*miu_p*N_A\n", - "N_A = sigma_p/(q*miu_p)# atoms/cm**3\n", - "V1 = 5# V\n", - "V2 = 0.35# V\n", - "Vb = V1+V2# V\n", - "# The transition capacitance,\n", - "C_T = 2.92*10**-4*((N_A/Vb)**(1./2))*A# pF/cm**2\n", - "print \"The value of C_T = %.2f pf/cm**2\"%C_T" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.35 Page No 71" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of C_T for reverse bias = 15.00 pF\n" - ] - } - ], - "source": [ - "# Given data\n", - "C_T1 = 15# pF\n", - "Vb1 = 8# V\n", - "Vb2 = 12# V\n", - "# C_T1/C_T2 = (Vb2/Vb1)**(1/2)\n", - "C_T2 = C_T1 * ((Vb1/Vb2)**(1/2))# pF\n", - "print \"The value of C_T for reverse bias = %.2f pF\"%C_T2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.36 Page No 72" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage = -59.87 mV\n" - ] - } - ], - "source": [ - "import math\n", - "# Given data\n", - "V_T = 0.026# V\n", - "Eta = 1\n", - "I = '-0.9*Io'\n", - "# T = Io*((%e**(V/(Eta*V_T)))-1 )\n", - "# I = Io*((%e**(V/(Eta*V_T)))-1 )\n", - "V = math.log(0.1)*V_T# V \n", - "V = V * 10**3# mV\n", - "print \"The voltage = %.2f mV\"%V" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.37 Page No 72" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Part (a) : The value of I_D for first circuit = 0.97 mA\n", - "Part (b) : The value of I_D for second circuit = 0.10 mA\n" - ] - } - ], - "source": [ - "# Given data\n", - "Vin = 20# V\n", - "Vgamma = 0.7# V\n", - "R = 20# k ohm\n", - "R = R * 10**3# ohm\n", - "# Vin-(I_D*Vin) - Vgamma = 0 or\n", - "# The value of I_D,\n", - "I_D = (Vin-Vgamma)/R# A\n", - "I_D = I_D * 10**3# mA\n", - "print \"Part (a) : The value of I_D for first circuit = %.2f mA\"%I_D\n", - "\n", - "# Part (b)\n", - "Vin= 10.# V\n", - "Vgamma = 0.7# V\n", - "R = 100# k ohm\n", - "# Drain current,\n", - "I_D= Vin/R# mV\n", - "print \"Part (b) : The value of I_D for second circuit = %.2f mA\"%I_D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.38 Page No 73" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of I_D = 3.10 mA\n", - "The value of Vo = 6.90 V\n" - ] - } - ], - "source": [ - "# Given data\n", - "R1 = 1# k ohm\n", - "R1 = R1 * 10**3# ohm\n", - "R2 = 2# k ohm\n", - "R2 = R2 * 10**3# ohm\n", - "V = 10# V\n", - "V1 = 0.7# V \n", - "# V * (I_D*R1) - (R2*I_D) - V1 = 0\n", - "I_D = (V-V1)/(R1+R2)# A\n", - "I_D = I_D * 10**3# mA\n", - "print \"The value of I_D = %.2f mA\"%I_D\n", - "# The output voltage,\n", - "Vo = (I_D*10**-3 * R2) +V1# V\n", - "print \"The value of Vo = %.2f V\"%Vo" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.39 Page No 73" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Part (a): The current through resistance = 1.00 A\n", - "Part (b) : Current through 10 ohm resistance will be Zero\n", - "Part (c): Current will be zero\n", - "Part (d): The diode will be ON and current = 1.00 A\n" - ] - } - ], - "source": [ - "# Given data\n", - "V = 10.# V\n", - "R = 10# ohm\n", - "# Current through resistance,\n", - "I = V/R# A\n", - "print \"Part (a): The current through resistance = %.2f A\"%I\n", - "print \"Part (b) : Current through 10 ohm resistance will be Zero\"\n", - "print \"Part (c): Current will be zero\"\n", - "print \"Part (d): The diode will be ON and current = %.2f A\"%I" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.40 Page No 74" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The operating point is : (0.50V,4.50mA)\n" - ] - } - ], - "source": [ - "# Given data\n", - "Vth= 0.5# V\n", - "R_F= 1*10**3# ohm\n", - "V= 5# V\n", - "# Applying KVL for loop, V-Vd-R_F*Ii= 0 (i)\n", - "# When Ii=0\n", - "Vd= V# V\n", - "# When Vd= 0\n", - "Ii= V/R_F# A\n", - "# From eq(i)\n", - "Ii= (V-Vth)/R_F# A\n", - "Vd= V-R_F*Ii# V\n", - "print \"The operating point is : (%.2fV,%.2fmA)\"%(Vd,Ii*1000)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.43 Page No 76" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage at V1 = 6.00 volts\n", - "The voltage at V2 = 5.40 volts\n" - ] - } - ], - "source": [ - "# Given data\n", - "V_CC = 6# V\n", - "Vr = 0.6# V\n", - "V1= V_CC##in V\n", - "V2 = V1-Vr# V\n", - "print \"The voltage at V1 = %.2f volts\"%V1\n", - "print \"The voltage at V2 = %.2f volts\"%V2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.44 Page No 76" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of I1 = 1.80 mA\n", - "The value of I2 = 1.80 mA\n" - ] - } - ], - "source": [ - "# Given data\n", - "V_T = 0.7# V\n", - "V = 5# V\n", - "R = 2# k ohm\n", - "R = R * 10**3# ohm\n", - "Vs = 0.7\n", - "Vx = Vs+V_T# V\n", - "# The value of I1 \n", - "I1 = (V-Vx)/R# A\n", - "I1 = I1 * 10**3# mA\n", - "print \"The value of I1 = %.2f mA\"%I1\n", - "# The value of I2 \n", - "I2 = I1# mA\n", - "print \"The value of I2 = %.2f mA\"%I2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 1.45 Page No 77" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of Vo = 1.00 V\n" - ] - } - ], - "source": [ - "# Given data\n", - "Rf = 300.# ohm\n", - "V = 0.5# V\n", - "R = 600.# ohm\n", - "Vi = 2.# V\n", - "# The output voltage \n", - "Vo = (Vi-V)*( R/(R+Rf) )# V\n", - "print \"The value of Vo = %.2f V\"%Vo" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/PraveenKumar/chapter2.ipynb b/sample_notebooks/PraveenKumar/chapter2.ipynb deleted file mode 100755 index 3d7aab33..00000000 --- a/sample_notebooks/PraveenKumar/chapter2.ipynb +++ /dev/null @@ -1,429 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "chapter-2, Economics of generation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex1, Page 73" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "#To Determine the Demand and Supply Parameters for 15 bulbs\n", - "\n", - "W=60 #Wattage of the bulb\n", - "N=15 #No. of bulbs\n", - "CL=W*N #Connected Load \n", - "Wih=2*(10**3) #Wattage of immersion heater\n", - "Wh=2*(10**3) #Wattage of heater\n", - "\n", - "#Usage of Bulbs at different time periods\n", - "N1=5 \n", - "N2=10 \n", - "N3=6\n", - "\n", - "#Time periods for bulbs\n", - "T1=2 #6pm - 8pm\n", - "T2=2 #8pm - 10pm\n", - "T3=2 #10pm - 12pm\n", - "#Time Periods for heaters\n", - "T4=4 #1pm - 5pm\n", - "T5=3 #8pm - 11pm\n", - "\n", - "#CASE 1\n", - "MD1=W*N2 #Maximum Demand\n", - "DF=MD1*100/CL #Demand Factor\n", - "EC1=(N1*W*T1)+(N2*W*T2)+(N3*W*T3) #Energy Consumed\n", - "DLF1=EC1*100/(24*MD1) #Daily Load Factor\n", - "\n", - "#CASE 2\n", - "MD2=(W*N2)+Wh #From 8pm - 10pm\n", - "EC2=(T4*Wih)+(T5*Wh)+EC1 #Energy Consumed\n", - "DLF2=EC2*100/(24*MD2) #Daily Load Factor\n", - "\n", - "print '''i)a) Connected Load is %0.2f W\\nb) The Maximum Demand is %0.2f W\n", - "c) The Demand Factor is %0.2f percent\\nd) The Daily Load Factor is %0.2f percent''' %(CL,MD1,DF,DLF1)\n", - "print 'ii) The Improved Daily Load Factor is %0.2f percent' %DLF2" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "i)a) Connected Load is 900.00 W\n", - "b) The Maximum Demand is 600.00 W\n", - "c) The Demand Factor is 66.67 percent\n", - "d) The Daily Load Factor is 17.50 percent\n", - "ii) The Improved Daily Load Factor is 26.47 percent\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2, Page 74" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "\n", - "#To determine the Demand and supply parameter of four consumers\n", - "\n", - "\n", - "#Maximum Demands of various users\n", - "MD1=2*(10**3) #9pm\n", - "MD2=2*(10**3) #12 noon\n", - "MD3=8*(10**3) #5pm\n", - "MD4=4*(10**3) #8pm\n", - "MDT=MD1+MD2+MD3+MD4 #Sum of all Maximum Demands\n", - "\n", - "#Demands of various users\n", - "D1=1.6*(10**3) #8pm\n", - "D2=1*(10**3) #8pm\n", - "D3=5*(10**3) #8pm\n", - "\n", - "#The Number after the Alphabets represents the Consumer\n", - "\n", - "#Maximum Demand of the System arises at 8.00 PM\n", - "MDS = D1+D2+D3+MD4 \n", - "\n", - "TDF=MDT/MDS #Diversity Factor\n", - "#Given Values\n", - "#Average Loads\n", - "AL2=500 \n", - "AL4=1000 \n", - "#Load Factors\n", - "LF1=15/100 \n", - "LF3=25/100 \n", - "#Calculated Values\n", - "#Average Loads\n", - "AL1=LF1*MD1 \n", - "AL3=LF3*MD3 \n", - "#Load Factors\n", - "LF2=AL2*100/MD2 \n", - "LF4=AL4*100/MD4 \n", - "\n", - "ALS=AL1+AL2+AL3+AL4 #Combined Average Loads\n", - "LFS=ALS*100/MDS #Combined Load Factor\n", - "\n", - "#Load Percent\n", - "LF1*=100 # %\n", - "LF3*=100 # %\n", - "\n", - "print 'i) The Diversity Factor is %0.2f' %TDF\n", - "print 'ii) The Average load and Load factor of:'\n", - "print ' Consumer 1 : %0.2f W and %0.2f percent' %(AL1,LF1)\n", - "print ' Consumer 2 : %0.2f W and %0.2f percent' %(AL2,LF2)\n", - "print ' Consumer 3 : %0.2f W and %0.2f percent' %(AL3,LF3)\n", - "print ' Consumer 4 : %0.2f W and %0.2f percent' %(AL4,LF4)\n", - "print 'iii) The Combined Load Factor and the Combined Average Load is %0.2f percent and %0.2f W respectively\\n' %(LFS,ALS)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "i) The Diversity Factor is 1.38\n", - "ii) The Average load and Load factor of:\n", - " Consumer 1 : 300.00 W and 15.00 percent\n", - " Consumer 2 : 500.00 W and 25.00 percent\n", - " Consumer 3 : 2000.00 W and 25.00 percent\n", - " Consumer 4 : 1000.00 W and 25.00 percent\n", - "iii) The Combined Load Factor and the Combined Average Load is 32.76 percent and 3800.00 W respectively\n", - "\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex3, Page 75" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "\n", - "#To Determine the Yearly Cost of the substation\n", - "\n", - "Teff=95/100 #Transmission Efficiency\n", - "Deff=85/100 #Distribution Efficiency\n", - "DFT=1.2 #Diversity Factor For Transmission\n", - "DFD=1.3 #Diversity Factor For Distribution\n", - "MDGS=100*(10**6) #Maximum Demand of Generating Station\n", - "ALF=40/100 #Annual Load Factor\n", - "ACCT=2.5*(10**6) #Annual Capital Charge for Transmission\n", - "ACCD=2*(10**6) #Annual Capital Charge for Distribution\n", - "GCC=100 #Generating Cost per kW demand\n", - "GCCU=5/100 # Per Unit Cost\n", - "#Fixed Charges from Supply to Substation Annually\n", - "GFC=GCC*MDGS/1000 #Generating\n", - "TFC=ACCT #Transmission\n", - "TotFCS=GFC+TFC #Total\n", - "#Fixed Charges for supply upto Consumer Annually\n", - "DFC=ACCD #Distribution\n", - "TotFCC=TotFCS+DFC #Total\n", - "\n", - "AMDS= DFT*MDGS/1000 #Aggregate of Maximum Demand at Supply\n", - "AMDC= DFD*AMDS #Aggregate of Maximum Demand for Consumers\n", - "\n", - "FCS=TotFCS/AMDS #Fixed Charges Per KW at substation\n", - "CES=GCCU/Teff #Cost of energy at the substation\n", - "\n", - "FCC=TotFCC/AMDC #Fixed Charges per KW at the consumer premises\n", - "CEC=CES/Deff #Cost of Energy at the consumer premises\n", - "\n", - "CEC*=100 # converting from rupee to paise\n", - "\n", - "print 'The Yealy Cost per KW demand and the cost per KWhr at:'\n", - "print 'a) The substation is %0.2f rupees per KW and %0.2f paise per kWhr'%(FCS,CES)\n", - "print 'b) The consumer premises is %g rupees per KW and %g paise per kWhr' %(FCC,CEC)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Yealy Cost per KW demand and the cost per KWhr at:\n", - "a) The substation is 104.17 rupees per KW and 0.05 paise per kWhr\n", - "b) The consumer premises is 92.9487 rupees per KW and 6.19195 paise per kWhr\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4, Page 78" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To determine the Load factor and suitable units for 24 hr operation of the plant\n", - "\n", - "\n", - "#Demands at Various Time Periods starting from 12PM to 12PM\n", - "D1=500*(10**3) \n", - "D2=800*(10**3) \n", - "D3=2000*(10**3) \n", - "D4=1000*(10**3) \n", - "D5=2500*(10**3) \n", - "D6=2000*(10**3) \n", - "D7=1500*(10**3) \n", - "D8=1000*(10**3) \n", - "\n", - "MD=D5 #Maximum Demand\n", - "#Time Periods of demands from 12PM\n", - "T1=5 \n", - "T2=5 \n", - "T3=2 \n", - "T4=2 \n", - "T5=3 \n", - "T6=3 \n", - "T7=2 \n", - "T8=2 \n", - "\n", - "#Total Energy Demand in 24hrs\n", - "TED=(T1*D1)+(T2*D2)+(T3*D3)+(D4*T4)+(T5*D5)+(D6*T6)+(D7*T7)+(T8*D8) \n", - "\n", - "LF=TED*100/(24*MD) \n", - "\n", - "C1000=3*1000*(10**3) #1000 unit \n", - "C500=1*500*(10**3) #500 Unit\n", - "\n", - "TCP=C1000+C500 #Total capacity of the plant\n", - "PCF=TED*100/(24*TCP) #Plant Capacity Factor\n", - "\n", - "#Operating Schedule, Units operated can be seen in the textbook\n", - "G1=500*(10**3) \n", - "G2=1000*(10**3) \n", - "G3=2000*(10**3) \n", - "G4=1000*(10**3) \n", - "G5=2500*(10**3) \n", - "G6=2000*(10**3) \n", - "G7=1500*(10**3) \n", - "G8=1000*(10**3) \n", - "\n", - "TEG=(T1*G1)+(T2*G2)+(T3*G3)+(G4*T4)+(T5*G5)+(G6*T6)+(G7*T7)+(T8*G8) #Total Energy Generated\n", - "PUF=TED*100/(TEG) #Plant Use Factor\n", - "\n", - "print 'a) The Reserve Capacity is a 1000kW Unit and Load Factor is %0.2f percent' %LF\n", - "print 'b) The Plant Capacity Factor is %0.2f percent' %PCF\n", - "print 'c) The Plant Use Factor is %0.2f percent' %PUF" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "a) The Reserve Capacity is a 1000kW Unit and Load Factor is 51.67 percent\n", - "b) The Plant Capacity Factor is 36.90 percent\n", - "c) The Plant Use Factor is 96.88 percent\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex5, Page 80" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To determine the Plant use factore of each unit\n", - "\n", - "\n", - "MDS=25*(10**6) #Maximum Demand on the System\n", - "U1=15*(10**6) #Load Supplied By Unit 1\n", - "U2=12.5*(10**6) #Load Supplied By Unit 2\n", - "#Running Time Factor of the Unit\n", - "T1=1 \n", - "T2=40/100 \n", - "\n", - "#Energy generated by each unit\n", - "E1=1*(10**8) \n", - "E2=1*(10**7) \n", - "Et=E1+E2 #Total Energy\n", - "\n", - "#Maximum Demands on Each Units\n", - "MD1=U1 \n", - "MD2=MDS-U1 \n", - "\n", - "#Annual Load Factor for the Units\n", - "ALF1=E1*1000*100/(MD1*8760) \n", - "ALF2=E2*1000*100/(MD2*8760) \n", - "\n", - "LF2=E2*1000*100/(MD2*0.4*8760) #Load Factor for the it is loaded\n", - "\n", - "\n", - "PUF1=ALF1 #Plant Use Factor\n", - "PCF1=ALF1 # Plant Capacity Factor\n", - "\n", - "PCF2=E2*1000*100/(U2*8760) #Plant Capacity Factor for Unit 2\n", - "PUF2=E2*1000*100/(U2*0.4*8760) #Plant Use Factor for Unit 2\n", - "\n", - "LFP=Et*100*1000/(MDS*8760) #Annual Load Factor of the Complete Plant\n", - "\n", - "print 'The Load Factor, Plant Capacity Factor, Plant Use Factor of:'\n", - "print 'Unit 1 : %0.2f percent, %0.2f percent, %0.2f percent' %(ALF1,PCF1,PUF1)\n", - "print 'Unit 2 : %0.2f percent, %0.2f percent, %0.2f percent' %(ALF2,PCF2,PUF2)\n", - "print 'The Annual Load Factor of the Entire Plant is %0.2f percent' %LFP" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Load Factor, Plant Capacity Factor, Plant Use Factor of:\n", - "Unit 1 : 76.10 percent, 76.10 percent, 76.10 percent\n", - "Unit 2 : 11.42 percent, 9.13 percent, 22.83 percent\n", - "The Annual Load Factor of the Entire Plant is 50.23 percent\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex6, Page 91" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#To determine the most economic power factor\n", - "\n", - "from numpy import sqrt\n", - "\n", - "P=200*(10**3) #Maximum Demand\n", - "pf=0.707 #Power Factor Lagging\n", - "\n", - "a=100 #Tariff per kVA per year\n", - "\n", - "b=200 #Power factor improvement cost Per kVA.\n", - "r=20 #Interest Depriciation, maintenance and cost of losses amount to 20% of capital cost per year\n", - "\n", - "# Economic PF = sqrt(1-((b1/a)**2))\n", - "\n", - "b1=r*b/100 # b' term accrding to the equation above\n", - "\n", - "pfeco=sqrt(1-((b1/a)**2)) #Economic Power Factor\n", - "\n", - "print 'The Economic Power Factor is %0.2f ' %pfeco\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Economic Power Factor is 0.92 \n" - ] - } - ], - "prompt_number": 22 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/PreetiRani/Operational.ipynb b/sample_notebooks/PreetiRani/Operational.ipynb new file mode 100755 index 00000000..ffbfbdf3 --- /dev/null +++ b/sample_notebooks/PreetiRani/Operational.ipynb @@ -0,0 +1,299 @@ +{ + "metadata": { + "name": "Preeti", + "signature": "sha256:b8dcb8af15a997e111f6feb032fec7a056888e6b8b149ec767b2b1cbf63692d5" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 : Operational Amplifiers" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.1 : page 11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "G= -100.0 # Gain\n", + "R1= 2.2 # in kohm\n", + "R1=R1*10**3 # in ohm\n", + "# Formula G=-Rf/R1\n", + "Rf= -G*R1 # ohm\n", + "Rf*= 10**-3 # kohm\n", + "print \"The value of Rf is %d kohm\" %Rf" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of Rf is 220 kohm\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.2 : page 11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Rf= 200 # in kohm\n", + "R1= 2 # in kohm\n", + "vin=2.5 # in mV\n", + "vin=vin*10**-3 # in volt\n", + "G= -Rf/R1 \n", + "vo= G*vin # in V\n", + "print \"The output voltage is %0.2f volt\" %vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The output voltage is -0.25 volt\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.3 : page 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "G=-10.0 \n", + "Ri= 100.0 # in kohm\n", + "R1= Ri # in kohm\n", + "R1=R1*10**3 # in ohm\n", + "R1*= 10**-3 # kohm\n", + "# Formula G=-R2/R1\n", + "R2= R1*abs(G) # ohm\n", + "R2*= 10**-3 # Mohm\n", + "print \"Value of R1 is %0.2f kohm\" %R1\n", + "print \"and value of R2 is %0.2f Mohm\" %R2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of R1 is 100.00 kohm\n", + "and value of R2 is 1.00 Mohm\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.4 : page 37" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "R1= 100.0 # in kohm\n", + "R2= 500 # in kohm\n", + "V1= 2.0 # in volt\n", + "Vo= (1+R2/R1)*V1 # in volt\n", + "print \"Output voltage for noninverting amplifier is %0.2f volt\" %Vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Output voltage for noninverting amplifier is 12.00 volt\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.5 : page 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "Rf= 1 # in Mohm\n", + "Rf=Rf*10**6 #in ohm\n", + "\n", + "# Part(a)\n", + "V1=1.0 #in volt\n", + "V2=2.0 #in volt\n", + "V3=3.0 #in volt\n", + "R1= 500.0 # in kohm\n", + "R1=R1*10**3 #in ohm\n", + "R2= 1 # in Mohm\n", + "R2=R2*10**6 #in ohm\n", + "R3= 1.0 # in Mohm\n", + "R3=R3*10**6 #in ohm\n", + "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n", + "print \"(a) Output voltage is %0.2f volt\" %Vo\n", + "\n", + "# Part(b)\n", + "V1=-2.0 #in volt\n", + "V2=3.0 #in volt\n", + "V3=1.0 #in volt\n", + "R1= 200.0 # in kohm\n", + "R1=R1*10**3 #in ohm\n", + "R2= 500.0 # in kohm\n", + "R2=R2*10**3 #in ohm\n", + "R3= 1.0 # in Mohm\n", + "R3=R3*10**6 #in ohm\n", + "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n", + "print \"(b) Output voltage is %0.2f volt\" %Vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Output voltage is -7.00 volt\n", + "(b) Output voltage is 3.00 volt\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.6 : page 38" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "print \"Minimum closed loop voltage gain for R2=0 and R1= 2 kohm is \"\n", + "R2=0 \n", + "R1=2.0 # in kohm\n", + "R1=R1*10**3 # in ohm\n", + "Av_min= (1+R2/R1)\n", + "print Av_min\n", + "\n", + "print \"Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm is\"\n", + "R2=100 # in kohm\n", + "R1=2 # in kohm\n", + "Av_max= (1+R2/R1)\n", + "print Av_max " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum closed loop voltage gain for R2=0 and R1= 2 kohm is \n", + "1.0\n", + "Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm is\n", + "51\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Exa 1.7 : page 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Given data\n", + "V1= 745 # in \u00b5V\n", + "V2= 740 # in \u00b5V\n", + "V1=V1*10**-6 # in volt\n", + "V2=V2*10**-6 # in volt\n", + "CMRR=80 # in dB\n", + "Av=5*10**5 \n", + "# (i)\n", + "# CMRR in dB= 20*log(Ad/Ac)\n", + "Ad=Av \n", + "Ac= Ad/10**(CMRR/20) \n", + "# (ii)\n", + "Vo= Ad*(V1-V2)+Ac*(V1+V2)/2 \n", + "print \"Output voltage is %0.2f volt\" %Vo" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Output voltage is 2.54 volt\n" + ] + } + ], + "prompt_number": 27 + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/PreetiRani/Operational_Amplifiers.ipynb b/sample_notebooks/PreetiRani/Operational_Amplifiers.ipynb deleted file mode 100755 index ffbfbdf3..00000000 --- a/sample_notebooks/PreetiRani/Operational_Amplifiers.ipynb +++ /dev/null @@ -1,299 +0,0 @@ -{ - "metadata": { - "name": "Preeti", - "signature": "sha256:b8dcb8af15a997e111f6feb032fec7a056888e6b8b149ec767b2b1cbf63692d5" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 : Operational Amplifiers" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.1 : page 11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "G= -100.0 # Gain\n", - "R1= 2.2 # in kohm\n", - "R1=R1*10**3 # in ohm\n", - "# Formula G=-Rf/R1\n", - "Rf= -G*R1 # ohm\n", - "Rf*= 10**-3 # kohm\n", - "print \"The value of Rf is %d kohm\" %Rf" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of Rf is 220 kohm\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.2 : page 11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "Rf= 200 # in kohm\n", - "R1= 2 # in kohm\n", - "vin=2.5 # in mV\n", - "vin=vin*10**-3 # in volt\n", - "G= -Rf/R1 \n", - "vo= G*vin # in V\n", - "print \"The output voltage is %0.2f volt\" %vo" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The output voltage is -0.25 volt\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.3 : page 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "G=-10.0 \n", - "Ri= 100.0 # in kohm\n", - "R1= Ri # in kohm\n", - "R1=R1*10**3 # in ohm\n", - "R1*= 10**-3 # kohm\n", - "# Formula G=-R2/R1\n", - "R2= R1*abs(G) # ohm\n", - "R2*= 10**-3 # Mohm\n", - "print \"Value of R1 is %0.2f kohm\" %R1\n", - "print \"and value of R2 is %0.2f Mohm\" %R2" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Value of R1 is 100.00 kohm\n", - "and value of R2 is 1.00 Mohm\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.4 : page 37" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "R1= 100.0 # in kohm\n", - "R2= 500 # in kohm\n", - "V1= 2.0 # in volt\n", - "Vo= (1+R2/R1)*V1 # in volt\n", - "print \"Output voltage for noninverting amplifier is %0.2f volt\" %Vo" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Output voltage for noninverting amplifier is 12.00 volt\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.5 : page 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "Rf= 1 # in Mohm\n", - "Rf=Rf*10**6 #in ohm\n", - "\n", - "# Part(a)\n", - "V1=1.0 #in volt\n", - "V2=2.0 #in volt\n", - "V3=3.0 #in volt\n", - "R1= 500.0 # in kohm\n", - "R1=R1*10**3 #in ohm\n", - "R2= 1 # in Mohm\n", - "R2=R2*10**6 #in ohm\n", - "R3= 1.0 # in Mohm\n", - "R3=R3*10**6 #in ohm\n", - "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n", - "print \"(a) Output voltage is %0.2f volt\" %Vo\n", - "\n", - "# Part(b)\n", - "V1=-2.0 #in volt\n", - "V2=3.0 #in volt\n", - "V3=1.0 #in volt\n", - "R1= 200.0 # in kohm\n", - "R1=R1*10**3 #in ohm\n", - "R2= 500.0 # in kohm\n", - "R2=R2*10**3 #in ohm\n", - "R3= 1.0 # in Mohm\n", - "R3=R3*10**6 #in ohm\n", - "Vo= -Rf*(V1/R1+V2/R2+V3/R3) # in volt\n", - "print \"(b) Output voltage is %0.2f volt\" %Vo" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Output voltage is -7.00 volt\n", - "(b) Output voltage is 3.00 volt\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.6 : page 38" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "print \"Minimum closed loop voltage gain for R2=0 and R1= 2 kohm is \"\n", - "R2=0 \n", - "R1=2.0 # in kohm\n", - "R1=R1*10**3 # in ohm\n", - "Av_min= (1+R2/R1)\n", - "print Av_min\n", - "\n", - "print \"Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm is\"\n", - "R2=100 # in kohm\n", - "R1=2 # in kohm\n", - "Av_max= (1+R2/R1)\n", - "print Av_max " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Minimum closed loop voltage gain for R2=0 and R1= 2 kohm is \n", - "1.0\n", - "Maximum closed loop voltage gain for maximum value of R2=100 kohm and R1= 2 kohm is\n", - "51\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Exa 1.7 : page 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Given data\n", - "V1= 745 # in \u00b5V\n", - "V2= 740 # in \u00b5V\n", - "V1=V1*10**-6 # in volt\n", - "V2=V2*10**-6 # in volt\n", - "CMRR=80 # in dB\n", - "Av=5*10**5 \n", - "# (i)\n", - "# CMRR in dB= 20*log(Ad/Ac)\n", - "Ad=Av \n", - "Ac= Ad/10**(CMRR/20) \n", - "# (ii)\n", - "Vo= Ad*(V1-V2)+Ac*(V1+V2)/2 \n", - "print \"Output voltage is %0.2f volt\" %Vo" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Output voltage is 2.54 volt\n" - ] - } - ], - "prompt_number": 27 - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/RONAKBANSAL/RONAKBANSAL_version_backup/chapter_1.ipynb b/sample_notebooks/RONAKBANSAL/RONAKBANSAL_version_backup/chapter_1.ipynb new file mode 100755 index 00000000..c00d0fbc --- /dev/null +++ b/sample_notebooks/RONAKBANSAL/RONAKBANSAL_version_backup/chapter_1.ipynb @@ -0,0 +1,528 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Semiconductor Diodes" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Thermal Voltage= 25.875 mV\n" + ] + } + ], + "source": [ + "k=1.38*(10**(-23)) #boltzmann's constant\n", + "t=273+27 #converting given temperature to Kelvin\n", + "q=1.6*(10**(-19)) #charge on an electron\n", + "\n", + "# V=(k*t)/q\n", + "\n", + "V=(k*t)/q\n", + "V=V*1000 #converting result in millivolts\n", + "print \"Thermal Voltage=\",V,\"mV\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2 (a)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage across Germanium diode= 0.2 V\n", + "Voltage across Silicon diode = 0.6 V\n", + "Voltage across GaAs diode = 1.1 V\n" + ] + } + ], + "source": [ + "Id= 1 #in mA, current across diodes\n", + "#from the standard graph for Ge,Si, and GaAs diodes\n", + "Vge=0.2\n", + "Vsi=0.6\n", + "Vgaas=1.1\n", + "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", + "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", + "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2 (b)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage across Germanium diode= 0.3 V\n", + "Voltage across Silicon diode = 0.7 V\n", + "Voltage across GaAs diode = 1.2 V\n" + ] + } + ], + "source": [ + "Id= 4 #in mA, current across diodes\n", + "#from the standard graph for Ge,Si, and GaAs diodes\n", + "Vge=0.3\n", + "Vsi=0.7\n", + "Vgaas=1.2\n", + "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", + "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", + "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2 (c)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage across Germanium diode= 0.42 V\n", + "Voltage across Silicon diode = 0.82 V\n", + "Voltage across GaAs diode = 1.33 V\n" + ] + } + ], + "source": [ + "Id=30 #in mA, current across diodes\n", + "#from the standard graph for Ge,Si, and GaAs diodes\n", + "Vge=0.42\n", + "Vsi=0.82\n", + "Vgaas=1.33\n", + "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", + "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", + "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2 (d)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Average Volatge value for Germanium Diode= 0.307 V\n", + "Average Volatge value for Silicon Diode= 0.707 V\n", + "Average Volatge value for GaAs Diode= 1.21 V\n" + ] + } + ], + "source": [ + "#Average value for Germanium\n", + "Vg=(0.2+0.3+0.42)/3\n", + "#Average value for Silicon\n", + "Vs=(0.6+0.7+0.82)/3\n", + "#Average value for GaAs\n", + "Vgs=(1.1+1.2+1.33)/3\n", + "print \"Average Volatge value for Germanium Diode=\",round(Vg,3),\"V\"\n", + "print \"Average Volatge value for Silicon Diode=\",round(Vs,3),\"V\"\n", + "print \"Average Volatge value for GaAs Diode=\",round(Vgs,3),\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2 (e)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Very close correspondence between knee voltage and average voltage\n", + "Germanium 0.3 V vs 0.307 V\n", + "Silicon 0.7 V vs 0.707 V\n", + "GaAs 1.2 V vs 1.21 V\n" + ] + } + ], + "source": [ + "#comparing average values in d with the standard knee voltages\n", + "#Average value for Germanium\n", + "Vg=(0.2+0.3+0.42)/3\n", + "#Average value for Silicon\n", + "Vs=(0.6+0.7+0.82)/3\n", + "#Average value for GaAs\n", + "Vgs=(1.1+1.2+1.33)/3\n", + "kge=0.3\n", + "ksi=0.7\n", + "kgaas=1.2\n", + "print \"Very close correspondence between knee voltage and average voltage\"\n", + "print \"Germanium\",kge,\"V vs\",round(Vg,3),\"V\"\n", + "print \"Silicon\",ksi,\"V vs\",round(Vs,3),\"V\"\n", + "print \"GaAs\",kgaas,\"V vs\",round(Vgs,3),\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## There is a Repeatation of Example 1.2" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dc resistance= 250.0 ohms\n" + ] + } + ], + "source": [ + "Id=2*(10**(-3)) #in ampere\n", + "Vd=0.5 #in volts\n", + "rd=Vd/Id\n", + "print \"dc resistance=\",rd,\"ohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2(b)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dc resistance 40.0 ohms\n" + ] + } + ], + "source": [ + "Id=20*(10**(-3)) #in ampere\n", + "Vd=0.8 #in volts\n", + "rd=Vd/Id\n", + "print \"dc resistance=\",rd,\"ohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2(c)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dc resistance= 10.0 Mohms\n" + ] + } + ], + "source": [ + "#Id=-Is\n", + "Id=1*(10**(-6)) #in ampere\n", + "Vd=-10 #in volts\n", + "rd=abs(Vd)/Id\n", + "rd=rd/(10**(6))\n", + "print \"dc resistance=\",rd,\"Mohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3(a)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ac resistance= 27.5 ohms\n" + ] + } + ], + "source": [ + "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n", + "Id1=4*(10**(-3)) #IN ampere\n", + "Id2=0 #IN ampere\n", + "Vd1=0.76 #IN VOLTS\n", + "Vd2=0.65 #IN VOLTS \n", + "X=Id1-Id2\n", + "Y=Vd1-Vd2\n", + "rd=Y/X\n", + "print \"ac resistance=\",rd,\"ohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3(b)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ac resistance= 2.0 ohms\n" + ] + } + ], + "source": [ + "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n", + "Id1=30*(10**(-3)) #IN ampere\n", + "Id2=20*(10**(-3)) #IN ampere\n", + "Vd1=0.80 #IN VOLTS\n", + "Vd2=0.78 #IN VOLTS \n", + "X=Id1-Id2\n", + "Y=Vd1-Vd2\n", + "rd=Y/X\n", + "print \"ac resistance=\",rd,\"ohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.3(c)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Dc resistance= 350.0 ohms exceeds ac resistance= 27.5 ohms\n", + "Dc resistance= 31.6 ohms exceeds ac resistance= 2 ohms\n" + ] + } + ], + "source": [ + "#calculating Dc resistance\n", + "#Case-1\n", + "Id1=2*(10**(-3)) #in ampere\n", + "Vd1=0.7 #in volts\n", + "Rd=Vd1/Id1\n", + "rd=27.5 #ac resistance in ohms\n", + "if Rd>rd:\n", + " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n", + "else:\n", + " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\"\n", + "\n", + "#Case-2\n", + "Id1=25*(10**(-3)) #in ampere\n", + "Vd1=0.79 #in volts\n", + "Rd=Vd1/Id1\n", + "rd=2 #ac resistance in ohms\n", + "if Rd>rd:\n", + " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n", + "else:\n", + " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.4" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "New potential across zener diode= 10.54 V\n" + ] + } + ], + "source": [ + "#Equation- change in Cvz=(Tc*Vz*(t1-t0))/100%\n", + "Tc=0.072 #unit %/celsius\n", + "t1=100 #in celsius\n", + "t0=25 #in celsius\n", + "Vz=10 #in volts\n", + "Cvz=(Tc*Vz*(t1-t0))/100\n", + "nVz=Vz+Cvz #new Vz\n", + "print \"New potential across zener diode=\",nVz,\"V\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.5" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The range of Wavelength for the frequency of Visible lightis 750 nm to 400 nm\n" + ] + } + ], + "source": [ + "#Equation wavelength(x)=c/f,where c=speed of light and f=frequency of the light\n", + "c=3*(10**(8))*(10**(9)) #in nm/s\n", + "x1=(c/(400*(10**12))) #in nm\n", + "x2=c/(750*(10**12)) #in nm\n", + "print \"The range of Wavelength for the frequency of Visible lightis\",x1,\"nm to\",x2,\"nm\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + }, + "widgets": { + "state": {}, + "version": "1.1.2" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/RONAKBANSAL/chapter_1.ipynb b/sample_notebooks/RONAKBANSAL/chapter_1.ipynb deleted file mode 100755 index c00d0fbc..00000000 --- a/sample_notebooks/RONAKBANSAL/chapter_1.ipynb +++ /dev/null @@ -1,528 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Semiconductor Diodes" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Thermal Voltage= 25.875 mV\n" - ] - } - ], - "source": [ - "k=1.38*(10**(-23)) #boltzmann's constant\n", - "t=273+27 #converting given temperature to Kelvin\n", - "q=1.6*(10**(-19)) #charge on an electron\n", - "\n", - "# V=(k*t)/q\n", - "\n", - "V=(k*t)/q\n", - "V=V*1000 #converting result in millivolts\n", - "print \"Thermal Voltage=\",V,\"mV\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2 (a)" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage across Germanium diode= 0.2 V\n", - "Voltage across Silicon diode = 0.6 V\n", - "Voltage across GaAs diode = 1.1 V\n" - ] - } - ], - "source": [ - "Id= 1 #in mA, current across diodes\n", - "#from the standard graph for Ge,Si, and GaAs diodes\n", - "Vge=0.2\n", - "Vsi=0.6\n", - "Vgaas=1.1\n", - "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", - "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", - "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2 (b)" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage across Germanium diode= 0.3 V\n", - "Voltage across Silicon diode = 0.7 V\n", - "Voltage across GaAs diode = 1.2 V\n" - ] - } - ], - "source": [ - "Id= 4 #in mA, current across diodes\n", - "#from the standard graph for Ge,Si, and GaAs diodes\n", - "Vge=0.3\n", - "Vsi=0.7\n", - "Vgaas=1.2\n", - "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", - "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", - "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2 (c)" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage across Germanium diode= 0.42 V\n", - "Voltage across Silicon diode = 0.82 V\n", - "Voltage across GaAs diode = 1.33 V\n" - ] - } - ], - "source": [ - "Id=30 #in mA, current across diodes\n", - "#from the standard graph for Ge,Si, and GaAs diodes\n", - "Vge=0.42\n", - "Vsi=0.82\n", - "Vgaas=1.33\n", - "print \"Voltage across Germanium diode=\",Vge,\"V\"\n", - "print \"Voltage across Silicon diode =\",Vsi,\"V\"\n", - "print \"Voltage across GaAs diode =\",Vgaas,\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2 (d)" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Average Volatge value for Germanium Diode= 0.307 V\n", - "Average Volatge value for Silicon Diode= 0.707 V\n", - "Average Volatge value for GaAs Diode= 1.21 V\n" - ] - } - ], - "source": [ - "#Average value for Germanium\n", - "Vg=(0.2+0.3+0.42)/3\n", - "#Average value for Silicon\n", - "Vs=(0.6+0.7+0.82)/3\n", - "#Average value for GaAs\n", - "Vgs=(1.1+1.2+1.33)/3\n", - "print \"Average Volatge value for Germanium Diode=\",round(Vg,3),\"V\"\n", - "print \"Average Volatge value for Silicon Diode=\",round(Vs,3),\"V\"\n", - "print \"Average Volatge value for GaAs Diode=\",round(Vgs,3),\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2 (e)" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Very close correspondence between knee voltage and average voltage\n", - "Germanium 0.3 V vs 0.307 V\n", - "Silicon 0.7 V vs 0.707 V\n", - "GaAs 1.2 V vs 1.21 V\n" - ] - } - ], - "source": [ - "#comparing average values in d with the standard knee voltages\n", - "#Average value for Germanium\n", - "Vg=(0.2+0.3+0.42)/3\n", - "#Average value for Silicon\n", - "Vs=(0.6+0.7+0.82)/3\n", - "#Average value for GaAs\n", - "Vgs=(1.1+1.2+1.33)/3\n", - "kge=0.3\n", - "ksi=0.7\n", - "kgaas=1.2\n", - "print \"Very close correspondence between knee voltage and average voltage\"\n", - "print \"Germanium\",kge,\"V vs\",round(Vg,3),\"V\"\n", - "print \"Silicon\",ksi,\"V vs\",round(Vs,3),\"V\"\n", - "print \"GaAs\",kgaas,\"V vs\",round(Vgs,3),\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## There is a Repeatation of Example 1.2" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2(a)" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dc resistance= 250.0 ohms\n" - ] - } - ], - "source": [ - "Id=2*(10**(-3)) #in ampere\n", - "Vd=0.5 #in volts\n", - "rd=Vd/Id\n", - "print \"dc resistance=\",rd,\"ohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2(b)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dc resistance 40.0 ohms\n" - ] - } - ], - "source": [ - "Id=20*(10**(-3)) #in ampere\n", - "Vd=0.8 #in volts\n", - "rd=Vd/Id\n", - "print \"dc resistance=\",rd,\"ohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2(c)" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dc resistance= 10.0 Mohms\n" - ] - } - ], - "source": [ - "#Id=-Is\n", - "Id=1*(10**(-6)) #in ampere\n", - "Vd=-10 #in volts\n", - "rd=abs(Vd)/Id\n", - "rd=rd/(10**(6))\n", - "print \"dc resistance=\",rd,\"Mohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.3(a)" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ac resistance= 27.5 ohms\n" - ] - } - ], - "source": [ - "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n", - "Id1=4*(10**(-3)) #IN ampere\n", - "Id2=0 #IN ampere\n", - "Vd1=0.76 #IN VOLTS\n", - "Vd2=0.65 #IN VOLTS \n", - "X=Id1-Id2\n", - "Y=Vd1-Vd2\n", - "rd=Y/X\n", - "print \"ac resistance=\",rd,\"ohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.3(b)" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ac resistance= 2.0 ohms\n" - ] - } - ], - "source": [ - "# drawing tangent at Id=2mA and choosing any random points n the tangent to gwt two set of values of Id and Vd\n", - "Id1=30*(10**(-3)) #IN ampere\n", - "Id2=20*(10**(-3)) #IN ampere\n", - "Vd1=0.80 #IN VOLTS\n", - "Vd2=0.78 #IN VOLTS \n", - "X=Id1-Id2\n", - "Y=Vd1-Vd2\n", - "rd=Y/X\n", - "print \"ac resistance=\",rd,\"ohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.3(c)" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Dc resistance= 350.0 ohms exceeds ac resistance= 27.5 ohms\n", - "Dc resistance= 31.6 ohms exceeds ac resistance= 2 ohms\n" - ] - } - ], - "source": [ - "#calculating Dc resistance\n", - "#Case-1\n", - "Id1=2*(10**(-3)) #in ampere\n", - "Vd1=0.7 #in volts\n", - "Rd=Vd1/Id1\n", - "rd=27.5 #ac resistance in ohms\n", - "if Rd>rd:\n", - " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n", - "else:\n", - " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\"\n", - "\n", - "#Case-2\n", - "Id1=25*(10**(-3)) #in ampere\n", - "Vd1=0.79 #in volts\n", - "Rd=Vd1/Id1\n", - "rd=2 #ac resistance in ohms\n", - "if Rd>rd:\n", - " print \"Dc resistance=\",Rd,\"ohms exceeds ac resistance=\",rd,\"ohms\"\n", - "else:\n", - " print \"Dc resistance=\",Rd,\"ohms didnot exceeds ac resistance=\",rd,\"ohms\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.4" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "New potential across zener diode= 10.54 V\n" - ] - } - ], - "source": [ - "#Equation- change in Cvz=(Tc*Vz*(t1-t0))/100%\n", - "Tc=0.072 #unit %/celsius\n", - "t1=100 #in celsius\n", - "t0=25 #in celsius\n", - "Vz=10 #in volts\n", - "Cvz=(Tc*Vz*(t1-t0))/100\n", - "nVz=Vz+Cvz #new Vz\n", - "print \"New potential across zener diode=\",nVz,\"V\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.5" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The range of Wavelength for the frequency of Visible lightis 750 nm to 400 nm\n" - ] - } - ], - "source": [ - "#Equation wavelength(x)=c/f,where c=speed of light and f=frequency of the light\n", - "c=3*(10**(8))*(10**(9)) #in nm/s\n", - "x1=(c/(400*(10**12))) #in nm\n", - "x2=c/(750*(10**12)) #in nm\n", - "print \"The range of Wavelength for the frequency of Visible lightis\",x1,\"nm to\",x2,\"nm\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - }, - "widgets": { - "state": {}, - "version": "1.1.2" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat.ipynb b/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat.ipynb new file mode 100644 index 00000000..0cef27c9 --- /dev/null +++ b/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat.ipynb @@ -0,0 +1,1396 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 1.1 Page Number 2" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heat Flow through the surface is 17850.0 W\n", + "Temprature Gradient in flow direction -700.0 C/m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T = 100 # temperature of wall 1 in deg celcius\n", + "\n", + "t = 30 # temperature of wall 2 in deg celcius\n", + "\n", + "L = 0.1 # distance between the walls in meters\n", + "\n", + "k = 8.5 # thermal conductivity in W/mK\n", + "\n", + "A = 3 # area is meters square\n", + "\n", + "#calculation\n", + "\n", + "Q = (T-t)/(L/(k*A)) # heat flow rate in (W)\n", + "\n", + "tempgrad = (-1*Q)/(k*A) # temperature gradient in celcius/meter\n", + "\n", + "# Result\n", + "\n", + "print(\"Heat Flow through the surface is\",Q,\"W\")\n", + "\n", + "print(\"Temprature Gradient in flow direction\",tempgrad,\"C/m\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.2 Page Number 6" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Convective heat transfer rate 1500.0 W\n", + "Resistance 0.08 C/W\n", + "Temprature Gradient along y direction -3000.0 C/m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T = 160 # temperature of wall 1 in deg celcius\n", + "\n", + "t = 40 # temperature of wall 2 in deg celcius\n", + "\n", + "k = 1 # thermal conductivity in W/mK\n", + "\n", + "h = 25 # Convective heat transfer coefficient W/m2K\n", + "\n", + "A = 0.5 # area is meters square\n", + "\n", + "#calculation\n", + "\n", + "Q = h*A*(T-t) # heat tranfer by convection (W)\n", + "\n", + "r = 1/(h*A) # resistance (C/W)\n", + "\n", + "tempgrad = (-1*Q)/(k*A) # temperature gradient in celcius/meter along y\n", + "\n", + "# Result\n", + "\n", + "print(\"Convective heat transfer rate \",Q,\"W\")\n", + "\n", + "print(\"Resistance\",r,\"C/W\")\n", + "\n", + "print(\"Temprature Gradient along y direction\",tempgrad,\"C/m\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.3 Page number 7" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heat Flow through the surface is 2171.37 W\n", + "Resistance 0.0783 K/W\n", + "Equivalent thermal coefficient 6.3864 W/m2K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T = 473 # temperature of wall 1 kelvin\n", + "\n", + "t = 303 # temperature of wall 2 in kelvin\n", + "\n", + "sigma = 5.67*10**-8 # Stefen-Boltzmann constant\n", + "\n", + "F = 0.46 # emmissivity \n", + "\n", + "A = 2 # area is meters sq\n", + "\n", + "#calculation\n", + "\n", + "Q = F*sigma*A*(T**4-t**4) # heat exchange in (W)\n", + "\n", + "R = (T-t)/Q # Resistance in (K/W)\n", + "\n", + "hr = 1/(R*A) # equivalent thermal coefficient W/m2K\n", + "\n", + "# Result\n", + "\n", + "print(\"Heat Flow through the surface is\",round(Q,2),\"W\")\n", + "\n", + "print(\"Resistance\",round(R,4),\"K/W\")\n", + "\n", + "print(\"Equivalent thermal coefficient\",round(hr,4),\"W/m2K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.4 Page number 8" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heat Received 7092.23 W\n", + "T2 = 368.479 K\n", + "Temprature on other side of the wall 263.3 K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "Tinf1 = 500 # temperature of wall 1 Kelvin\n", + "\n", + "T1 = 400 # temperature of wall 2 in Kelvin\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 50 # Convective heat transfer coefficient W/m2K\n", + "\n", + "k = 45 # thermal conductivity in W/mK\n", + "\n", + "L = 0.2 # slab thickness in meters\n", + "\n", + "#calculation\n", + "\n", + "Q = sigma*((Tinf1/100)**4 - (T1/100)**4)+ h*(Tinf1-T1) # heat received (W)\n", + "\n", + "dT = Q*(L/k) # temp gradient (K)\n", + "\n", + "T2 = T1-dT #\n", + "\n", + "Tinf2 = 263.3 # temperature on the other side of the wall using trial and error\n", + "\n", + "# Result\n", + "\n", + "print(\"Heat Received \",round(Q,3),\"W\")\n", + "\n", + "print(\"T2 = \",round(T2,3),\"K\")\n", + "\n", + "print(\"Temprature on other side of the wall\",round(Tinf2,3),\"K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.5 Page number " + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rate of change of temperature 0.03984 C/s\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T1 = 400 # temperature of wall 1 Kelvin\n", + "\n", + "T2 = 100 # temperature of wall 2 in Kelvin\n", + "\n", + "sigma = 5.67*10**-8 # Stefen-Boltzmann constant\n", + "\n", + "h = 200 # Convective heat transfer coefficient W/m2K\n", + "\n", + "q = 1.5*10**6 # heat generated in W/m3\n", + "\n", + "H = 0.3 # height in meters\n", + "\n", + "r = 0.15 # radius in meters\n", + "\n", + "rho = 19000 # density in kg/m3\n", + "\n", + "cp = 118 # specific heat capacity in kJ/kgK\n", + "\n", + "#calculation\n", + "\n", + "Sa = 2*3.14*r*H+2*3.14*r**2 # Surface area in meters sq\n", + "\n", + "Hc = 3.14*r**2*H*rho*cp # heat capacity in J/deg C\n", + "\n", + "Hg = 3.14*r**2*H*q # Heat generated in W\n", + "\n", + "Hcon = h*Sa*(T1-T2) # convective heat transfer in W\n", + "\n", + "Hrad = sigma*Sa*((T1+273)**4 - (T2+273)**4)\n", + "\n", + "Th = Hg-Hcon-Hrad\n", + "\n", + "dTbydt = Th/Hc\n", + "\n", + "# Result\n", + "\n", + "print(\"Rate of change of temperature \",round(dTbydt,5),\"C/s\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.6 Page number 11" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "BTU/hrftF = 1.7322 W/mC\n", + "BTU/hrft2F = 5.6831 W/m2C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "J = 9.47*10**-4 # Joule to BTU conversion\n", + "\n", + "m = 39.37 # meter to inch conversion\n", + "\n", + "kg = 2.2046 # kg to lb conversion\n", + "\n", + "C = 9/5 # Celcius to Farhenight\n", + "\n", + "# Calculation\n", + "\n", + "BTU = 1/J # in Joule\n", + "\n", + "ft = 12/m # in feet\n", + "\n", + "a = (BTU/(3600*ft*(5/9))) # in BTU/hrftF\n", + "\n", + "print(\"BTU/hrftF = \",round(a,4),\"W/mC\")\n", + "\n", + "b = (BTU/(3600*ft**2*(5/9))) # in BTU/hrftF\n", + "\n", + "print(\"BTU/hrft2F = \",round(b,4),\"W/m2C\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 1 page Number 11" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Temprature gradient along surface -1111.7 C/m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T1 = 200 # temperature of wall 1 Kelvin\n", + "\n", + "T2 = 60 # temperature of wall 2 in Kelvin\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 80 # Convective heat transfer coefficient W/m2K\n", + "\n", + "k = 12 # thermal conductivity in W/mK\n", + "\n", + "#L = 0.2 # slab thickness in meters\n", + "\n", + "#calculation\n", + "\n", + "Q = sigma*(((T1+273)/100)**4 - ((T2+273)/100)**4)+ h*(T1-T2) # heat received (W)\n", + "\n", + "dTbydx = Q/(-1*k) # temp gradient (K)\n", + "\n", + "print(\"Temprature gradient along surface\",round(dTbydx,1),\"C/m\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 2 Page number 12" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Temprature only conduction and convection 682.174 C\n", + "Temprature only conduction and radiation 1139.148 C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "dTbydx = -9000 # temperature gradient \n", + "\n", + "T2 = 30 # temperature of wall 2 in C\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "k = -25 # Convective heat transfer coefficient W/mK\n", + "\n", + "h = 345 # thermal conductivity in W/m2K\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "#calculation\n", + "\n", + "#only conduction and convection\n", + "\n", + "T11 = k*A*dTbydx/(h*A) + T2\n", + "\n", + "#only conduction and radiation\n", + "\n", + "T12 = (((k*A*dTbydx/(sigma)) + ((T2+273)/100)**4)*100**4)**(1/4)-273\n", + "\n", + "# Result\n", + "\n", + "print(\"Temprature only conduction and convection \",round(T11,3),\"C\")\n", + "\n", + "print(\"Temprature only conduction and radiation \",round(T12,3),\"C\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem number 3 Page number 12" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wall surface temperature 330.4 K\n", + "Heat Generated 2252.765 W/m2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "Qc = 2250 # heat conducted in W/m2\n", + "\n", + "T1 = 303 # temperature of wall 2 in C\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 75 # thermal conductivity in W/m2K\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "#calculation\n", + "\n", + "# taking the approximate value from table 330.4\n", + "\n", + "Tapprox = 330.4\n", + "\n", + "Q = h*(Tapprox-T1)+sigma*((Tapprox/100)**4-(T1/100)**4)\n", + "\n", + "# Result\n", + "\n", + "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", + "\n", + "print(\"Heat Generated \",round(Q,3),\"W/m2\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 4 page number 13" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wall surface temperature 277.75 K\n", + "Heat Generated 65.479 W\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "Hc = 65.5 # heat conducted in W/m\n", + "\n", + "T1 = 263 # temperature of wall in K\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 4.35 # thermal conductivity in W/m2K\n", + "\n", + "r = 0.08 # area in meters \n", + "\n", + "#calculation\n", + "\n", + "# taking the approximate value from table 277.75 K\n", + "\n", + "Tapprox = 277.75\n", + "\n", + "Q = h*3.14*r*2*(Tapprox-T1)+sigma*2*3.14*r*((Tapprox/100)**4-(T1/100)**4)\n", + "\n", + "# Result\n", + "\n", + "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", + "\n", + "print(\"Heat Generated \",round(Q,3),\"W\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 5 Page number 14" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wall surface temperature 386.1 K\n", + "Heat Generated 449.65 W\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "Hc = 450 # heat conducted in W/m\n", + "\n", + "T1 = 396.4 # temperature of wall in K\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 1.5 # thermal conductivity in W/m2K\n", + "\n", + "r = 0.08 # area in meters \n", + "\n", + "A = 4*3.14*0.48**2 # area in meters sq\n", + "\n", + "#calculation\n", + "\n", + "# taking the approximate value from table 386.1 K\n", + "\n", + "Tapprox = 386.1\n", + "\n", + "Q = h*A*(T1-Tapprox)+sigma*A*((T1/100)**4-(Tapprox/100)**4)\n", + "\n", + "# Result\n", + "\n", + "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", + "\n", + "print(\"Heat Generated \",round(Q,3),\"W\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 6 Page number 14" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heat Capacity 1000.0 J/C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "dTbydt = 0.5 # Temperature transition in C/s\n", + "\n", + "Qr = 4000 # Heat Received in J/s\n", + "\n", + "Qc = 5200 # Heat Convection in J/s\n", + "\n", + "qdot = 1700 # Heat generated in J/s\n", + "\n", + "#calculation\n", + "\n", + "HeatCapacity = (Qr-Qc+qdot)/dTbydt\n", + "\n", + "# Result\n", + "\n", + "print(\"Heat Capacity \",round(HeatCapacity,3),\"J/C\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 7 page number 15" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Time rate of temperature change 0.1 C/s\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "Q = 240 # Heat Received in J/s\n", + "\n", + "qdot = 100000 # Heat generated in J/m3/s\n", + "\n", + "rho = 2500 # density in kg/m3\n", + "\n", + "cp = 0.52*10**3 # heat capacity in kJ/KgK\n", + "\n", + "a = 0.2 # side of the cube in meters\n", + "\n", + "#calculation\n", + "\n", + "V = a**3\n", + "\n", + "dTbydt = (Q+qdot*V)/(rho*V*cp)\n", + "\n", + "# Result\n", + "\n", + "print(\"Time rate of temperature change \",round(dTbydt,3),\"C/s\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 8 Page Number 15 " + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Heat Convected 1309.5 W/m2\n", + "Heat Received 1303.428 W/m2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T1 = 160 # heat conducted in W/m\n", + "\n", + "T2 = 30 # temperature of wall in K\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 45 # thermal conductivity in W/m2K\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "#calculation\n", + "\n", + "# taking the approximate value from table 332 K\n", + "\n", + "Tapprox = 332.1 \n", + "\n", + "Hc = h*A*(Tapprox-(273+T2)) # Heat Convected in W/m2\n", + "\n", + "Hr = sigma*A*(((T1+273)/100)**4-(Tapprox/100)**4) # Heat received in W/m2\n", + "\n", + "# Result\n", + "\n", + "print(\"Heat Convected \",round(Hc,3),\"W/m2\")\n", + "\n", + "print(\"Heat Received \",round(Hr,3),\"W/m2\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 9 Page number 16" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Heat loss case 1 150.6 W\n", + "Total Heat loss case 2 81.9 W\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T1 = 37 # temperature of body in C\n", + "\n", + "T21 = 26 # temperature of air in C\n", + "\n", + "T22 = 5 # temperature of walls in room in C\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 6 # Convective heat transfer coefficient W/m2K\n", + "\n", + "A = 0.6 # area in meters sq\n", + "\n", + "#calculation\n", + "\n", + "Hc = h*A*(T1-T21) # Heat Convected in W/m2\n", + "\n", + "Hr1 = sigma*A*(((T1+273)/100)**4-((T22+273)/100)**4) # Heat received in W/m2\n", + "\n", + "Ht1 = Hr1+Hc\n", + "\n", + "# calculate when temperature is 26C\n", + "\n", + "Hr2 = sigma*A*(((T1+273)/100)**4 - ((T21+273)/100)**4) # Heat received in W/m2\n", + "\n", + "Ht2 = Hc+Hr2\n", + "\n", + "print(\"Total Heat loss case 1\",round(Ht1,1),\"W\")\n", + "\n", + "print(\"Total Heat loss case 2\",round(Ht2,1),\"W\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 10 Page number 16" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Net heat Gain 291.1 W\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "\n", + "T1 = 37 # temperature of body in C\n", + "\n", + "T21 = 650 # temperature of air in C\n", + "\n", + "T22 = 5 # temperature of walls in room in C\n", + "\n", + "sigma = 5.67 # Stefen-Boltzmann constant\n", + "\n", + "h = 6 # Convective heat transfer coefficient W/m2K\n", + "\n", + "A = 0.6 # area in meters sq\n", + "\n", + "F = 0.01 # fraction of radiation \n", + "\n", + "#calculation\n", + "\n", + "# Heat loss by convection in W\n", + "\n", + "Hc = h*A*(T1-T22)\n", + "\n", + "# Heat Gain by radiation\n", + "\n", + "Hr = sigma*F*(((T21+273)/100)**4 - ((T1+273)/100)**4) # Heat received in W/m2\n", + "\n", + "Hnet = Hr-Hc\n", + "\n", + "print(\"Net heat Gain\",round(Hnet,1),\"W\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 11 Page number 16" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Equilibrium Temperature = 960.01 K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "Q = 1500 # heat dissipation in W\n", + "\n", + "sigma = 5.67 # stefan-Boltzmann constant\n", + "\n", + "T2 = 288 # temperature in K\n", + "\n", + "r = 0.04 # radius in meters\n", + "\n", + "H = 0.25 # height in meters\n", + "\n", + "T1 = ((Q/(sigma*3.14*r*H)+(288/100)**4)*100**4)**(1/4)\n", + "\n", + "print(\"Equilibrium Temperature = \",round(T1,2),\"K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem number 12 Page number 17" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Equilibrium Temperature = 62.0 C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "Hr = 800 # Heat Rate in W/m2\n", + "\n", + "h1 = 10 # convective heat transfer rate on back of plate in W/m2K\n", + "\n", + "h2 = 15 # convective heat transfer rate on front of plate in W/m2K\n", + "\n", + "T2 = 30 # temperature on both sides of the plate\n", + "\n", + "T = (Hr+h1*30+h2*30)/25\n", + "\n", + "print(\"Equilibrium Temperature = \",round(T,2),\"C\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem number 13 Page number 17" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "temperature of the plate 784.57 K\n", + "heat transfer with sheet 19668.31 W\n", + "heat transfer without sheet 39336.61 W\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "T1 = 650 # temperature from one side of the source in C\n", + "\n", + "T2 = 150 # temperature on other side of the surface in C\n", + "\n", + "sigma = 5.67 # stefan-boltzmann constant\n", + "\n", + "T = (((((T1+273)/100)**4 + ((T2+273)/100)**4)/2)*100**4)**(1/4)\n", + "\n", + "print(\"temperature of the plate\",round(T,2),\"K\")\n", + "\n", + "Q1 = sigma*(((T1+273)/100)**4 - (T/100)**4)\n", + "\n", + "print(\"heat transfer with sheet\",round(Q1,2),\"W\")\n", + "\n", + "Q2 = sigma*(((T1+273)/100)**4 - ((T2+273)/100)**4)\n", + "\n", + "print(\"heat transfer without sheet\",round(Q2,2),\"W\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 14 Page number 18" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "COnvective heat trasnfer rate 375.0 W/m2K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "Tair = 120 # temperature of air in C\n", + "\n", + "T1 = 42 # temperature of plate 1 in C\n", + "\n", + "T2 = 30 # temperature of plate 2 in C\n", + "\n", + "L = 0.01 # length of the slab in meters\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "k = 22.5 # thermal conductivity in W/mK\n", + "\n", + "# Calculation\n", + "\n", + "Q = (T1-T2)/(L/(k*A))\n", + "\n", + "Tnew = T1+6\n", + "\n", + "h = Q/(A*(Tair-Tnew))\n", + "\n", + "print(\"COnvective heat trasnfer rate\",round(h,2),\"W/m2K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 15 Page number 19" + ] + }, + { + "cell_type": "code", + "execution_count": 87, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Efficiency of the collector when temperature is 32 deg C 47.5 %\n", + "Efficiency of the collector when temperature is 45 deg C 75.62 %\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "T1 = 60 # temperature of the tube in C\n", + "\n", + "T2 = 32 # temperature of air in C\n", + "\n", + "h = 15 # convective heat transfer in W/m2K\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "Qf = 800 # heat flux in W/m2\n", + "\n", + "Tnew = 45 # new temperature in C\n", + "\n", + "# Calculation\n", + "\n", + "Q = h*A*(T1-T2) # heat transfer in W\n", + "\n", + "eff = ((Qf-Q)/Qf)*100\n", + "\n", + "print(\"Efficiency of the collector when temperature is 32 deg C\",round(eff,2),\"%\")\n", + "\n", + "# Heat lost by convection when T = 45 C\n", + "\n", + "Q2 = h*A*(Tnew-T2) # heat transfer in W\n", + "\n", + "eff1 = ((Qf-Q2)/Qf)*100 \n", + "\n", + "print(\"Efficiency of the collector when temperature is 45 deg C\",round(eff1,2),\"%\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 16 Page Number 19" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Temperature of the air 428.89 C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable declaration\n", + "\n", + "Tg = 40 # temperature of the glass plate in C\n", + "\n", + "dT = 5 # temperature graditent in C\n", + "\n", + "L = 0.001 # length in meters\n", + "\n", + "k = 1.4 # conductive heat transfer coefficient in W/mK\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "h = 18 # convective heat trasnfer coefficient in W/m2K\n", + "\n", + "# Calculation\n", + "\n", + "Q = dT/(L/(k*A))\n", + "\n", + "Tair = (Q/h)+ Tg\n", + "\n", + "print(\"Temperature of the air\",round(Tair,2),\"C\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 17 Page number 20" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Temperature gradient in the solid -631.58 C/m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "h = 30 # Convective heat transfer coefficient in W/m2K\n", + "\n", + "k = 9.5 # conductive heat trasnfer coefficient in W/mK\n", + "\n", + "T1 = 260 # temperature of the surface in C\n", + "\n", + "T2 = 60 # temperature of the air in C\n", + "\n", + "tempgrad = (h/k)*(T2-T1)\n", + "\n", + "print(\"Temperature gradient in the solid\",round(tempgrad,2),\"C/m\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 18 Page number 20" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Steady state temperature of plate 313.33 K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "h1 = 100 # convective heat transfer coeffcient in W/m2K\n", + "\n", + "h2 = 15 # convective heat transfer coeffcient in W/m2K\n", + "\n", + "# solving by trial and error we get T1 = 313.33 K\n", + "\n", + "T1 = 313.33 \n", + "\n", + "print(\"Steady state temperature of plate\",round(T1,2),\"K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 19 Page number 21" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Surface temperature 674.39 K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "k = -22.5 # conductive heat trasnfer coefficient in W/mK\n", + "\n", + "tempgrad = -500 # temperature gradient in C/m\n", + "\n", + "sigma = 5.67 # stefan-boltzmann constant\n", + "\n", + "Ts = 303 # temperatre of surroundings in K\n", + "\n", + "# Calculation\n", + "\n", + "T2 = ((((k*tempgrad)/sigma)+(Ts/100)**4)*100**4)**(1/4)\n", + "\n", + "print(\"Surface temperature\",round(T2,2),\"K\")\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 20 Page number 21" + ] + }, + { + "cell_type": "code", + "execution_count": 92, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Surface temperatrue 230.2 K\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# variable declaration \n", + "\n", + "Hc = 2000 # heat generated in W\n", + "\n", + "r = 1 # radius in meters\n", + "\n", + "sigma = 5.67 # stefan boltzmann constant\n", + "\n", + "T2 = 0 # temperate of space in K\n", + "\n", + "# Calculation \n", + "\n", + "T = ((Hc/(4*3.14*r**2*sigma))*100**4)**(1/4)\n", + "\n", + "print(\"Surface temperatrue\",round(T,2),\"K\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Problem 21 page Number 22" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Temperature drop through the wall 1.33 C\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "# Variable Declaration\n", + "\n", + "Q = 10 # heat flux in W/m2\n", + "\n", + "A = 1 # area in meters sq\n", + "\n", + "k = 1.5 # thermal cnductivity in W/mK\n", + "\n", + "t = 0.2 # wall thockness in m\n", + "\n", + "# Calculation\n", + "\n", + "dT = (Q*t)/(k*A)\n", + "\n", + "print(\"Temperature drop through the wall\",round(dT,2),\"C\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [default]", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.2" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat_Trasnfer.ipynb b/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat_Trasnfer.ipynb deleted file mode 100644 index 0cef27c9..00000000 --- a/sample_notebooks/RahulJoshi/Chapter_1_An_Overview_of_Heat_Trasnfer.ipynb +++ /dev/null @@ -1,1396 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 1.1 Page Number 2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Heat Flow through the surface is 17850.0 W\n", - "Temprature Gradient in flow direction -700.0 C/m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T = 100 # temperature of wall 1 in deg celcius\n", - "\n", - "t = 30 # temperature of wall 2 in deg celcius\n", - "\n", - "L = 0.1 # distance between the walls in meters\n", - "\n", - "k = 8.5 # thermal conductivity in W/mK\n", - "\n", - "A = 3 # area is meters square\n", - "\n", - "#calculation\n", - "\n", - "Q = (T-t)/(L/(k*A)) # heat flow rate in (W)\n", - "\n", - "tempgrad = (-1*Q)/(k*A) # temperature gradient in celcius/meter\n", - "\n", - "# Result\n", - "\n", - "print(\"Heat Flow through the surface is\",Q,\"W\")\n", - "\n", - "print(\"Temprature Gradient in flow direction\",tempgrad,\"C/m\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.2 Page Number 6" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Convective heat transfer rate 1500.0 W\n", - "Resistance 0.08 C/W\n", - "Temprature Gradient along y direction -3000.0 C/m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T = 160 # temperature of wall 1 in deg celcius\n", - "\n", - "t = 40 # temperature of wall 2 in deg celcius\n", - "\n", - "k = 1 # thermal conductivity in W/mK\n", - "\n", - "h = 25 # Convective heat transfer coefficient W/m2K\n", - "\n", - "A = 0.5 # area is meters square\n", - "\n", - "#calculation\n", - "\n", - "Q = h*A*(T-t) # heat tranfer by convection (W)\n", - "\n", - "r = 1/(h*A) # resistance (C/W)\n", - "\n", - "tempgrad = (-1*Q)/(k*A) # temperature gradient in celcius/meter along y\n", - "\n", - "# Result\n", - "\n", - "print(\"Convective heat transfer rate \",Q,\"W\")\n", - "\n", - "print(\"Resistance\",r,\"C/W\")\n", - "\n", - "print(\"Temprature Gradient along y direction\",tempgrad,\"C/m\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.3 Page number 7" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Heat Flow through the surface is 2171.37 W\n", - "Resistance 0.0783 K/W\n", - "Equivalent thermal coefficient 6.3864 W/m2K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T = 473 # temperature of wall 1 kelvin\n", - "\n", - "t = 303 # temperature of wall 2 in kelvin\n", - "\n", - "sigma = 5.67*10**-8 # Stefen-Boltzmann constant\n", - "\n", - "F = 0.46 # emmissivity \n", - "\n", - "A = 2 # area is meters sq\n", - "\n", - "#calculation\n", - "\n", - "Q = F*sigma*A*(T**4-t**4) # heat exchange in (W)\n", - "\n", - "R = (T-t)/Q # Resistance in (K/W)\n", - "\n", - "hr = 1/(R*A) # equivalent thermal coefficient W/m2K\n", - "\n", - "# Result\n", - "\n", - "print(\"Heat Flow through the surface is\",round(Q,2),\"W\")\n", - "\n", - "print(\"Resistance\",round(R,4),\"K/W\")\n", - "\n", - "print(\"Equivalent thermal coefficient\",round(hr,4),\"W/m2K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.4 Page number 8" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Heat Received 7092.23 W\n", - "T2 = 368.479 K\n", - "Temprature on other side of the wall 263.3 K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "Tinf1 = 500 # temperature of wall 1 Kelvin\n", - "\n", - "T1 = 400 # temperature of wall 2 in Kelvin\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 50 # Convective heat transfer coefficient W/m2K\n", - "\n", - "k = 45 # thermal conductivity in W/mK\n", - "\n", - "L = 0.2 # slab thickness in meters\n", - "\n", - "#calculation\n", - "\n", - "Q = sigma*((Tinf1/100)**4 - (T1/100)**4)+ h*(Tinf1-T1) # heat received (W)\n", - "\n", - "dT = Q*(L/k) # temp gradient (K)\n", - "\n", - "T2 = T1-dT #\n", - "\n", - "Tinf2 = 263.3 # temperature on the other side of the wall using trial and error\n", - "\n", - "# Result\n", - "\n", - "print(\"Heat Received \",round(Q,3),\"W\")\n", - "\n", - "print(\"T2 = \",round(T2,3),\"K\")\n", - "\n", - "print(\"Temprature on other side of the wall\",round(Tinf2,3),\"K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.5 Page number " - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rate of change of temperature 0.03984 C/s\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T1 = 400 # temperature of wall 1 Kelvin\n", - "\n", - "T2 = 100 # temperature of wall 2 in Kelvin\n", - "\n", - "sigma = 5.67*10**-8 # Stefen-Boltzmann constant\n", - "\n", - "h = 200 # Convective heat transfer coefficient W/m2K\n", - "\n", - "q = 1.5*10**6 # heat generated in W/m3\n", - "\n", - "H = 0.3 # height in meters\n", - "\n", - "r = 0.15 # radius in meters\n", - "\n", - "rho = 19000 # density in kg/m3\n", - "\n", - "cp = 118 # specific heat capacity in kJ/kgK\n", - "\n", - "#calculation\n", - "\n", - "Sa = 2*3.14*r*H+2*3.14*r**2 # Surface area in meters sq\n", - "\n", - "Hc = 3.14*r**2*H*rho*cp # heat capacity in J/deg C\n", - "\n", - "Hg = 3.14*r**2*H*q # Heat generated in W\n", - "\n", - "Hcon = h*Sa*(T1-T2) # convective heat transfer in W\n", - "\n", - "Hrad = sigma*Sa*((T1+273)**4 - (T2+273)**4)\n", - "\n", - "Th = Hg-Hcon-Hrad\n", - "\n", - "dTbydt = Th/Hc\n", - "\n", - "# Result\n", - "\n", - "print(\"Rate of change of temperature \",round(dTbydt,5),\"C/s\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.6 Page number 11" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "BTU/hrftF = 1.7322 W/mC\n", - "BTU/hrft2F = 5.6831 W/m2C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "J = 9.47*10**-4 # Joule to BTU conversion\n", - "\n", - "m = 39.37 # meter to inch conversion\n", - "\n", - "kg = 2.2046 # kg to lb conversion\n", - "\n", - "C = 9/5 # Celcius to Farhenight\n", - "\n", - "# Calculation\n", - "\n", - "BTU = 1/J # in Joule\n", - "\n", - "ft = 12/m # in feet\n", - "\n", - "a = (BTU/(3600*ft*(5/9))) # in BTU/hrftF\n", - "\n", - "print(\"BTU/hrftF = \",round(a,4),\"W/mC\")\n", - "\n", - "b = (BTU/(3600*ft**2*(5/9))) # in BTU/hrftF\n", - "\n", - "print(\"BTU/hrft2F = \",round(b,4),\"W/m2C\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 1 page Number 11" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Temprature gradient along surface -1111.7 C/m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T1 = 200 # temperature of wall 1 Kelvin\n", - "\n", - "T2 = 60 # temperature of wall 2 in Kelvin\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 80 # Convective heat transfer coefficient W/m2K\n", - "\n", - "k = 12 # thermal conductivity in W/mK\n", - "\n", - "#L = 0.2 # slab thickness in meters\n", - "\n", - "#calculation\n", - "\n", - "Q = sigma*(((T1+273)/100)**4 - ((T2+273)/100)**4)+ h*(T1-T2) # heat received (W)\n", - "\n", - "dTbydx = Q/(-1*k) # temp gradient (K)\n", - "\n", - "print(\"Temprature gradient along surface\",round(dTbydx,1),\"C/m\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 2 Page number 12" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Temprature only conduction and convection 682.174 C\n", - "Temprature only conduction and radiation 1139.148 C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "dTbydx = -9000 # temperature gradient \n", - "\n", - "T2 = 30 # temperature of wall 2 in C\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "k = -25 # Convective heat transfer coefficient W/mK\n", - "\n", - "h = 345 # thermal conductivity in W/m2K\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "#calculation\n", - "\n", - "#only conduction and convection\n", - "\n", - "T11 = k*A*dTbydx/(h*A) + T2\n", - "\n", - "#only conduction and radiation\n", - "\n", - "T12 = (((k*A*dTbydx/(sigma)) + ((T2+273)/100)**4)*100**4)**(1/4)-273\n", - "\n", - "# Result\n", - "\n", - "print(\"Temprature only conduction and convection \",round(T11,3),\"C\")\n", - "\n", - "print(\"Temprature only conduction and radiation \",round(T12,3),\"C\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem number 3 Page number 12" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wall surface temperature 330.4 K\n", - "Heat Generated 2252.765 W/m2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "Qc = 2250 # heat conducted in W/m2\n", - "\n", - "T1 = 303 # temperature of wall 2 in C\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 75 # thermal conductivity in W/m2K\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "#calculation\n", - "\n", - "# taking the approximate value from table 330.4\n", - "\n", - "Tapprox = 330.4\n", - "\n", - "Q = h*(Tapprox-T1)+sigma*((Tapprox/100)**4-(T1/100)**4)\n", - "\n", - "# Result\n", - "\n", - "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", - "\n", - "print(\"Heat Generated \",round(Q,3),\"W/m2\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 4 page number 13" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wall surface temperature 277.75 K\n", - "Heat Generated 65.479 W\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "Hc = 65.5 # heat conducted in W/m\n", - "\n", - "T1 = 263 # temperature of wall in K\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 4.35 # thermal conductivity in W/m2K\n", - "\n", - "r = 0.08 # area in meters \n", - "\n", - "#calculation\n", - "\n", - "# taking the approximate value from table 277.75 K\n", - "\n", - "Tapprox = 277.75\n", - "\n", - "Q = h*3.14*r*2*(Tapprox-T1)+sigma*2*3.14*r*((Tapprox/100)**4-(T1/100)**4)\n", - "\n", - "# Result\n", - "\n", - "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", - "\n", - "print(\"Heat Generated \",round(Q,3),\"W\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 5 Page number 14" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wall surface temperature 386.1 K\n", - "Heat Generated 449.65 W\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "Hc = 450 # heat conducted in W/m\n", - "\n", - "T1 = 396.4 # temperature of wall in K\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 1.5 # thermal conductivity in W/m2K\n", - "\n", - "r = 0.08 # area in meters \n", - "\n", - "A = 4*3.14*0.48**2 # area in meters sq\n", - "\n", - "#calculation\n", - "\n", - "# taking the approximate value from table 386.1 K\n", - "\n", - "Tapprox = 386.1\n", - "\n", - "Q = h*A*(T1-Tapprox)+sigma*A*((T1/100)**4-(Tapprox/100)**4)\n", - "\n", - "# Result\n", - "\n", - "print(\"Wall surface temperature \",round(Tapprox,3),\"K\")\n", - "\n", - "print(\"Heat Generated \",round(Q,3),\"W\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 6 Page number 14" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Heat Capacity 1000.0 J/C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "dTbydt = 0.5 # Temperature transition in C/s\n", - "\n", - "Qr = 4000 # Heat Received in J/s\n", - "\n", - "Qc = 5200 # Heat Convection in J/s\n", - "\n", - "qdot = 1700 # Heat generated in J/s\n", - "\n", - "#calculation\n", - "\n", - "HeatCapacity = (Qr-Qc+qdot)/dTbydt\n", - "\n", - "# Result\n", - "\n", - "print(\"Heat Capacity \",round(HeatCapacity,3),\"J/C\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 7 page number 15" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Time rate of temperature change 0.1 C/s\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "Q = 240 # Heat Received in J/s\n", - "\n", - "qdot = 100000 # Heat generated in J/m3/s\n", - "\n", - "rho = 2500 # density in kg/m3\n", - "\n", - "cp = 0.52*10**3 # heat capacity in kJ/KgK\n", - "\n", - "a = 0.2 # side of the cube in meters\n", - "\n", - "#calculation\n", - "\n", - "V = a**3\n", - "\n", - "dTbydt = (Q+qdot*V)/(rho*V*cp)\n", - "\n", - "# Result\n", - "\n", - "print(\"Time rate of temperature change \",round(dTbydt,3),\"C/s\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 8 Page Number 15 " - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Heat Convected 1309.5 W/m2\n", - "Heat Received 1303.428 W/m2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T1 = 160 # heat conducted in W/m\n", - "\n", - "T2 = 30 # temperature of wall in K\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 45 # thermal conductivity in W/m2K\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "#calculation\n", - "\n", - "# taking the approximate value from table 332 K\n", - "\n", - "Tapprox = 332.1 \n", - "\n", - "Hc = h*A*(Tapprox-(273+T2)) # Heat Convected in W/m2\n", - "\n", - "Hr = sigma*A*(((T1+273)/100)**4-(Tapprox/100)**4) # Heat received in W/m2\n", - "\n", - "# Result\n", - "\n", - "print(\"Heat Convected \",round(Hc,3),\"W/m2\")\n", - "\n", - "print(\"Heat Received \",round(Hr,3),\"W/m2\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 9 Page number 16" - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total Heat loss case 1 150.6 W\n", - "Total Heat loss case 2 81.9 W\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T1 = 37 # temperature of body in C\n", - "\n", - "T21 = 26 # temperature of air in C\n", - "\n", - "T22 = 5 # temperature of walls in room in C\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 6 # Convective heat transfer coefficient W/m2K\n", - "\n", - "A = 0.6 # area in meters sq\n", - "\n", - "#calculation\n", - "\n", - "Hc = h*A*(T1-T21) # Heat Convected in W/m2\n", - "\n", - "Hr1 = sigma*A*(((T1+273)/100)**4-((T22+273)/100)**4) # Heat received in W/m2\n", - "\n", - "Ht1 = Hr1+Hc\n", - "\n", - "# calculate when temperature is 26C\n", - "\n", - "Hr2 = sigma*A*(((T1+273)/100)**4 - ((T21+273)/100)**4) # Heat received in W/m2\n", - "\n", - "Ht2 = Hc+Hr2\n", - "\n", - "print(\"Total Heat loss case 1\",round(Ht1,1),\"W\")\n", - "\n", - "print(\"Total Heat loss case 2\",round(Ht2,1),\"W\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 10 Page number 16" - ] - }, - { - "cell_type": "code", - "execution_count": 63, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Net heat Gain 291.1 W\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "\n", - "T1 = 37 # temperature of body in C\n", - "\n", - "T21 = 650 # temperature of air in C\n", - "\n", - "T22 = 5 # temperature of walls in room in C\n", - "\n", - "sigma = 5.67 # Stefen-Boltzmann constant\n", - "\n", - "h = 6 # Convective heat transfer coefficient W/m2K\n", - "\n", - "A = 0.6 # area in meters sq\n", - "\n", - "F = 0.01 # fraction of radiation \n", - "\n", - "#calculation\n", - "\n", - "# Heat loss by convection in W\n", - "\n", - "Hc = h*A*(T1-T22)\n", - "\n", - "# Heat Gain by radiation\n", - "\n", - "Hr = sigma*F*(((T21+273)/100)**4 - ((T1+273)/100)**4) # Heat received in W/m2\n", - "\n", - "Hnet = Hr-Hc\n", - "\n", - "print(\"Net heat Gain\",round(Hnet,1),\"W\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 11 Page number 16" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Equilibrium Temperature = 960.01 K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "Q = 1500 # heat dissipation in W\n", - "\n", - "sigma = 5.67 # stefan-Boltzmann constant\n", - "\n", - "T2 = 288 # temperature in K\n", - "\n", - "r = 0.04 # radius in meters\n", - "\n", - "H = 0.25 # height in meters\n", - "\n", - "T1 = ((Q/(sigma*3.14*r*H)+(288/100)**4)*100**4)**(1/4)\n", - "\n", - "print(\"Equilibrium Temperature = \",round(T1,2),\"K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem number 12 Page number 17" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Equilibrium Temperature = 62.0 C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "Hr = 800 # Heat Rate in W/m2\n", - "\n", - "h1 = 10 # convective heat transfer rate on back of plate in W/m2K\n", - "\n", - "h2 = 15 # convective heat transfer rate on front of plate in W/m2K\n", - "\n", - "T2 = 30 # temperature on both sides of the plate\n", - "\n", - "T = (Hr+h1*30+h2*30)/25\n", - "\n", - "print(\"Equilibrium Temperature = \",round(T,2),\"C\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem number 13 Page number 17" - ] - }, - { - "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "temperature of the plate 784.57 K\n", - "heat transfer with sheet 19668.31 W\n", - "heat transfer without sheet 39336.61 W\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "T1 = 650 # temperature from one side of the source in C\n", - "\n", - "T2 = 150 # temperature on other side of the surface in C\n", - "\n", - "sigma = 5.67 # stefan-boltzmann constant\n", - "\n", - "T = (((((T1+273)/100)**4 + ((T2+273)/100)**4)/2)*100**4)**(1/4)\n", - "\n", - "print(\"temperature of the plate\",round(T,2),\"K\")\n", - "\n", - "Q1 = sigma*(((T1+273)/100)**4 - (T/100)**4)\n", - "\n", - "print(\"heat transfer with sheet\",round(Q1,2),\"W\")\n", - "\n", - "Q2 = sigma*(((T1+273)/100)**4 - ((T2+273)/100)**4)\n", - "\n", - "print(\"heat transfer without sheet\",round(Q2,2),\"W\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 14 Page number 18" - ] - }, - { - "cell_type": "code", - "execution_count": 83, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "COnvective heat trasnfer rate 375.0 W/m2K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "Tair = 120 # temperature of air in C\n", - "\n", - "T1 = 42 # temperature of plate 1 in C\n", - "\n", - "T2 = 30 # temperature of plate 2 in C\n", - "\n", - "L = 0.01 # length of the slab in meters\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "k = 22.5 # thermal conductivity in W/mK\n", - "\n", - "# Calculation\n", - "\n", - "Q = (T1-T2)/(L/(k*A))\n", - "\n", - "Tnew = T1+6\n", - "\n", - "h = Q/(A*(Tair-Tnew))\n", - "\n", - "print(\"COnvective heat trasnfer rate\",round(h,2),\"W/m2K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 15 Page number 19" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Efficiency of the collector when temperature is 32 deg C 47.5 %\n", - "Efficiency of the collector when temperature is 45 deg C 75.62 %\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "T1 = 60 # temperature of the tube in C\n", - "\n", - "T2 = 32 # temperature of air in C\n", - "\n", - "h = 15 # convective heat transfer in W/m2K\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "Qf = 800 # heat flux in W/m2\n", - "\n", - "Tnew = 45 # new temperature in C\n", - "\n", - "# Calculation\n", - "\n", - "Q = h*A*(T1-T2) # heat transfer in W\n", - "\n", - "eff = ((Qf-Q)/Qf)*100\n", - "\n", - "print(\"Efficiency of the collector when temperature is 32 deg C\",round(eff,2),\"%\")\n", - "\n", - "# Heat lost by convection when T = 45 C\n", - "\n", - "Q2 = h*A*(Tnew-T2) # heat transfer in W\n", - "\n", - "eff1 = ((Qf-Q2)/Qf)*100 \n", - "\n", - "print(\"Efficiency of the collector when temperature is 45 deg C\",round(eff1,2),\"%\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 16 Page Number 19" - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Temperature of the air 428.89 C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable declaration\n", - "\n", - "Tg = 40 # temperature of the glass plate in C\n", - "\n", - "dT = 5 # temperature graditent in C\n", - "\n", - "L = 0.001 # length in meters\n", - "\n", - "k = 1.4 # conductive heat transfer coefficient in W/mK\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "h = 18 # convective heat trasnfer coefficient in W/m2K\n", - "\n", - "# Calculation\n", - "\n", - "Q = dT/(L/(k*A))\n", - "\n", - "Tair = (Q/h)+ Tg\n", - "\n", - "print(\"Temperature of the air\",round(Tair,2),\"C\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 17 Page number 20" - ] - }, - { - "cell_type": "code", - "execution_count": 89, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Temperature gradient in the solid -631.58 C/m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "h = 30 # Convective heat transfer coefficient in W/m2K\n", - "\n", - "k = 9.5 # conductive heat trasnfer coefficient in W/mK\n", - "\n", - "T1 = 260 # temperature of the surface in C\n", - "\n", - "T2 = 60 # temperature of the air in C\n", - "\n", - "tempgrad = (h/k)*(T2-T1)\n", - "\n", - "print(\"Temperature gradient in the solid\",round(tempgrad,2),\"C/m\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 18 Page number 20" - ] - }, - { - "cell_type": "code", - "execution_count": 90, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Steady state temperature of plate 313.33 K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "h1 = 100 # convective heat transfer coeffcient in W/m2K\n", - "\n", - "h2 = 15 # convective heat transfer coeffcient in W/m2K\n", - "\n", - "# solving by trial and error we get T1 = 313.33 K\n", - "\n", - "T1 = 313.33 \n", - "\n", - "print(\"Steady state temperature of plate\",round(T1,2),\"K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 19 Page number 21" - ] - }, - { - "cell_type": "code", - "execution_count": 91, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Surface temperature 674.39 K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "k = -22.5 # conductive heat trasnfer coefficient in W/mK\n", - "\n", - "tempgrad = -500 # temperature gradient in C/m\n", - "\n", - "sigma = 5.67 # stefan-boltzmann constant\n", - "\n", - "Ts = 303 # temperatre of surroundings in K\n", - "\n", - "# Calculation\n", - "\n", - "T2 = ((((k*tempgrad)/sigma)+(Ts/100)**4)*100**4)**(1/4)\n", - "\n", - "print(\"Surface temperature\",round(T2,2),\"K\")\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 20 Page number 21" - ] - }, - { - "cell_type": "code", - "execution_count": 92, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Surface temperatrue 230.2 K\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# variable declaration \n", - "\n", - "Hc = 2000 # heat generated in W\n", - "\n", - "r = 1 # radius in meters\n", - "\n", - "sigma = 5.67 # stefan boltzmann constant\n", - "\n", - "T2 = 0 # temperate of space in K\n", - "\n", - "# Calculation \n", - "\n", - "T = ((Hc/(4*3.14*r**2*sigma))*100**4)**(1/4)\n", - "\n", - "print(\"Surface temperatrue\",round(T,2),\"K\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Problem 21 page Number 22" - ] - }, - { - "cell_type": "code", - "execution_count": 93, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Temperature drop through the wall 1.33 C\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "# Variable Declaration\n", - "\n", - "Q = 10 # heat flux in W/m2\n", - "\n", - "A = 1 # area in meters sq\n", - "\n", - "k = 1.5 # thermal cnductivity in W/mK\n", - "\n", - "t = 0.2 # wall thockness in m\n", - "\n", - "# Calculation\n", - "\n", - "dT = (Q*t)/(k*A)\n", - "\n", - "print(\"Temperature drop through the wall\",round(dT,2),\"C\")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "anaconda-cloud": {}, - "kernelspec": { - "display_name": "Python [default]", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.2" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter1.ipynb b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter1.ipynb new file mode 100755 index 00000000..af42a9cd --- /dev/null +++ b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter1.ipynb @@ -0,0 +1,993 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# chapter 1: Atomic Nucleus" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.1;pg no:2" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:2 \n", + " \n", + "\n", + "\n", + " The electric field in V/m is = 20000.0\n", + "\n", + " The force in N/C is = 20000.0\n", + "\n", + " The force on metal sphere in N is = 7.6e-05\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:2 \\n \\n\"\n", + "#Given:\n", + "v=1000# potential\n", + "d=0.05# distance\n", + "q=3.8*10**-9# charge\n", + "#solution:\n", + "e=v/d;#electric field\n", + "f=e;# force\n", + "f1=f*q;# force on metal sphere\n", + "print\"\\n The electric field in V/m is =\",e\n", + "print\"\\n The force in N/C is =\",f\n", + "print\"\\n The force on metal sphere in N is =\",f1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.2;pg no:2" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.2, Page:2 \n", + " \n", + "\n", + "The potential in V is = 80.0\n" + ] + } + ], + "source": [ + "#cal of potential\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.2, Page:2 \\n \\n\"\n", + "#Given:\n", + "energy=2*10**-6\n", + "c=2.5*10**-8# velocity of light\n", + "#solution:\n", + "v=energy/c# potential\n", + "print\"The potential in V is =\",v" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.3;pg no:3" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.3, Page:3 \n", + "\n", + "The wavelength in Angstroms is = 3.88\n", + "The photon wavelength in Angstroms is = 1242.38\n" + ] + } + ], + "source": [ + "#cal of elecrtron and photon wavelength\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.3, Page:3 \\n\"\n", + "#Given:\n", + "energy=10 #in electron volts\n", + "m=9.1*10**-31# mass of electron in kg\n", + "h=6.626*10**-34# planck's constant J.s\n", + "c=3*10**8# speed of light in m/s\n", + "#solution (a):\n", + "energy1=energy*1.6*10**-19# energy in J\n", + "p=(2*m*energy1)**0.5# momentum\n", + "wavelength=h/p*(10)**10\n", + "print\"The wavelength in Angstroms is =\",round(wavelength,2)\n", + "#solution (b):\n", + "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", + "print\"The photon wavelength in Angstroms is =\",round(wavelength1,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.4;pg no:3" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.4, Page:3 \n", + " \n", + "\n", + "The energy in eV is = 150.77\n" + ] + } + ], + "source": [ + "#cal of kinetic energy of an electron\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.4, Page:3 \\n \\n\"\n", + "#Given:\n", + "wavelength=10**-10\n", + "m=9.1*10**-31\n", + "h=6.626*10**-34\n", + "#solution:\n", + "p=h/wavelength\n", + "e=p*p/(2*m) # energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "print\"The energy in eV is =\",round(e1,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.5;pg no:3" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.5, Page:3 \n", + " \n", + "\n", + "The wavelength in 10^-5 Angstroms is = 0.66\n", + "The wavelength in 10^-5 Angstroms is = 0.65\n" + ] + } + ], + "source": [ + "#cal of wavelength of oxygen and nitrogen nucleus\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.5, Page:3 \\n \\n\"\n", + "#Given:\n", + "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", + "h=6.6262*10**-34#planck's constant in J.s\n", + "energy1=120# in Mev for oxygen\n", + "energy2=140# in MeV for nitrogen\n", + "#solution(a):\n", + "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", + "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "print\"The wavelength in 10^-5 Angstroms is =\",round(wavelength1,2)\n", + "#solution (b):\n", + "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", + "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "print\"The wavelength in 10^-5 Angstroms is =\",round(wavelength2,2)\n", + "# 1 Angstrom = 10^-10 m" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.6;pg no:3" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.6, Page:3 \n", + " \n", + "\n", + "The energy in eV is = 8275.0\n" + ] + } + ], + "source": [ + "#cal of energy of a gamma photon\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.6, Page:3 \\n \\n\"\n", + "#Given:\n", + "wavelength=1.5*10**-10\n", + "h=6.62*10**-34\n", + "c=3*10**8\n", + "#solution:\n", + "e=(h*c)/wavelength# energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "print\"The energy in eV is =\",e1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.7;pg no:4" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.7, Page:4 \n", + " \n", + "\n", + "\n", + " The threshold frequency in s^-1 is = 1.23634168427e+15\n", + "\n", + " The threshold wavelength in Angstroms is = 2426.51\n", + "\n", + " The energy of photoelectrone in eV is = 3.91\n" + ] + } + ], + "source": [ + "#cal of threshold frequency,wavelength,energy of photoelectrone\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.7, Page:4 \\n \\n\"\n", + "#Given:\n", + "E=5.12*1.6*10**-19# energy in J\n", + "h=6.626*10**-34\n", + "c=3*10**8\n", + "wavelength=200*10**-9\n", + "w=2.3# in eV\n", + "#solution:\n", + "tf=E/h# (part a)\n", + "print\"\\n The threshold frequency in s^-1 is =\",round(tf,2)\n", + "tl=c/tf*10**10# (part b)\n", + "print\"\\n The threshold wavelength in Angstroms is =\",round(tl,2)\n", + "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", + "pe=e-w\n", + "print\"\\n The energy of photoelectrone in eV is =\",round(pe,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.8;pg no:4" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.8, Page:4 \n", + " \n", + "\n", + "\n", + " The velocity of alpha particles for 1 MeV in mega m/s is = 6.94\n", + "\n", + " The velocity of alpha particles for 2 MeV in mega m/s is = 9.82\n", + "\n", + " The velocity of deuteron particles for 1 MeV in mega m/s is = 9.82\n", + "\n", + " The velocity of deuteron particles for 2 MeV in mega m/s is = 13.88\n", + "\n", + " The velocity of proton particles for 1 MeV in mega m/s is = 13.88\n", + "\n", + " The velocity of proton particles for 2 MeV in mega m/s is = 19.63\n" + ] + } + ], + "source": [ + "#cal of velocity of alpha particles,deuteron,proton\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.8, Page:4 \\n \\n\"\n", + "#Given:\n", + "e1=1 # in MeV\n", + "e2=2 # in MeV\n", + "ma=4 # in u(amu)\n", + "md=2 # in u(amu)\n", + "mp=1 # in u(amu)\n", + "# 1u = 1.6*10^-27 Kg\n", + "#solution: part a)For alpha particles\n", + "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 1 MeV in mega m/s is =\",round(v1a/10**6,2)# For 1 MeV\n", + "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 2 MeV in mega m/s is =\",round(v2a/10**6,2)# For 2 MeV\n", + "#solution: part b)For deuteron particles\n", + "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 1 MeV in mega m/s is =\",round(v1b/10**6,2) # For 1 MeV\n", + "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 2 MeV in mega m/s is =\",round(v2b/10**6,2) # For 2 MeV\n", + "#solution: part c)For proton particles\n", + "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 1 MeV in mega m/s is =\",round(v1p/10**6,2) # For 1 MeV\n", + "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 2 MeV in mega m/s is =\",round(v2p/10**6,2) # For 2 MeV" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.9;pg no:5" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.9, Page:5 \n", + " \n", + "\n", + "The energy in MeV is = 934.0\n" + ] + } + ], + "source": [ + "#cal of The energy equivalence\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.9, Page:5 \\n \\n\"\n", + "#Given:\n", + "m=1./(6.023*10**23)#mass of 1 atom in g\n", + "m1=m*10**-3#mass of 1 atom in Kg\n", + "c=3.*10**8# velocity in m/s\n", + "#solution:\n", + "e=m1*c*c; # energy in J\n", + "e1=e/(1.6*10**-13)# energy in MeV\n", + "print\"The energy in MeV is =\",round(e1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.10;pg no:5" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.10, Page:5 \n", + " \n", + "\n", + "The energy in eV is = 13.26\n" + ] + } + ], + "source": [ + "#cal of The energy of formation\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.10, Page:5 \\n \\n\"\n", + "#Given:\n", + "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", + "#solution:\n", + "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", + "print\"The energy in eV is =\",round(energy,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.11;pg no:5" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.11, Page:5 \n", + " \n", + "\n", + "\n", + " The mean binding energy of helium atom in MeV is = 7.07\n", + "\n", + " The mean binding energy of oxygen atom in MeV is = 7.98\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of helium and oxygen\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.11, Page:5 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078\n", + "mn=1.0087\n", + "ma=4.0026\n", + "mo=15.9949\n", + "Ah=4.0026 # atomic mass of helium\n", + "Ao=15.9949 # atomic mass of oxygen\n", + "#solution:\n", + "# part (a)\n", + "B1=(2*mh+2*mn-ma)*931 # in MeV\n", + "Bh=B1/Ah\n", + "print\"\\n The mean binding energy of helium atom in MeV is =\",round(Bh,2)\n", + "# part (b)\n", + "B2=(8*mh+8*mn-mo)*931 # in MeV\n", + "Bo=B2/Ao\n", + "print\"\\n The mean binding energy of oxygen atom in MeV is =\",round(Bo,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.12;pg no:6" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.12, Page:6 \n", + "\n", + "\n", + " The mean binding energy of Be atom in MeV is = 7.059\n", + "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Be atom\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.12, Page:6 \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "ABe=8.0053; # atomic mass of beryllium\n", + "#solution:\n", + "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", + "Bh=B1/ABe;\n", + "print\"\\n The mean binding energy of Be atom in MeV is =\",round(Bh,3)\n", + "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.13;pg no:6" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.13, Page:6 \n", + "\n", + "The amount of coal required in Kg is = 2.5\n" + ] + } + ], + "source": [ + "#cal of amount of coal\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.13, Page:6 \\n\"\n", + "#Given:\n", + "e=200; # in Mev\n", + "m=0.235; # weight of uranium atom in Kg\n", + "enthalpy=393.5; # in KJ/mol\n", + "Na=6.02*10**23;\n", + "#solution:\n", + "e1=e*1.6*10**-19*10**6;\n", + "atoms=Na/m;\n", + "e2=atoms*e1;#energy released in J\n", + "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", + "m2=m1/1000;# in tons\n", + "print\"The amount of coal required in Kg is =\", round(m2/1000,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.14;pg no:7" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.14, Page:7 \n", + " \n", + "\n", + "The energy release in part (a) in eV/molecule is = 2.51\n", + "The energy release in part (b) in eV/molecule is = 9.23\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.14, Page:7 \\n \\n\"\n", + "#Given:\n", + "H1=241.8; # in KJ/mol\n", + "H2=887.2; # in KJ/mol\n", + "# 1 KJ/mol = 0.0104 eV/atom\n", + "#solution: part (a)\n", + "e1=H1*0.0104;\n", + "print\"The energy release in part (a) in eV/molecule is =\",round(e1,2)\n", + "#solution: part (b)\n", + "e2=H2*0.0104;\n", + "print\"The energy release in part (b) in eV/molecule is =\",round(e2,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.15;pg no:7" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.15, Page:7 \n", + "\n", + "The energy release in part (a) in KJ/mol of carbondioxide is = 394.9\n", + "The energy release in part (b) in KJ/mol of alumina is = 1676.0\n", + "The energy release in part (c) in MJ/atom of U(235) is = 19.264\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.15, Page:7 \\n\"\n", + "#Given:\n", + "H1=4.1; # in eV/molecule\n", + "H2=17.4; # in eV/molecule\n", + "H3=200;# in MeV/atom of U\n", + "# 1 eV/atom = 96.32 KJ/mol\n", + "#solution: part (a)\n", + "e1=H1*96.32;\n", + "print\"The energy release in part (a) in KJ/mol of carbondioxide is =\",round(e1,1)\n", + "#solution: part (b)\n", + "e2=H2*96.32;\n", + "print\"The energy release in part (b) in KJ/mol of alumina is =\",round(e2,1)\n", + "#solution: part (c)\n", + "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", + "print\"The energy release in part (c) in MJ/atom of U(235) is =\",round(e3/10**6,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.16;pg no:7" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.16, Page:7 \n", + " \n", + "\n", + "\n", + " The rate of energy release in MW is= 949.25\n" + ] + } + ], + "source": [ + "#cal of The rate of energy release\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.16, Page:7 \\n \\n\"\n", + "#Given:\n", + "e=200.; #MeV/ atom of U\n", + "# 1 eV = 1.6*10^-19 J\n", + "Na=6.023*10**23;\n", + "M=0.235; # mass in Kg\n", + "#solution:\n", + "e1=e*1.6*10**-19*10**6;\n", + "A=Na/M;\n", + "e2=A*e1; # energy released in MJ/day\n", + "e3=e2/(24.*3600.);\n", + "print\"\\n The rate of energy release in MW is=\",round(e3/10**6,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.17;pg no:8" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.17, Page:8 \n", + " \n", + "\n", + "\n", + " The mass loss in 10^-27 Kg/He formed is = 0.0464\n" + ] + } + ], + "source": [ + "#cal of The mass loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.17, Page:8 \\n \\n\"\n", + "#Given:\n", + "e=26.03; # in MeV\n", + "#solution:\n", + "loss=e/931; #in atomic mass units (u)\n", + "# 1 u = 1.66*10^-27 Kg\n", + "m=(loss*1.66*10**-27)/(1*10**-27);\n", + "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",round(m,4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.18;pg no:8" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.18, Page:8 \n", + "\n", + "\n", + " The energy loss in MeV is = -4.0312\n" + ] + } + ], + "source": [ + "#cal of The energy loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.18, Page:8 \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mt=3.016049;\n", + "md=2.014102;\n", + "#solution:\n", + "m1=(mh+mt-2*md);\n", + "e=(-m1)*931; # in MeV\n", + "print\"\\n The energy loss in MeV is =\",round(-e,4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.19;pg no:8" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.19, Page:8 \n", + "\n", + "The mean binding energy of tritium atom in MeV is = 2.811\n", + "The mean binding energy of nickel atom in MeV is = 8.716\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of tritium and nickel atom\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.19, Page:8 \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mn=1.008665;\n", + "mt=3.016049; # atomic mass of Tritium\n", + "mNi=59.93528; # atomic mass of Nickel\n", + "#solution:\n", + "# part (a)\n", + "B1=(1*mh+2*mn-mt)*931; # in MeV\n", + "Bh=B1/mt;\n", + "print\"The mean binding energy of tritium atom in MeV is =\",round(Bh,3)\n", + "# part (b)\n", + "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", + "Bo=B2/mNi;\n", + "print\"The mean binding energy of nickel atom in MeV is =\",round(Bo,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.20;pg no:9" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.20, Page:9 \n", + "\n", + "The mean binding energy of Cl (35) atom in MeV is = 8.5281\n", + "The mean binding energy of Cl (37) atom in MeV is = 8.5784\n", + "The increase in mean binding energy of Cl atom in MeV is = 0.05\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Cl\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.20, Page:9 \\n\"\n", + "#Given:\n", + "mh=1.00783;\n", + "mn=1.00867;\n", + "m35=34.96885; # atomic mass of Cl (35)\n", + "m37=36.96590; # atomic mass of Cl (37)\n", + "#solution:\n", + "B1=(17*mh+18*mn-m35)*931; # in MeV\n", + "Bh=B1/m35;\n", + "print\"The mean binding energy of Cl (35) atom in MeV is =\",round(Bh,4)\n", + "B2=(17*mh+20*mn-m37)*931; # in MeV\n", + "Bo=B2/m37;\n", + "print\"The mean binding energy of Cl (37) atom in MeV is =\",round(Bo,4)\n", + "Bi=Bo-Bh;\n", + "print\"The increase in mean binding energy of Cl atom in MeV is =\",round(Bi,2)\n", + "# NOTE: The answer depends upon how much precise value you take for atomic masses." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.21;pg no:9" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.21, Page:9 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Na(22) in MeV is = 7.9236\n", + "\n", + " The mean binding energy of Na(23)in MeV is = 8.1154\n", + "\n", + " The mean binding energy of Na(24) in MeV is = 8.0717\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Na\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.21, Page:9 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "m22=21.99431;# atomic mass of Na 22\n", + "m23=22.9898;# atomic mass of Na 23\n", + "m24=23.9909;# atomic mass of Na 24\n", + "#solution:\n", + "# part (a)\n", + "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", + "Bh=B1/m22;\n", + "print\"\\n The mean binding energy of Na(22) in MeV is =\",round(Bh,4)\n", + "# part (b)\n", + "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", + "Bo=B2/m23;\n", + "print\"\\n The mean binding energy of Na(23)in MeV is =\",round(Bo,4)\n", + "# part (c)\n", + "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", + "Bs=B3/m24;\n", + "print\"\\n The mean binding energy of Na(24) in MeV is =\",round(Bs,4)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1.ipynb b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1.ipynb new file mode 100755 index 00000000..f71cb56f --- /dev/null +++ b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1.ipynb @@ -0,0 +1,1118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# chapter1: electric charge" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.1" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:3 \n", + " \n", + "\n", + "\n", + " The electric field in V/m is = 20000.0\n", + "\n", + " The force in N/C is = 20000.0\n", + "\n", + " The force on metal sphere in N is = 7.6e-05\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:3 \\n \\n\"\n", + "#Given:\n", + "v=1000# potential\n", + "d=0.05# distance\n", + "q=3.8*10**-9# charge\n", + "\n", + "#solution:\n", + "e=v/d;#electric field\n", + "f=e;# force\n", + "f1=f*q;# force on metal sphere\n", + "print\"\\n The electric field in V/m is =\",e\n", + "print\"\\n The force in N/C is =\",f\n", + "print\"\\n The force on metal sphere in N is =\",f1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.2" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.2, Page:4 \n", + " \n", + "\n", + "The potential in V is = 80.0\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.2, Page:4 \\n \\n\"\n", + "#Given:\n", + "energy=2*10**-6\n", + "c=2.5*10**-8# velocity of light\n", + "#solution:\n", + "v=energy/c# potential\n", + "print\"The potential in V is =\",v\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.3" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.3, Page:5 \n", + " \n", + "\n", + "The wavelength in Angstroms is = 3.88289589025\n", + "\n", + " The photon wavelength in Angstroms is = 9.11075e-05\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.3, Page:5 \\n \\n\"\n", + "#Given:\n", + "\n", + "energy=10 #in electron volts\n", + "m=9.1*10**-31# mass of electron in kg\n", + "h=6.626*10**-34# planck's constant J.s\n", + "c=3*10^8# speed of light in m/s\n", + "\n", + "#solution (a):\n", + "energy1=energy*1.6*10**-19# energy in J\n", + "p=(2*m*energy1)**0.5# momentum\n", + "wavelength=h/p*(10)**10\n", + "\n", + "print\"The wavelength in Angstroms is =\",wavelength\n", + "\n", + "\n", + "#solution (b):\n", + "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", + "\n", + "print\"\\n The photon wavelength in Angstroms is =\",wavelength1\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example1.4" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.4, Page:6 \n", + " \n", + "\n", + "The energy in eV is = 150.768804945\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.4, Page:6 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "wavelength=10**-10\n", + "m=9.1*10**-31\n", + "h=6.626*10**-34\n", + "\n", + "#solution:\n", + "\n", + "p=h/wavelength\n", + "e=p*p/(2*m) # energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "\n", + "print\"The energy in eV is =\",e1\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.5" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.5, Page:8 \n", + " \n", + "\n", + "\n", + " The wavelength in 10^-5 Angstroms is = 0.655671822473\n", + "\n", + " The wavelength in 10^-5 Angstroms is = 0.648946805494\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.5, Page:8 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", + "h=6.6262*10**-34#planck's constant in J.s\n", + "energy1=120# in Mev for oxygen\n", + "energy2=140# in MeV for nitrogen\n", + "\n", + "#solution(a):\n", + "\n", + "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", + "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "\n", + "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength1\n", + "\n", + "#solution (b):\n", + "\n", + "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", + "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "\n", + "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength2\n", + "\n", + "# 1 Angstrom = 10^-10 m\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example1.6" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.6, Page:9 \n", + " \n", + "\n", + "The energy in eV is = 8275.0\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.6, Page:9 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "wavelength=1.5*10**-10\n", + "h=6.62*10**-34\n", + "c=3*10**8\n", + "\n", + "#solution:\n", + "\n", + "e=(h*c)/wavelength# energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "\n", + "print\"The energy in eV is =\",e1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.7" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.7, Page:10 \n", + " \n", + "\n", + "\n", + " The threshold frequency in s^-1 is = 1.23634168427e+15\n", + "\n", + " The threshold wavelength in Angstroms is = 2426.51367187\n", + "\n", + " The energy of photoelectrone in eV is = 3.911875\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.7, Page:10 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "E=5.12*1.6*10**-19# energy in J\n", + "h=6.626*10**-34\n", + "c=3*10**8\n", + "wavelength=200*10**-9\n", + "w=2.3# in eV\n", + "\n", + "#solution:\n", + "\n", + "tf=E/h# (part a)\n", + "print\"\\n The threshold frequency in s^-1 is =\",tf\n", + "\n", + "tl=c/tf*10**10# (part b)\n", + "print\"\\n The threshold wavelength in Angstroms is =\",tl\n", + "\n", + "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", + "\n", + "pe=e-w\n", + "\n", + "print\"\\n The energy of photoelectrone in eV is =\",pe\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.8" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.8, Page:10 \n", + " \n", + "\n", + "\n", + " The velocity of alpha particles for 1 MeV in m/s is = 6941056.08394\n", + "\n", + " The velocity of alpha particles for 2 MeV in m/s is = 9816135.6511\n", + "\n", + " The velocity of deuteron particles for 1 MeV in m/s is = 9816135.6511\n", + "\n", + " The velocity of deuteron particles for 2 MeV in m/s is = 13882112.1679\n", + "\n", + " The velocity of proton particles for 1 MeV in m/s is = 13882112.1679\n", + "\n", + " The velocity of proton particles for 2 MeV in m/s is = 19632271.3022\n" + ] + } + ], + "source": [ + "#cal of velocity of alpha particles,deuteron,proton\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.8, Page:10 \\n \\n\"\n", + "#Given:\n", + "e1=1 # in MeV\n", + "e2=2 # in MeV\n", + "ma=4 # in u(amu)\n", + "md=2 # in u(amu)\n", + "mp=1 # in u(amu)\n", + "\n", + "# 1u = 1.6*10^-27 Kg\n", + "\n", + "#solution: part a)For alpha particles\n", + "\n", + "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 1 MeV in m/s is =\",v1a# For 1 MeV\n", + "\n", + "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 2 MeV in m/s is =\",v2a# For 2 MeV\n", + "\n", + "#solution: part b)For deuteron particles\n", + "\n", + "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 1 MeV in m/s is =\",v1b # For 1 MeV\n", + "\n", + "\n", + "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 2 MeV in m/s is =\",v2b # For 2 MeV\n", + "\n", + "#solution: part c)For proton particles\n", + "\n", + "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 1 MeV in m/s is =\",v1p # For 1 MeV\n", + "\n", + "\n", + "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 2 MeV in m/s is =\",v2p # For 2 MeV\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.9" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.9, Page: \n", + " \n", + "\n", + "The energy in MeV is = 933.919973435\n" + ] + } + ], + "source": [ + "#cal of The energy\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.9, Page: \\n \\n\"\n", + "#Given:\n", + "\n", + "m=1/(6.023*10**23)#mass of 1 atom in g\n", + "m1=m*10**-3#mass of 1 atom in Kg\n", + "c=3*10**8# velocity in m/s\n", + "#solution:\n", + "\n", + "e=m1*c*c; # energy in J\n", + "e1=e/(1.6*10**-13)# energy in MeV\n", + "\n", + "print\"The energy in MeV is =\",e1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.10" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:11 \n", + " \n", + "\n", + "The energy in eV is = 13.2638658253\n" + ] + } + ], + "source": [ + "#cal of The energy\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:11 \\n \\n\"\n", + "#Given:\n", + "\n", + "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", + "\n", + "#solution:\n", + "\n", + "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", + "\n", + "print\"The energy in eV is =\",energy\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.11" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.11, Page:11 \n", + " \n", + "\n", + "\n", + " The mean binding energy of helium atom in MeV is = 7.0710038475\n", + "\n", + " The mean binding energy of oxygen atom in MeV is = 7.9800498909\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of helium and oxygen\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.11, Page:11 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078\n", + "mn=1.0087\n", + "ma=4.0026\n", + "mo=15.9949\n", + "Ah=4.0026 # atomic mass of helium\n", + "Ao=15.9949 # atomic mass of oxygen\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=(2*mh+2*mn-ma)*931 # in MeV\n", + "Bh=B1/Ah\n", + "print\"\\n The mean binding energy of helium atom in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=(8*mh+8*mn-mo)*931 # in MeV\n", + "Bo=B2/Ao\n", + "print\"\\n The mean binding energy of oxygen atom in MeV is =\",Bo\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.12" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.12, Page:12 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Be atom in MeV is = 7.05928572321\n", + "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" + ] + } + ], + "source": [ + "#cal of \n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.12, Page:12 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "ABe=8.0053; # atomic mass of beryllium\n", + "\n", + "#solution:\n", + "\n", + "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", + "Bh=B1/ABe;\n", + "print\"\\n The mean binding energy of Be atom in MeV is =\",Bh\n", + "\n", + "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.13" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.13, Page:12 \n", + " \n", + "\n", + "\n", + " The amount of coal required in Kg is = 2499.85671416\n" + ] + } + ], + "source": [ + "#cal of amount of coal\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.13, Page:12 \\n \\n\"\n", + "#Given:\n", + "\n", + "e=200; # in Mev\n", + "m=0.235; # weight of uranium atom in Kg\n", + "enthalpy=393.5; # in KJ/mol\n", + "Na=6.02*10**23;\n", + "\n", + "\n", + "#solution:\n", + "e1=e*1.6*10**-19*10**6;\n", + "atoms=Na/m;\n", + "e2=atoms*e1;#energy released in J\n", + "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", + "m2=m1/1000;# in tons\n", + "print\"\\n The amount of coal required in Kg is =\", m2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.14" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.14, Page:13 \n", + " \n", + "\n", + "\n", + " The energy release in part (a) in eV/molecule is = 2.51472\n", + "\n", + " The energy release in part (b) in eV/molecule is = 9.22688\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.14, Page:13 \\n \\n\"\n", + "#Given:\n", + "H1=241.8; # in KJ/mol\n", + "H2=887.2; # in KJ/mol\n", + "# 1 KJ/mol = 0.0104 eV/atom\n", + "\n", + "#solution: part (a)\n", + "e1=H1*0.0104;\n", + "print\"\\n The energy release in part (a) in eV/molecule is =\",e1\n", + "\n", + "#solution: part (b)\n", + "e2=H2*0.0104;\n", + "print\"\\n The energy release in part (b) in eV/molecule is =\",e2\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.15" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.15, Page:14 \n", + " \n", + "\n", + "\n", + " The energy release in part (a) in KJ/mol of carbondioxide is = 394.912\n", + "\n", + " The energy release in part (b) in KJ/mol of alumina is = 1675.968\n", + "\n", + " The energy release in part (c) in MJ/atom of U(235) is = 19264000.0\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.15, Page:14 \\n \\n\"\n", + "#Given:\n", + "H1=4.1; # in eV/molecule\n", + "H2=17.4; # in eV/molecule\n", + "H3=200;# in MeV/atom of U\n", + "\n", + "# 1 eV/atom = 96.32 KJ/mol\n", + "\n", + "#solution: part (a)\n", + "e1=H1*96.32;\n", + "print\"\\n The energy release in part (a) in KJ/mol of carbondioxide is =\",e1\n", + "\n", + "#solution: part (b)\n", + "e2=H2*96.32;\n", + "print\"\\n The energy release in part (b) in KJ/mol of alumina is =\",e2\n", + "\n", + "#solution: part (c)\n", + "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", + "print\"\\n The energy release in part (c) in MJ/atom of U(235) is =\",e3\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.16" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.16, Page:15 \n", + " \n", + "\n", + "\n", + " The rate of energy release in W is 949251379.039\n" + ] + } + ], + "source": [ + "#cal of The rate of energy release\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.16, Page:15 \\n \\n\"\n", + "#Given:\n", + "e=200; #MeV/ atom of U\n", + "# 1 eV = 1.6*10^-19 J\n", + "Na=6.023*10**23;\n", + "M=0.235; # mass in Kg\n", + "\n", + "#solution:\n", + "\n", + "e1=e*1.6*10**-19*10**6;\n", + "A=Na/M;\n", + "e2=A*e1; # energy released in MJ/day\n", + "e3=e2/(24*3600);\n", + "print\"\\n The rate of energy release in W is \",e3\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.17" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.17, Page:16 \n", + " \n", + "\n", + "\n", + " The mass loss in 10^-27 Kg/He formed is = 0.046412244898\n" + ] + } + ], + "source": [ + "#cal of The mass loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.17, Page:16 \\n \\n\"\n", + "#Given:\n", + "e=26.03; # in MeV\n", + "\n", + "#solution:\n", + "\n", + "loss=e/931; #in atomic mass units (u)\n", + "# 1 u = 1.66*10^-27 Kg\n", + "m=(loss*1.66*10**-27)/(1*10**-27);\n", + "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",m\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.18" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.18, Page:17 \n", + " \n", + "\n", + "\n", + " The energy loss in MeV is = 4.03123\n" + ] + } + ], + "source": [ + "#cal of The energy loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.18, Page:17 \\n \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mt=3.016049;\n", + "md=2.014102;\n", + "\n", + "#solution:\n", + "\n", + "m1=(mh+mt-2*md);\n", + "e=(-m1)*931; # in MeV\n", + "print\"\\n The energy loss in MeV is =\",e\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.19" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.19, Page:18 \n", + " \n", + "\n", + "\n", + " The mean binding energy of tritium atom in MeV is = 2.81085817903\n", + "\n", + " The mean binding energy of nickel atom in MeV is = 8.71580311296\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of tritium and nickel atom\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.19, Page:18 \\n \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mn=1.008665;\n", + "mt=3.016049; # atomic mass of Tritium\n", + "mNi=59.93528; # atomic mass of Nickel\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=(1*mh+2*mn-mt)*931; # in MeV\n", + "Bh=B1/mt;\n", + "print\"\\n The mean binding energy of tritium atom in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", + "Bo=B2/mNi;\n", + "print\"\\n The mean binding energy of nickel atom in MeV is =\",Bo\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.20" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.20, Page:19 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Cl (35) atom in MeV is = 8.52810201079\n", + "\n", + " The mean binding energy of Cl (37) atom in MeV is = 8.57839008383\n", + "\n", + " The increase in mean binding energy of Cl atom in MeV is = 0.0502880730447\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Cl\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.20, Page:19 \\n \\n\"\n", + "#Given:\n", + "mh=1.00783;\n", + "mn=1.00867;\n", + "m35=34.96885; # atomic mass of Cl (35)\n", + "m37=36.96590; # atomic mass of Cl (37)\n", + "\n", + "#solution:\n", + "\n", + "B1=(17*mh+18*mn-m35)*931; # in MeV\n", + "Bh=B1/m35;\n", + "print\"\\n The mean binding energy of Cl (35) atom in MeV is =\",Bh\n", + "\n", + "B2=(17*mh+20*mn-m37)*931; # in MeV\n", + "Bo=B2/m37;\n", + "print\"\\n The mean binding energy of Cl (37) atom in MeV is =\",Bo\n", + "\n", + "Bi=Bo-Bh;\n", + "print\"\\n The increase in mean binding energy of Cl atom in MeV is =\",Bi\n", + "\n", + "# NOTE: The answer depends upon how much precise value you take for atomic masses.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.21" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.21, Page:20 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Na(22) in MeV is = 7.92358978299\n", + "\n", + " The mean binding energy of Na(23)in MeV is = 8.11544250059\n", + "\n", + " The mean binding energy of Na(24) in MeV is = 8.07172719656\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Na\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.21, Page:20 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "m22=21.99431;# atomic mass of Na 22\n", + "m23=22.9898;# atomic mass of Na 23\n", + "m24=23.9909;# atomic mass of Na 24\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", + "Bh=B1/m22;\n", + "print\"\\n The mean binding energy of Na(22) in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", + "Bo=B2/m23;\n", + "print\"\\n The mean binding energy of Na(23)in MeV is =\",Bo\n", + "\n", + "# part (c)\n", + "\n", + "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", + "Bs=B3/m24;\n", + "print\"\\n The mean binding energy of Na(24) in MeV is =\",Bs\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1_1.ipynb b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1_1.ipynb new file mode 100755 index 00000000..6bb4fa49 --- /dev/null +++ b/sample_notebooks/Raj Phani/Raj Phani_version_backup/chapter_1_1.ipynb @@ -0,0 +1,1118 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# chapter1: electric charge" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.1" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:3 \n", + " \n", + "\n", + "\n", + " The electric field in V/m is = 20000.0\n", + "\n", + " The force in N/C is = 20000.0\n", + "\n", + " The force on metal sphere in N is = 7.6e-05\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:3 \\n \\n\"\n", + "#Given:\n", + "v=1000# potential\n", + "d=0.05# distance\n", + "q=3.8*10**-9# charge\n", + "\n", + "#solution:\n", + "e=v/d;#electric field\n", + "f=e;# force\n", + "f1=f*q;# force on metal sphere\n", + "print\"\\n The electric field in V/m is =\",e\n", + "print\"\\n The force in N/C is =\",f\n", + "print\"\\n The force on metal sphere in N is =\",f1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.2" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.2, Page:4 \n", + " \n", + "\n", + "The potential in V is = 80.0\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.2, Page:4 \\n \\n\"\n", + "#Given:\n", + "energy=2*10**-6\n", + "c=2.5*10**-8# velocity of light\n", + "#solution:\n", + "v=energy/c# potential\n", + "print\"The potential in V is =\",v\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.3" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.3, Page:5 \n", + " \n", + "\n", + "The wavelength in Angstroms is = 3.88289589025\n", + "\n", + " The photon wavelength in Angstroms is = 9.11075e-05\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.3, Page:5 \\n \\n\"\n", + "#Given:\n", + "\n", + "energy=10 #in electron volts\n", + "m=9.1*10**-31# mass of electron in kg\n", + "h=6.626*10**-34# planck's constant J.s\n", + "c=3*10^8# speed of light in m/s\n", + "\n", + "#solution (a):\n", + "energy1=energy*1.6*10**-19# energy in J\n", + "p=(2*m*energy1)**0.5# momentum\n", + "wavelength=h/p*(10)**10\n", + "\n", + "print\"The wavelength in Angstroms is =\",wavelength\n", + "\n", + "\n", + "#solution (b):\n", + "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", + "\n", + "print\"\\n The photon wavelength in Angstroms is =\",wavelength1\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example1.4" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.4, Page:6 \n", + " \n", + "\n", + "The energy in eV is = 150.768804945\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.4, Page:6 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "wavelength=10**-10\n", + "m=9.1*10**-31\n", + "h=6.626*10**-34\n", + "\n", + "#solution:\n", + "\n", + "p=h/wavelength\n", + "e=p*p/(2*m) # energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "\n", + "print\"The energy in eV is =\",e1\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.5" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.5, Page:8 \n", + " \n", + "\n", + "\n", + " The wavelength in 10^-5 Angstroms is = 0.655671822473\n", + "\n", + " The wavelength in 10^-5 Angstroms is = 0.648946805494\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.5, Page:8 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", + "h=6.6262*10**-34#planck's constant in J.s\n", + "energy1=120# in Mev for oxygen\n", + "energy2=140# in MeV for nitrogen\n", + "\n", + "#solution(a):\n", + "\n", + "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", + "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "\n", + "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength1\n", + "\n", + "#solution (b):\n", + "\n", + "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", + "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", + "\n", + "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength2\n", + "\n", + "# 1 Angstrom = 10^-10 m\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example1.6" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.6, Page:9 \n", + " \n", + "\n", + "The energy in eV is = 8275.0\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.6, Page:9 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "wavelength=1.5*10**-10\n", + "h=6.62*10**-34\n", + "c=3*10**8\n", + "\n", + "#solution:\n", + "\n", + "e=(h*c)/wavelength# energy in J\n", + "e1=e/(1.6*10**-19)# energy in eV\n", + "\n", + "print\"The energy in eV is =\",e1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.7" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.7, Page:10 \n", + " \n", + "\n", + "\n", + " The threshold frequency in s^-1 is = 1.23634168427e+15\n", + "\n", + " The threshold wavelength in Angstroms is = 2426.51367187\n", + "\n", + " The energy of photoelectrone in eV is = 3.911875\n" + ] + } + ], + "source": [ + "#cal of elelectric field and force\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.7, Page:10 \\n \\n\"\n", + "\n", + "#Given:\n", + "\n", + "E=5.12*1.6*10**-19# energy in J\n", + "h=6.626*10**-34\n", + "c=3*10**8\n", + "wavelength=200*10**-9\n", + "w=2.3# in eV\n", + "\n", + "#solution:\n", + "\n", + "tf=E/h# (part a)\n", + "print\"\\n The threshold frequency in s^-1 is =\",tf\n", + "\n", + "tl=c/tf*10**10# (part b)\n", + "print\"\\n The threshold wavelength in Angstroms is =\",tl\n", + "\n", + "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", + "\n", + "pe=e-w\n", + "\n", + "print\"\\n The energy of photoelectrone in eV is =\",pe\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.8" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.8, Page:10 \n", + " \n", + "\n", + "\n", + " The velocity of alpha particles for 1 MeV in m/s is = 6941056.08394\n", + "\n", + " The velocity of alpha particles for 2 MeV in m/s is = 9816135.6511\n", + "\n", + " The velocity of deuteron particles for 1 MeV in m/s is = 9816135.6511\n", + "\n", + " The velocity of deuteron particles for 2 MeV in m/s is = 13882112.1679\n", + "\n", + " The velocity of proton particles for 1 MeV in m/s is = 13882112.1679\n", + "\n", + " The velocity of proton particles for 2 MeV in m/s is = 19632271.3022\n" + ] + } + ], + "source": [ + "#cal of velocity of alpha particles,deuteron,proton\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.8, Page:10 \\n \\n\"\n", + "#Given:\n", + "e1=1 # in MeV\n", + "e2=2 # in MeV\n", + "ma=4 # in u(amu)\n", + "md=2 # in u(amu)\n", + "mp=1 # in u(amu)\n", + "\n", + "# 1u = 1.6*10^-27 Kg\n", + "\n", + "#solution: part a)For alpha particles\n", + "\n", + "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 1 MeV in m/s is =\",v1a# For 1 MeV\n", + "\n", + "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of alpha particles for 2 MeV in m/s is =\",v2a# For 2 MeV\n", + "\n", + "#solution: part b)For deuteron particles\n", + "\n", + "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 1 MeV in m/s is =\",v1b # For 1 MeV\n", + "\n", + "\n", + "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of deuteron particles for 2 MeV in m/s is =\",v2b # For 2 MeV\n", + "\n", + "#solution: part c)For proton particles\n", + "\n", + "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 1 MeV in m/s is =\",v1p # For 1 MeV\n", + "\n", + "\n", + "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", + "print\"\\n The velocity of proton particles for 2 MeV in m/s is =\",v2p # For 2 MeV\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.9" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.9, Page:10 \n", + " \n", + "\n", + "The energy in MeV is = 933.919973435\n" + ] + } + ], + "source": [ + "#cal of The energy\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.9, Page:10 \\n \\n\"\n", + "#Given:\n", + "\n", + "m=1/(6.023*10**23)#mass of 1 atom in g\n", + "m1=m*10**-3#mass of 1 atom in Kg\n", + "c=3*10**8# velocity in m/s\n", + "#solution:\n", + "\n", + "e=m1*c*c; # energy in J\n", + "e1=e/(1.6*10**-13)# energy in MeV\n", + "\n", + "print\"The energy in MeV is =\",e1\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.10" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:11 \n", + " \n", + "\n", + "The energy in eV is = 13.2638658253\n" + ] + } + ], + "source": [ + "#cal of The energy\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:11 \\n \\n\"\n", + "#Given:\n", + "\n", + "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", + "\n", + "#solution:\n", + "\n", + "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", + "\n", + "print\"The energy in eV is =\",energy\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.11" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.11, Page:11 \n", + " \n", + "\n", + "\n", + " The mean binding energy of helium atom in MeV is = 7.0710038475\n", + "\n", + " The mean binding energy of oxygen atom in MeV is = 7.9800498909\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of helium and oxygen\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.11, Page:11 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078\n", + "mn=1.0087\n", + "ma=4.0026\n", + "mo=15.9949\n", + "Ah=4.0026 # atomic mass of helium\n", + "Ao=15.9949 # atomic mass of oxygen\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=(2*mh+2*mn-ma)*931 # in MeV\n", + "Bh=B1/Ah\n", + "print\"\\n The mean binding energy of helium atom in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=(8*mh+8*mn-mo)*931 # in MeV\n", + "Bo=B2/Ao\n", + "print\"\\n The mean binding energy of oxygen atom in MeV is =\",Bo\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.12" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.12, Page:12 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Be atom in MeV is = 7.05928572321\n", + "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" + ] + } + ], + "source": [ + "#cal of \n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.12, Page:12 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "ABe=8.0053; # atomic mass of beryllium\n", + "\n", + "#solution:\n", + "\n", + "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", + "Bh=B1/ABe;\n", + "print\"\\n The mean binding energy of Be atom in MeV is =\",Bh\n", + "\n", + "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.13" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.13, Page:12 \n", + " \n", + "\n", + "\n", + " The amount of coal required in Kg is = 2499.85671416\n" + ] + } + ], + "source": [ + "#cal of amount of coal\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.13, Page:12 \\n \\n\"\n", + "#Given:\n", + "\n", + "e=200; # in Mev\n", + "m=0.235; # weight of uranium atom in Kg\n", + "enthalpy=393.5; # in KJ/mol\n", + "Na=6.02*10**23;\n", + "\n", + "\n", + "#solution:\n", + "e1=e*1.6*10**-19*10**6;\n", + "atoms=Na/m;\n", + "e2=atoms*e1;#energy released in J\n", + "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", + "m2=m1/1000;# in tons\n", + "print\"\\n The amount of coal required in Kg is =\", m2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.14" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.14, Page:13 \n", + " \n", + "\n", + "\n", + " The energy release in part (a) in eV/molecule is = 2.51472\n", + "\n", + " The energy release in part (b) in eV/molecule is = 9.22688\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.14, Page:13 \\n \\n\"\n", + "#Given:\n", + "H1=241.8; # in KJ/mol\n", + "H2=887.2; # in KJ/mol\n", + "# 1 KJ/mol = 0.0104 eV/atom\n", + "\n", + "#solution: part (a)\n", + "e1=H1*0.0104;\n", + "print\"\\n The energy release in part (a) in eV/molecule is =\",e1\n", + "\n", + "#solution: part (b)\n", + "e2=H2*0.0104;\n", + "print\"\\n The energy release in part (b) in eV/molecule is =\",e2\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.15" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.15, Page:14 \n", + " \n", + "\n", + "\n", + " The energy release in part (a) in KJ/mol of carbondioxide is = 394.912\n", + "\n", + " The energy release in part (b) in KJ/mol of alumina is = 1675.968\n", + "\n", + " The energy release in part (c) in MJ/atom of U(235) is = 19264000.0\n" + ] + } + ], + "source": [ + "#cal of The energy releases\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.15, Page:14 \\n \\n\"\n", + "#Given:\n", + "H1=4.1; # in eV/molecule\n", + "H2=17.4; # in eV/molecule\n", + "H3=200;# in MeV/atom of U\n", + "\n", + "# 1 eV/atom = 96.32 KJ/mol\n", + "\n", + "#solution: part (a)\n", + "e1=H1*96.32;\n", + "print\"\\n The energy release in part (a) in KJ/mol of carbondioxide is =\",e1\n", + "\n", + "#solution: part (b)\n", + "e2=H2*96.32;\n", + "print\"\\n The energy release in part (b) in KJ/mol of alumina is =\",e2\n", + "\n", + "#solution: part (c)\n", + "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", + "print\"\\n The energy release in part (c) in MJ/atom of U(235) is =\",e3\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.16" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.16, Page:15 \n", + " \n", + "\n", + "\n", + " The rate of energy release in W is 949251379.039\n" + ] + } + ], + "source": [ + "#cal of The rate of energy release\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.16, Page:15 \\n \\n\"\n", + "#Given:\n", + "e=200; #MeV/ atom of U\n", + "# 1 eV = 1.6*10^-19 J\n", + "Na=6.023*10**23;\n", + "M=0.235; # mass in Kg\n", + "\n", + "#solution:\n", + "\n", + "e1=e*1.6*10**-19*10**6;\n", + "A=Na/M;\n", + "e2=A*e1; # energy released in MJ/day\n", + "e3=e2/(24*3600);\n", + "print\"\\n The rate of energy release in W is \",e3\n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.17" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.17, Page:16 \n", + " \n", + "\n", + "\n", + " The mass loss in 10^-27 Kg/He formed is = 0.046412244898\n" + ] + } + ], + "source": [ + "#cal of The mass loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.17, Page:16 \\n \\n\"\n", + "#Given:\n", + "e=26.03; # in MeV\n", + "\n", + "#solution:\n", + "\n", + "loss=e/931; #in atomic mass units (u)\n", + "# 1 u = 1.66*10^-27 Kg\n", + "m=(loss*1.66*10**-27)/(1*10**-27);\n", + "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",m\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.18" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.18, Page:17 \n", + " \n", + "\n", + "\n", + " The energy loss in MeV is = 4.03123\n" + ] + } + ], + "source": [ + "#cal of The energy loss\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.18, Page:17 \\n \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mt=3.016049;\n", + "md=2.014102;\n", + "\n", + "#solution:\n", + "\n", + "m1=(mh+mt-2*md);\n", + "e=(-m1)*931; # in MeV\n", + "print\"\\n The energy loss in MeV is =\",e\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.19" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.19, Page:18 \n", + " \n", + "\n", + "\n", + " The mean binding energy of tritium atom in MeV is = 2.81085817903\n", + "\n", + " The mean binding energy of nickel atom in MeV is = 8.71580311296\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of tritium and nickel atom\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.19, Page:18 \\n \\n\"\n", + "#Given:\n", + "mh=1.007825;\n", + "mn=1.008665;\n", + "mt=3.016049; # atomic mass of Tritium\n", + "mNi=59.93528; # atomic mass of Nickel\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=(1*mh+2*mn-mt)*931; # in MeV\n", + "Bh=B1/mt;\n", + "print\"\\n The mean binding energy of tritium atom in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", + "Bo=B2/mNi;\n", + "print\"\\n The mean binding energy of nickel atom in MeV is =\",Bo\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.20" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.20, Page:19 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Cl (35) atom in MeV is = 8.52810201079\n", + "\n", + " The mean binding energy of Cl (37) atom in MeV is = 8.57839008383\n", + "\n", + " The increase in mean binding energy of Cl atom in MeV is = 0.0502880730447\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Cl\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.20, Page:19 \\n \\n\"\n", + "#Given:\n", + "mh=1.00783;\n", + "mn=1.00867;\n", + "m35=34.96885; # atomic mass of Cl (35)\n", + "m37=36.96590; # atomic mass of Cl (37)\n", + "\n", + "#solution:\n", + "\n", + "B1=(17*mh+18*mn-m35)*931; # in MeV\n", + "Bh=B1/m35;\n", + "print\"\\n The mean binding energy of Cl (35) atom in MeV is =\",Bh\n", + "\n", + "B2=(17*mh+20*mn-m37)*931; # in MeV\n", + "Bo=B2/m37;\n", + "print\"\\n The mean binding energy of Cl (37) atom in MeV is =\",Bo\n", + "\n", + "Bi=Bo-Bh;\n", + "print\"\\n The increase in mean binding energy of Cl atom in MeV is =\",Bi\n", + "\n", + "# NOTE: The answer depends upon how much precise value you take for atomic masses.\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.21" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.21, Page:20 \n", + " \n", + "\n", + "\n", + " The mean binding energy of Na(22) in MeV is = 7.92358978299\n", + "\n", + " The mean binding energy of Na(23)in MeV is = 8.11544250059\n", + "\n", + " The mean binding energy of Na(24) in MeV is = 8.07172719656\n" + ] + } + ], + "source": [ + "#cal of mean binding energy of Na\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.21, Page:20 \\n \\n\"\n", + "#Given:\n", + "mh=1.0078;\n", + "mn=1.0087;\n", + "m22=21.99431;# atomic mass of Na 22\n", + "m23=22.9898;# atomic mass of Na 23\n", + "m24=23.9909;# atomic mass of Na 24\n", + "\n", + "#solution:\n", + "\n", + "# part (a)\n", + "\n", + "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", + "Bh=B1/m22;\n", + "print\"\\n The mean binding energy of Na(22) in MeV is =\",Bh\n", + "\n", + "# part (b)\n", + "\n", + "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", + "Bo=B2/m23;\n", + "print\"\\n The mean binding energy of Na(23)in MeV is =\",Bo\n", + "\n", + "# part (c)\n", + "\n", + "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", + "Bs=B3/m24;\n", + "print\"\\n The mean binding energy of Na(24) in MeV is =\",Bs\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Raj Phani/chapter1.ipynb b/sample_notebooks/Raj Phani/chapter1.ipynb deleted file mode 100755 index af42a9cd..00000000 --- a/sample_notebooks/Raj Phani/chapter1.ipynb +++ /dev/null @@ -1,993 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# chapter 1: Atomic Nucleus" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.1;pg no:2" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:2 \n", - " \n", - "\n", - "\n", - " The electric field in V/m is = 20000.0\n", - "\n", - " The force in N/C is = 20000.0\n", - "\n", - " The force on metal sphere in N is = 7.6e-05\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:2 \\n \\n\"\n", - "#Given:\n", - "v=1000# potential\n", - "d=0.05# distance\n", - "q=3.8*10**-9# charge\n", - "#solution:\n", - "e=v/d;#electric field\n", - "f=e;# force\n", - "f1=f*q;# force on metal sphere\n", - "print\"\\n The electric field in V/m is =\",e\n", - "print\"\\n The force in N/C is =\",f\n", - "print\"\\n The force on metal sphere in N is =\",f1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.2;pg no:2" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.2, Page:2 \n", - " \n", - "\n", - "The potential in V is = 80.0\n" - ] - } - ], - "source": [ - "#cal of potential\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.2, Page:2 \\n \\n\"\n", - "#Given:\n", - "energy=2*10**-6\n", - "c=2.5*10**-8# velocity of light\n", - "#solution:\n", - "v=energy/c# potential\n", - "print\"The potential in V is =\",v" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.3;pg no:3" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.3, Page:3 \n", - "\n", - "The wavelength in Angstroms is = 3.88\n", - "The photon wavelength in Angstroms is = 1242.38\n" - ] - } - ], - "source": [ - "#cal of elecrtron and photon wavelength\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.3, Page:3 \\n\"\n", - "#Given:\n", - "energy=10 #in electron volts\n", - "m=9.1*10**-31# mass of electron in kg\n", - "h=6.626*10**-34# planck's constant J.s\n", - "c=3*10**8# speed of light in m/s\n", - "#solution (a):\n", - "energy1=energy*1.6*10**-19# energy in J\n", - "p=(2*m*energy1)**0.5# momentum\n", - "wavelength=h/p*(10)**10\n", - "print\"The wavelength in Angstroms is =\",round(wavelength,2)\n", - "#solution (b):\n", - "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", - "print\"The photon wavelength in Angstroms is =\",round(wavelength1,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.4;pg no:3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.4, Page:3 \n", - " \n", - "\n", - "The energy in eV is = 150.77\n" - ] - } - ], - "source": [ - "#cal of kinetic energy of an electron\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.4, Page:3 \\n \\n\"\n", - "#Given:\n", - "wavelength=10**-10\n", - "m=9.1*10**-31\n", - "h=6.626*10**-34\n", - "#solution:\n", - "p=h/wavelength\n", - "e=p*p/(2*m) # energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "print\"The energy in eV is =\",round(e1,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.5;pg no:3" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.5, Page:3 \n", - " \n", - "\n", - "The wavelength in 10^-5 Angstroms is = 0.66\n", - "The wavelength in 10^-5 Angstroms is = 0.65\n" - ] - } - ], - "source": [ - "#cal of wavelength of oxygen and nitrogen nucleus\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.5, Page:3 \\n \\n\"\n", - "#Given:\n", - "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", - "h=6.6262*10**-34#planck's constant in J.s\n", - "energy1=120# in Mev for oxygen\n", - "energy2=140# in MeV for nitrogen\n", - "#solution(a):\n", - "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", - "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "print\"The wavelength in 10^-5 Angstroms is =\",round(wavelength1,2)\n", - "#solution (b):\n", - "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", - "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "print\"The wavelength in 10^-5 Angstroms is =\",round(wavelength2,2)\n", - "# 1 Angstrom = 10^-10 m" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.6;pg no:3" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.6, Page:3 \n", - " \n", - "\n", - "The energy in eV is = 8275.0\n" - ] - } - ], - "source": [ - "#cal of energy of a gamma photon\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.6, Page:3 \\n \\n\"\n", - "#Given:\n", - "wavelength=1.5*10**-10\n", - "h=6.62*10**-34\n", - "c=3*10**8\n", - "#solution:\n", - "e=(h*c)/wavelength# energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "print\"The energy in eV is =\",e1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.7;pg no:4" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.7, Page:4 \n", - " \n", - "\n", - "\n", - " The threshold frequency in s^-1 is = 1.23634168427e+15\n", - "\n", - " The threshold wavelength in Angstroms is = 2426.51\n", - "\n", - " The energy of photoelectrone in eV is = 3.91\n" - ] - } - ], - "source": [ - "#cal of threshold frequency,wavelength,energy of photoelectrone\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.7, Page:4 \\n \\n\"\n", - "#Given:\n", - "E=5.12*1.6*10**-19# energy in J\n", - "h=6.626*10**-34\n", - "c=3*10**8\n", - "wavelength=200*10**-9\n", - "w=2.3# in eV\n", - "#solution:\n", - "tf=E/h# (part a)\n", - "print\"\\n The threshold frequency in s^-1 is =\",round(tf,2)\n", - "tl=c/tf*10**10# (part b)\n", - "print\"\\n The threshold wavelength in Angstroms is =\",round(tl,2)\n", - "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", - "pe=e-w\n", - "print\"\\n The energy of photoelectrone in eV is =\",round(pe,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.8;pg no:4" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.8, Page:4 \n", - " \n", - "\n", - "\n", - " The velocity of alpha particles for 1 MeV in mega m/s is = 6.94\n", - "\n", - " The velocity of alpha particles for 2 MeV in mega m/s is = 9.82\n", - "\n", - " The velocity of deuteron particles for 1 MeV in mega m/s is = 9.82\n", - "\n", - " The velocity of deuteron particles for 2 MeV in mega m/s is = 13.88\n", - "\n", - " The velocity of proton particles for 1 MeV in mega m/s is = 13.88\n", - "\n", - " The velocity of proton particles for 2 MeV in mega m/s is = 19.63\n" - ] - } - ], - "source": [ - "#cal of velocity of alpha particles,deuteron,proton\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.8, Page:4 \\n \\n\"\n", - "#Given:\n", - "e1=1 # in MeV\n", - "e2=2 # in MeV\n", - "ma=4 # in u(amu)\n", - "md=2 # in u(amu)\n", - "mp=1 # in u(amu)\n", - "# 1u = 1.6*10^-27 Kg\n", - "#solution: part a)For alpha particles\n", - "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 1 MeV in mega m/s is =\",round(v1a/10**6,2)# For 1 MeV\n", - "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 2 MeV in mega m/s is =\",round(v2a/10**6,2)# For 2 MeV\n", - "#solution: part b)For deuteron particles\n", - "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 1 MeV in mega m/s is =\",round(v1b/10**6,2) # For 1 MeV\n", - "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 2 MeV in mega m/s is =\",round(v2b/10**6,2) # For 2 MeV\n", - "#solution: part c)For proton particles\n", - "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 1 MeV in mega m/s is =\",round(v1p/10**6,2) # For 1 MeV\n", - "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 2 MeV in mega m/s is =\",round(v2p/10**6,2) # For 2 MeV" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.9;pg no:5" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.9, Page:5 \n", - " \n", - "\n", - "The energy in MeV is = 934.0\n" - ] - } - ], - "source": [ - "#cal of The energy equivalence\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.9, Page:5 \\n \\n\"\n", - "#Given:\n", - "m=1./(6.023*10**23)#mass of 1 atom in g\n", - "m1=m*10**-3#mass of 1 atom in Kg\n", - "c=3.*10**8# velocity in m/s\n", - "#solution:\n", - "e=m1*c*c; # energy in J\n", - "e1=e/(1.6*10**-13)# energy in MeV\n", - "print\"The energy in MeV is =\",round(e1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.10;pg no:5" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.10, Page:5 \n", - " \n", - "\n", - "The energy in eV is = 13.26\n" - ] - } - ], - "source": [ - "#cal of The energy of formation\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.10, Page:5 \\n \\n\"\n", - "#Given:\n", - "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", - "#solution:\n", - "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", - "print\"The energy in eV is =\",round(energy,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.11;pg no:5" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.11, Page:5 \n", - " \n", - "\n", - "\n", - " The mean binding energy of helium atom in MeV is = 7.07\n", - "\n", - " The mean binding energy of oxygen atom in MeV is = 7.98\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of helium and oxygen\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.11, Page:5 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078\n", - "mn=1.0087\n", - "ma=4.0026\n", - "mo=15.9949\n", - "Ah=4.0026 # atomic mass of helium\n", - "Ao=15.9949 # atomic mass of oxygen\n", - "#solution:\n", - "# part (a)\n", - "B1=(2*mh+2*mn-ma)*931 # in MeV\n", - "Bh=B1/Ah\n", - "print\"\\n The mean binding energy of helium atom in MeV is =\",round(Bh,2)\n", - "# part (b)\n", - "B2=(8*mh+8*mn-mo)*931 # in MeV\n", - "Bo=B2/Ao\n", - "print\"\\n The mean binding energy of oxygen atom in MeV is =\",round(Bo,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.12;pg no:6" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.12, Page:6 \n", - "\n", - "\n", - " The mean binding energy of Be atom in MeV is = 7.059\n", - "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Be atom\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.12, Page:6 \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "ABe=8.0053; # atomic mass of beryllium\n", - "#solution:\n", - "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", - "Bh=B1/ABe;\n", - "print\"\\n The mean binding energy of Be atom in MeV is =\",round(Bh,3)\n", - "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.13;pg no:6" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.13, Page:6 \n", - "\n", - "The amount of coal required in Kg is = 2.5\n" - ] - } - ], - "source": [ - "#cal of amount of coal\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.13, Page:6 \\n\"\n", - "#Given:\n", - "e=200; # in Mev\n", - "m=0.235; # weight of uranium atom in Kg\n", - "enthalpy=393.5; # in KJ/mol\n", - "Na=6.02*10**23;\n", - "#solution:\n", - "e1=e*1.6*10**-19*10**6;\n", - "atoms=Na/m;\n", - "e2=atoms*e1;#energy released in J\n", - "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", - "m2=m1/1000;# in tons\n", - "print\"The amount of coal required in Kg is =\", round(m2/1000,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.14;pg no:7" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.14, Page:7 \n", - " \n", - "\n", - "The energy release in part (a) in eV/molecule is = 2.51\n", - "The energy release in part (b) in eV/molecule is = 9.23\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.14, Page:7 \\n \\n\"\n", - "#Given:\n", - "H1=241.8; # in KJ/mol\n", - "H2=887.2; # in KJ/mol\n", - "# 1 KJ/mol = 0.0104 eV/atom\n", - "#solution: part (a)\n", - "e1=H1*0.0104;\n", - "print\"The energy release in part (a) in eV/molecule is =\",round(e1,2)\n", - "#solution: part (b)\n", - "e2=H2*0.0104;\n", - "print\"The energy release in part (b) in eV/molecule is =\",round(e2,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.15;pg no:7" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.15, Page:7 \n", - "\n", - "The energy release in part (a) in KJ/mol of carbondioxide is = 394.9\n", - "The energy release in part (b) in KJ/mol of alumina is = 1676.0\n", - "The energy release in part (c) in MJ/atom of U(235) is = 19.264\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.15, Page:7 \\n\"\n", - "#Given:\n", - "H1=4.1; # in eV/molecule\n", - "H2=17.4; # in eV/molecule\n", - "H3=200;# in MeV/atom of U\n", - "# 1 eV/atom = 96.32 KJ/mol\n", - "#solution: part (a)\n", - "e1=H1*96.32;\n", - "print\"The energy release in part (a) in KJ/mol of carbondioxide is =\",round(e1,1)\n", - "#solution: part (b)\n", - "e2=H2*96.32;\n", - "print\"The energy release in part (b) in KJ/mol of alumina is =\",round(e2,1)\n", - "#solution: part (c)\n", - "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", - "print\"The energy release in part (c) in MJ/atom of U(235) is =\",round(e3/10**6,3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.16;pg no:7" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.16, Page:7 \n", - " \n", - "\n", - "\n", - " The rate of energy release in MW is= 949.25\n" - ] - } - ], - "source": [ - "#cal of The rate of energy release\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.16, Page:7 \\n \\n\"\n", - "#Given:\n", - "e=200.; #MeV/ atom of U\n", - "# 1 eV = 1.6*10^-19 J\n", - "Na=6.023*10**23;\n", - "M=0.235; # mass in Kg\n", - "#solution:\n", - "e1=e*1.6*10**-19*10**6;\n", - "A=Na/M;\n", - "e2=A*e1; # energy released in MJ/day\n", - "e3=e2/(24.*3600.);\n", - "print\"\\n The rate of energy release in MW is=\",round(e3/10**6,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.17;pg no:8" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.17, Page:8 \n", - " \n", - "\n", - "\n", - " The mass loss in 10^-27 Kg/He formed is = 0.0464\n" - ] - } - ], - "source": [ - "#cal of The mass loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.17, Page:8 \\n \\n\"\n", - "#Given:\n", - "e=26.03; # in MeV\n", - "#solution:\n", - "loss=e/931; #in atomic mass units (u)\n", - "# 1 u = 1.66*10^-27 Kg\n", - "m=(loss*1.66*10**-27)/(1*10**-27);\n", - "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",round(m,4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.18;pg no:8" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.18, Page:8 \n", - "\n", - "\n", - " The energy loss in MeV is = -4.0312\n" - ] - } - ], - "source": [ - "#cal of The energy loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.18, Page:8 \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mt=3.016049;\n", - "md=2.014102;\n", - "#solution:\n", - "m1=(mh+mt-2*md);\n", - "e=(-m1)*931; # in MeV\n", - "print\"\\n The energy loss in MeV is =\",round(-e,4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.19;pg no:8" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.19, Page:8 \n", - "\n", - "The mean binding energy of tritium atom in MeV is = 2.811\n", - "The mean binding energy of nickel atom in MeV is = 8.716\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of tritium and nickel atom\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.19, Page:8 \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mn=1.008665;\n", - "mt=3.016049; # atomic mass of Tritium\n", - "mNi=59.93528; # atomic mass of Nickel\n", - "#solution:\n", - "# part (a)\n", - "B1=(1*mh+2*mn-mt)*931; # in MeV\n", - "Bh=B1/mt;\n", - "print\"The mean binding energy of tritium atom in MeV is =\",round(Bh,3)\n", - "# part (b)\n", - "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", - "Bo=B2/mNi;\n", - "print\"The mean binding energy of nickel atom in MeV is =\",round(Bo,3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.20;pg no:9" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.20, Page:9 \n", - "\n", - "The mean binding energy of Cl (35) atom in MeV is = 8.5281\n", - "The mean binding energy of Cl (37) atom in MeV is = 8.5784\n", - "The increase in mean binding energy of Cl atom in MeV is = 0.05\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Cl\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.20, Page:9 \\n\"\n", - "#Given:\n", - "mh=1.00783;\n", - "mn=1.00867;\n", - "m35=34.96885; # atomic mass of Cl (35)\n", - "m37=36.96590; # atomic mass of Cl (37)\n", - "#solution:\n", - "B1=(17*mh+18*mn-m35)*931; # in MeV\n", - "Bh=B1/m35;\n", - "print\"The mean binding energy of Cl (35) atom in MeV is =\",round(Bh,4)\n", - "B2=(17*mh+20*mn-m37)*931; # in MeV\n", - "Bo=B2/m37;\n", - "print\"The mean binding energy of Cl (37) atom in MeV is =\",round(Bo,4)\n", - "Bi=Bo-Bh;\n", - "print\"The increase in mean binding energy of Cl atom in MeV is =\",round(Bi,2)\n", - "# NOTE: The answer depends upon how much precise value you take for atomic masses." - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.21;pg no:9" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.21, Page:9 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Na(22) in MeV is = 7.9236\n", - "\n", - " The mean binding energy of Na(23)in MeV is = 8.1154\n", - "\n", - " The mean binding energy of Na(24) in MeV is = 8.0717\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Na\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.21, Page:9 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "m22=21.99431;# atomic mass of Na 22\n", - "m23=22.9898;# atomic mass of Na 23\n", - "m24=23.9909;# atomic mass of Na 24\n", - "#solution:\n", - "# part (a)\n", - "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", - "Bh=B1/m22;\n", - "print\"\\n The mean binding energy of Na(22) in MeV is =\",round(Bh,4)\n", - "# part (b)\n", - "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", - "Bo=B2/m23;\n", - "print\"\\n The mean binding energy of Na(23)in MeV is =\",round(Bo,4)\n", - "# part (c)\n", - "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", - "Bs=B3/m24;\n", - "print\"\\n The mean binding energy of Na(24) in MeV is =\",round(Bs,4)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Raj Phani/chapter_1.ipynb b/sample_notebooks/Raj Phani/chapter_1.ipynb deleted file mode 100755 index f71cb56f..00000000 --- a/sample_notebooks/Raj Phani/chapter_1.ipynb +++ /dev/null @@ -1,1118 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# chapter1: electric charge" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.1" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:3 \n", - " \n", - "\n", - "\n", - " The electric field in V/m is = 20000.0\n", - "\n", - " The force in N/C is = 20000.0\n", - "\n", - " The force on metal sphere in N is = 7.6e-05\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:3 \\n \\n\"\n", - "#Given:\n", - "v=1000# potential\n", - "d=0.05# distance\n", - "q=3.8*10**-9# charge\n", - "\n", - "#solution:\n", - "e=v/d;#electric field\n", - "f=e;# force\n", - "f1=f*q;# force on metal sphere\n", - "print\"\\n The electric field in V/m is =\",e\n", - "print\"\\n The force in N/C is =\",f\n", - "print\"\\n The force on metal sphere in N is =\",f1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.2" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.2, Page:4 \n", - " \n", - "\n", - "The potential in V is = 80.0\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.2, Page:4 \\n \\n\"\n", - "#Given:\n", - "energy=2*10**-6\n", - "c=2.5*10**-8# velocity of light\n", - "#solution:\n", - "v=energy/c# potential\n", - "print\"The potential in V is =\",v\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.3" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.3, Page:5 \n", - " \n", - "\n", - "The wavelength in Angstroms is = 3.88289589025\n", - "\n", - " The photon wavelength in Angstroms is = 9.11075e-05\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.3, Page:5 \\n \\n\"\n", - "#Given:\n", - "\n", - "energy=10 #in electron volts\n", - "m=9.1*10**-31# mass of electron in kg\n", - "h=6.626*10**-34# planck's constant J.s\n", - "c=3*10^8# speed of light in m/s\n", - "\n", - "#solution (a):\n", - "energy1=energy*1.6*10**-19# energy in J\n", - "p=(2*m*energy1)**0.5# momentum\n", - "wavelength=h/p*(10)**10\n", - "\n", - "print\"The wavelength in Angstroms is =\",wavelength\n", - "\n", - "\n", - "#solution (b):\n", - "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", - "\n", - "print\"\\n The photon wavelength in Angstroms is =\",wavelength1\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example1.4" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.4, Page:6 \n", - " \n", - "\n", - "The energy in eV is = 150.768804945\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.4, Page:6 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "wavelength=10**-10\n", - "m=9.1*10**-31\n", - "h=6.626*10**-34\n", - "\n", - "#solution:\n", - "\n", - "p=h/wavelength\n", - "e=p*p/(2*m) # energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "\n", - "print\"The energy in eV is =\",e1\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.5" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.5, Page:8 \n", - " \n", - "\n", - "\n", - " The wavelength in 10^-5 Angstroms is = 0.655671822473\n", - "\n", - " The wavelength in 10^-5 Angstroms is = 0.648946805494\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.5, Page:8 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", - "h=6.6262*10**-34#planck's constant in J.s\n", - "energy1=120# in Mev for oxygen\n", - "energy2=140# in MeV for nitrogen\n", - "\n", - "#solution(a):\n", - "\n", - "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", - "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "\n", - "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength1\n", - "\n", - "#solution (b):\n", - "\n", - "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", - "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "\n", - "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength2\n", - "\n", - "# 1 Angstrom = 10^-10 m\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example1.6" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.6, Page:9 \n", - " \n", - "\n", - "The energy in eV is = 8275.0\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.6, Page:9 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "wavelength=1.5*10**-10\n", - "h=6.62*10**-34\n", - "c=3*10**8\n", - "\n", - "#solution:\n", - "\n", - "e=(h*c)/wavelength# energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "\n", - "print\"The energy in eV is =\",e1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.7" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.7, Page:10 \n", - " \n", - "\n", - "\n", - " The threshold frequency in s^-1 is = 1.23634168427e+15\n", - "\n", - " The threshold wavelength in Angstroms is = 2426.51367187\n", - "\n", - " The energy of photoelectrone in eV is = 3.911875\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.7, Page:10 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "E=5.12*1.6*10**-19# energy in J\n", - "h=6.626*10**-34\n", - "c=3*10**8\n", - "wavelength=200*10**-9\n", - "w=2.3# in eV\n", - "\n", - "#solution:\n", - "\n", - "tf=E/h# (part a)\n", - "print\"\\n The threshold frequency in s^-1 is =\",tf\n", - "\n", - "tl=c/tf*10**10# (part b)\n", - "print\"\\n The threshold wavelength in Angstroms is =\",tl\n", - "\n", - "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", - "\n", - "pe=e-w\n", - "\n", - "print\"\\n The energy of photoelectrone in eV is =\",pe\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.8" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.8, Page:10 \n", - " \n", - "\n", - "\n", - " The velocity of alpha particles for 1 MeV in m/s is = 6941056.08394\n", - "\n", - " The velocity of alpha particles for 2 MeV in m/s is = 9816135.6511\n", - "\n", - " The velocity of deuteron particles for 1 MeV in m/s is = 9816135.6511\n", - "\n", - " The velocity of deuteron particles for 2 MeV in m/s is = 13882112.1679\n", - "\n", - " The velocity of proton particles for 1 MeV in m/s is = 13882112.1679\n", - "\n", - " The velocity of proton particles for 2 MeV in m/s is = 19632271.3022\n" - ] - } - ], - "source": [ - "#cal of velocity of alpha particles,deuteron,proton\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.8, Page:10 \\n \\n\"\n", - "#Given:\n", - "e1=1 # in MeV\n", - "e2=2 # in MeV\n", - "ma=4 # in u(amu)\n", - "md=2 # in u(amu)\n", - "mp=1 # in u(amu)\n", - "\n", - "# 1u = 1.6*10^-27 Kg\n", - "\n", - "#solution: part a)For alpha particles\n", - "\n", - "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 1 MeV in m/s is =\",v1a# For 1 MeV\n", - "\n", - "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 2 MeV in m/s is =\",v2a# For 2 MeV\n", - "\n", - "#solution: part b)For deuteron particles\n", - "\n", - "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 1 MeV in m/s is =\",v1b # For 1 MeV\n", - "\n", - "\n", - "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 2 MeV in m/s is =\",v2b # For 2 MeV\n", - "\n", - "#solution: part c)For proton particles\n", - "\n", - "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 1 MeV in m/s is =\",v1p # For 1 MeV\n", - "\n", - "\n", - "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 2 MeV in m/s is =\",v2p # For 2 MeV\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.9" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.9, Page: \n", - " \n", - "\n", - "The energy in MeV is = 933.919973435\n" - ] - } - ], - "source": [ - "#cal of The energy\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.9, Page: \\n \\n\"\n", - "#Given:\n", - "\n", - "m=1/(6.023*10**23)#mass of 1 atom in g\n", - "m1=m*10**-3#mass of 1 atom in Kg\n", - "c=3*10**8# velocity in m/s\n", - "#solution:\n", - "\n", - "e=m1*c*c; # energy in J\n", - "e1=e/(1.6*10**-13)# energy in MeV\n", - "\n", - "print\"The energy in MeV is =\",e1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.10" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:11 \n", - " \n", - "\n", - "The energy in eV is = 13.2638658253\n" - ] - } - ], - "source": [ - "#cal of The energy\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:11 \\n \\n\"\n", - "#Given:\n", - "\n", - "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", - "\n", - "#solution:\n", - "\n", - "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", - "\n", - "print\"The energy in eV is =\",energy\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.11" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.11, Page:11 \n", - " \n", - "\n", - "\n", - " The mean binding energy of helium atom in MeV is = 7.0710038475\n", - "\n", - " The mean binding energy of oxygen atom in MeV is = 7.9800498909\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of helium and oxygen\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.11, Page:11 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078\n", - "mn=1.0087\n", - "ma=4.0026\n", - "mo=15.9949\n", - "Ah=4.0026 # atomic mass of helium\n", - "Ao=15.9949 # atomic mass of oxygen\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=(2*mh+2*mn-ma)*931 # in MeV\n", - "Bh=B1/Ah\n", - "print\"\\n The mean binding energy of helium atom in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=(8*mh+8*mn-mo)*931 # in MeV\n", - "Bo=B2/Ao\n", - "print\"\\n The mean binding energy of oxygen atom in MeV is =\",Bo\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.12" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.12, Page:12 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Be atom in MeV is = 7.05928572321\n", - "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" - ] - } - ], - "source": [ - "#cal of \n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.12, Page:12 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "ABe=8.0053; # atomic mass of beryllium\n", - "\n", - "#solution:\n", - "\n", - "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", - "Bh=B1/ABe;\n", - "print\"\\n The mean binding energy of Be atom in MeV is =\",Bh\n", - "\n", - "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.13" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.13, Page:12 \n", - " \n", - "\n", - "\n", - " The amount of coal required in Kg is = 2499.85671416\n" - ] - } - ], - "source": [ - "#cal of amount of coal\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.13, Page:12 \\n \\n\"\n", - "#Given:\n", - "\n", - "e=200; # in Mev\n", - "m=0.235; # weight of uranium atom in Kg\n", - "enthalpy=393.5; # in KJ/mol\n", - "Na=6.02*10**23;\n", - "\n", - "\n", - "#solution:\n", - "e1=e*1.6*10**-19*10**6;\n", - "atoms=Na/m;\n", - "e2=atoms*e1;#energy released in J\n", - "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", - "m2=m1/1000;# in tons\n", - "print\"\\n The amount of coal required in Kg is =\", m2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.14" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.14, Page:13 \n", - " \n", - "\n", - "\n", - " The energy release in part (a) in eV/molecule is = 2.51472\n", - "\n", - " The energy release in part (b) in eV/molecule is = 9.22688\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.14, Page:13 \\n \\n\"\n", - "#Given:\n", - "H1=241.8; # in KJ/mol\n", - "H2=887.2; # in KJ/mol\n", - "# 1 KJ/mol = 0.0104 eV/atom\n", - "\n", - "#solution: part (a)\n", - "e1=H1*0.0104;\n", - "print\"\\n The energy release in part (a) in eV/molecule is =\",e1\n", - "\n", - "#solution: part (b)\n", - "e2=H2*0.0104;\n", - "print\"\\n The energy release in part (b) in eV/molecule is =\",e2\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.15" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.15, Page:14 \n", - " \n", - "\n", - "\n", - " The energy release in part (a) in KJ/mol of carbondioxide is = 394.912\n", - "\n", - " The energy release in part (b) in KJ/mol of alumina is = 1675.968\n", - "\n", - " The energy release in part (c) in MJ/atom of U(235) is = 19264000.0\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.15, Page:14 \\n \\n\"\n", - "#Given:\n", - "H1=4.1; # in eV/molecule\n", - "H2=17.4; # in eV/molecule\n", - "H3=200;# in MeV/atom of U\n", - "\n", - "# 1 eV/atom = 96.32 KJ/mol\n", - "\n", - "#solution: part (a)\n", - "e1=H1*96.32;\n", - "print\"\\n The energy release in part (a) in KJ/mol of carbondioxide is =\",e1\n", - "\n", - "#solution: part (b)\n", - "e2=H2*96.32;\n", - "print\"\\n The energy release in part (b) in KJ/mol of alumina is =\",e2\n", - "\n", - "#solution: part (c)\n", - "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", - "print\"\\n The energy release in part (c) in MJ/atom of U(235) is =\",e3\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.16" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.16, Page:15 \n", - " \n", - "\n", - "\n", - " The rate of energy release in W is 949251379.039\n" - ] - } - ], - "source": [ - "#cal of The rate of energy release\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.16, Page:15 \\n \\n\"\n", - "#Given:\n", - "e=200; #MeV/ atom of U\n", - "# 1 eV = 1.6*10^-19 J\n", - "Na=6.023*10**23;\n", - "M=0.235; # mass in Kg\n", - "\n", - "#solution:\n", - "\n", - "e1=e*1.6*10**-19*10**6;\n", - "A=Na/M;\n", - "e2=A*e1; # energy released in MJ/day\n", - "e3=e2/(24*3600);\n", - "print\"\\n The rate of energy release in W is \",e3\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.17" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.17, Page:16 \n", - " \n", - "\n", - "\n", - " The mass loss in 10^-27 Kg/He formed is = 0.046412244898\n" - ] - } - ], - "source": [ - "#cal of The mass loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.17, Page:16 \\n \\n\"\n", - "#Given:\n", - "e=26.03; # in MeV\n", - "\n", - "#solution:\n", - "\n", - "loss=e/931; #in atomic mass units (u)\n", - "# 1 u = 1.66*10^-27 Kg\n", - "m=(loss*1.66*10**-27)/(1*10**-27);\n", - "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",m\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.18" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.18, Page:17 \n", - " \n", - "\n", - "\n", - " The energy loss in MeV is = 4.03123\n" - ] - } - ], - "source": [ - "#cal of The energy loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.18, Page:17 \\n \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mt=3.016049;\n", - "md=2.014102;\n", - "\n", - "#solution:\n", - "\n", - "m1=(mh+mt-2*md);\n", - "e=(-m1)*931; # in MeV\n", - "print\"\\n The energy loss in MeV is =\",e\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.19" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.19, Page:18 \n", - " \n", - "\n", - "\n", - " The mean binding energy of tritium atom in MeV is = 2.81085817903\n", - "\n", - " The mean binding energy of nickel atom in MeV is = 8.71580311296\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of tritium and nickel atom\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.19, Page:18 \\n \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mn=1.008665;\n", - "mt=3.016049; # atomic mass of Tritium\n", - "mNi=59.93528; # atomic mass of Nickel\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=(1*mh+2*mn-mt)*931; # in MeV\n", - "Bh=B1/mt;\n", - "print\"\\n The mean binding energy of tritium atom in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", - "Bo=B2/mNi;\n", - "print\"\\n The mean binding energy of nickel atom in MeV is =\",Bo\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.20" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.20, Page:19 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Cl (35) atom in MeV is = 8.52810201079\n", - "\n", - " The mean binding energy of Cl (37) atom in MeV is = 8.57839008383\n", - "\n", - " The increase in mean binding energy of Cl atom in MeV is = 0.0502880730447\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Cl\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.20, Page:19 \\n \\n\"\n", - "#Given:\n", - "mh=1.00783;\n", - "mn=1.00867;\n", - "m35=34.96885; # atomic mass of Cl (35)\n", - "m37=36.96590; # atomic mass of Cl (37)\n", - "\n", - "#solution:\n", - "\n", - "B1=(17*mh+18*mn-m35)*931; # in MeV\n", - "Bh=B1/m35;\n", - "print\"\\n The mean binding energy of Cl (35) atom in MeV is =\",Bh\n", - "\n", - "B2=(17*mh+20*mn-m37)*931; # in MeV\n", - "Bo=B2/m37;\n", - "print\"\\n The mean binding energy of Cl (37) atom in MeV is =\",Bo\n", - "\n", - "Bi=Bo-Bh;\n", - "print\"\\n The increase in mean binding energy of Cl atom in MeV is =\",Bi\n", - "\n", - "# NOTE: The answer depends upon how much precise value you take for atomic masses.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.21" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.21, Page:20 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Na(22) in MeV is = 7.92358978299\n", - "\n", - " The mean binding energy of Na(23)in MeV is = 8.11544250059\n", - "\n", - " The mean binding energy of Na(24) in MeV is = 8.07172719656\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Na\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.21, Page:20 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "m22=21.99431;# atomic mass of Na 22\n", - "m23=22.9898;# atomic mass of Na 23\n", - "m24=23.9909;# atomic mass of Na 24\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", - "Bh=B1/m22;\n", - "print\"\\n The mean binding energy of Na(22) in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", - "Bo=B2/m23;\n", - "print\"\\n The mean binding energy of Na(23)in MeV is =\",Bo\n", - "\n", - "# part (c)\n", - "\n", - "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", - "Bs=B3/m24;\n", - "print\"\\n The mean binding energy of Na(24) in MeV is =\",Bs\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Raj Phani/chapter_1_1.ipynb b/sample_notebooks/Raj Phani/chapter_1_1.ipynb deleted file mode 100755 index 6bb4fa49..00000000 --- a/sample_notebooks/Raj Phani/chapter_1_1.ipynb +++ /dev/null @@ -1,1118 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# chapter1: electric charge" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.1" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:3 \n", - " \n", - "\n", - "\n", - " The electric field in V/m is = 20000.0\n", - "\n", - " The force in N/C is = 20000.0\n", - "\n", - " The force on metal sphere in N is = 7.6e-05\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:3 \\n \\n\"\n", - "#Given:\n", - "v=1000# potential\n", - "d=0.05# distance\n", - "q=3.8*10**-9# charge\n", - "\n", - "#solution:\n", - "e=v/d;#electric field\n", - "f=e;# force\n", - "f1=f*q;# force on metal sphere\n", - "print\"\\n The electric field in V/m is =\",e\n", - "print\"\\n The force in N/C is =\",f\n", - "print\"\\n The force on metal sphere in N is =\",f1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.2" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.2, Page:4 \n", - " \n", - "\n", - "The potential in V is = 80.0\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.2, Page:4 \\n \\n\"\n", - "#Given:\n", - "energy=2*10**-6\n", - "c=2.5*10**-8# velocity of light\n", - "#solution:\n", - "v=energy/c# potential\n", - "print\"The potential in V is =\",v\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.3" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.3, Page:5 \n", - " \n", - "\n", - "The wavelength in Angstroms is = 3.88289589025\n", - "\n", - " The photon wavelength in Angstroms is = 9.11075e-05\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.3, Page:5 \\n \\n\"\n", - "#Given:\n", - "\n", - "energy=10 #in electron volts\n", - "m=9.1*10**-31# mass of electron in kg\n", - "h=6.626*10**-34# planck's constant J.s\n", - "c=3*10^8# speed of light in m/s\n", - "\n", - "#solution (a):\n", - "energy1=energy*1.6*10**-19# energy in J\n", - "p=(2*m*energy1)**0.5# momentum\n", - "wavelength=h/p*(10)**10\n", - "\n", - "print\"The wavelength in Angstroms is =\",wavelength\n", - "\n", - "\n", - "#solution (b):\n", - "wavelength1=h*c/energy1*(10)**10;#photon wavelength\n", - "\n", - "print\"\\n The photon wavelength in Angstroms is =\",wavelength1\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example1.4" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.4, Page:6 \n", - " \n", - "\n", - "The energy in eV is = 150.768804945\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.4, Page:6 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "wavelength=10**-10\n", - "m=9.1*10**-31\n", - "h=6.626*10**-34\n", - "\n", - "#solution:\n", - "\n", - "p=h/wavelength\n", - "e=p*p/(2*m) # energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "\n", - "print\"The energy in eV is =\",e1\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.5" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.5, Page:8 \n", - " \n", - "\n", - "\n", - " The wavelength in 10^-5 Angstroms is = 0.655671822473\n", - "\n", - " The wavelength in 10^-5 Angstroms is = 0.648946805494\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.5, Page:8 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "m=1.66*10**-27# 1u=1.66*10^-27 kg\n", - "h=6.6262*10**-34#planck's constant in J.s\n", - "energy1=120# in Mev for oxygen\n", - "energy2=140# in MeV for nitrogen\n", - "\n", - "#solution(a):\n", - "\n", - "p=(2*m*16*energy1*(1.6022*10**-13))**0.5\n", - "wavelength1=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "\n", - "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength1\n", - "\n", - "#solution (b):\n", - "\n", - "p=(2*m*14*energy2*(1.6022*10**-13))**0.5\n", - "wavelength2=h/p*(10)**15#wavelength in 10^-5 Angstroms\n", - "\n", - "print\"\\n The wavelength in 10^-5 Angstroms is =\",wavelength2\n", - "\n", - "# 1 Angstrom = 10^-10 m\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example1.6" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.6, Page:9 \n", - " \n", - "\n", - "The energy in eV is = 8275.0\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.6, Page:9 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "wavelength=1.5*10**-10\n", - "h=6.62*10**-34\n", - "c=3*10**8\n", - "\n", - "#solution:\n", - "\n", - "e=(h*c)/wavelength# energy in J\n", - "e1=e/(1.6*10**-19)# energy in eV\n", - "\n", - "print\"The energy in eV is =\",e1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.7" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.7, Page:10 \n", - " \n", - "\n", - "\n", - " The threshold frequency in s^-1 is = 1.23634168427e+15\n", - "\n", - " The threshold wavelength in Angstroms is = 2426.51367187\n", - "\n", - " The energy of photoelectrone in eV is = 3.911875\n" - ] - } - ], - "source": [ - "#cal of elelectric field and force\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.7, Page:10 \\n \\n\"\n", - "\n", - "#Given:\n", - "\n", - "E=5.12*1.6*10**-19# energy in J\n", - "h=6.626*10**-34\n", - "c=3*10**8\n", - "wavelength=200*10**-9\n", - "w=2.3# in eV\n", - "\n", - "#solution:\n", - "\n", - "tf=E/h# (part a)\n", - "print\"\\n The threshold frequency in s^-1 is =\",tf\n", - "\n", - "tl=c/tf*10**10# (part b)\n", - "print\"\\n The threshold wavelength in Angstroms is =\",tl\n", - "\n", - "e=(h*c)/(wavelength*1.6*10**-19)# photon energy in eV (part c)\n", - "\n", - "pe=e-w\n", - "\n", - "print\"\\n The energy of photoelectrone in eV is =\",pe\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.8" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.8, Page:10 \n", - " \n", - "\n", - "\n", - " The velocity of alpha particles for 1 MeV in m/s is = 6941056.08394\n", - "\n", - " The velocity of alpha particles for 2 MeV in m/s is = 9816135.6511\n", - "\n", - " The velocity of deuteron particles for 1 MeV in m/s is = 9816135.6511\n", - "\n", - " The velocity of deuteron particles for 2 MeV in m/s is = 13882112.1679\n", - "\n", - " The velocity of proton particles for 1 MeV in m/s is = 13882112.1679\n", - "\n", - " The velocity of proton particles for 2 MeV in m/s is = 19632271.3022\n" - ] - } - ], - "source": [ - "#cal of velocity of alpha particles,deuteron,proton\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.8, Page:10 \\n \\n\"\n", - "#Given:\n", - "e1=1 # in MeV\n", - "e2=2 # in MeV\n", - "ma=4 # in u(amu)\n", - "md=2 # in u(amu)\n", - "mp=1 # in u(amu)\n", - "\n", - "# 1u = 1.6*10^-27 Kg\n", - "\n", - "#solution: part a)For alpha particles\n", - "\n", - "v1a=((2*e1*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 1 MeV in m/s is =\",v1a# For 1 MeV\n", - "\n", - "v2a=((2*e2*10**6*1.6*10**-19)/(ma*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of alpha particles for 2 MeV in m/s is =\",v2a# For 2 MeV\n", - "\n", - "#solution: part b)For deuteron particles\n", - "\n", - "v1b=((2*e1*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 1 MeV in m/s is =\",v1b # For 1 MeV\n", - "\n", - "\n", - "v2b=((2*e2*10**6*1.6*10**-19)/(md*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of deuteron particles for 2 MeV in m/s is =\",v2b # For 2 MeV\n", - "\n", - "#solution: part c)For proton particles\n", - "\n", - "v1p=((2*e1*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 1 MeV in m/s is =\",v1p # For 1 MeV\n", - "\n", - "\n", - "v2p=((2*e2*10**6*1.6*10**-19)/(mp*1.6605*10**-27))**.5\n", - "print\"\\n The velocity of proton particles for 2 MeV in m/s is =\",v2p # For 2 MeV\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.9" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.9, Page:10 \n", - " \n", - "\n", - "The energy in MeV is = 933.919973435\n" - ] - } - ], - "source": [ - "#cal of The energy\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.9, Page:10 \\n \\n\"\n", - "#Given:\n", - "\n", - "m=1/(6.023*10**23)#mass of 1 atom in g\n", - "m1=m*10**-3#mass of 1 atom in Kg\n", - "c=3*10**8# velocity in m/s\n", - "#solution:\n", - "\n", - "e=m1*c*c; # energy in J\n", - "e1=e/(1.6*10**-13)# energy in MeV\n", - "\n", - "print\"The energy in MeV is =\",e1\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.10" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:11 \n", - " \n", - "\n", - "The energy in eV is = 13.2638658253\n" - ] - } - ], - "source": [ - "#cal of The energy\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:11 \\n \\n\"\n", - "#Given:\n", - "\n", - "enthalpy=1278 # enthalpy of combustion in kJ/mol\n", - "\n", - "#solution:\n", - "\n", - "energy=(enthalpy*1000)/(6.022*10**23*1.6*10**-19)\n", - "\n", - "print\"The energy in eV is =\",energy\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.11" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.11, Page:11 \n", - " \n", - "\n", - "\n", - " The mean binding energy of helium atom in MeV is = 7.0710038475\n", - "\n", - " The mean binding energy of oxygen atom in MeV is = 7.9800498909\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of helium and oxygen\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.11, Page:11 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078\n", - "mn=1.0087\n", - "ma=4.0026\n", - "mo=15.9949\n", - "Ah=4.0026 # atomic mass of helium\n", - "Ao=15.9949 # atomic mass of oxygen\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=(2*mh+2*mn-ma)*931 # in MeV\n", - "Bh=B1/Ah\n", - "print\"\\n The mean binding energy of helium atom in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=(8*mh+8*mn-mo)*931 # in MeV\n", - "Bo=B2/Ao\n", - "print\"\\n The mean binding energy of oxygen atom in MeV is =\",Bo\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.12" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.12, Page:12 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Be atom in MeV is = 7.05928572321\n", - "From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\n" - ] - } - ], - "source": [ - "#cal of \n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.12, Page:12 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "ABe=8.0053; # atomic mass of beryllium\n", - "\n", - "#solution:\n", - "\n", - "B1=(4*mh+4*mn-ABe)*931; # in MeV\n", - "Bh=B1/ABe;\n", - "print\"\\n The mean binding energy of Be atom in MeV is =\",Bh\n", - "\n", - "print\"From previous problem we have the avg. binding energy of helium atom is 7.08 MeV, Hence Be is unstable to fission into 2 alphas\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.13" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.13, Page:12 \n", - " \n", - "\n", - "\n", - " The amount of coal required in Kg is = 2499.85671416\n" - ] - } - ], - "source": [ - "#cal of amount of coal\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.13, Page:12 \\n \\n\"\n", - "#Given:\n", - "\n", - "e=200; # in Mev\n", - "m=0.235; # weight of uranium atom in Kg\n", - "enthalpy=393.5; # in KJ/mol\n", - "Na=6.02*10**23;\n", - "\n", - "\n", - "#solution:\n", - "e1=e*1.6*10**-19*10**6;\n", - "atoms=Na/m;\n", - "e2=atoms*e1;#energy released in J\n", - "m1=(e2*12)/(393.5*1000*1000);# in Kg\n", - "m2=m1/1000;# in tons\n", - "print\"\\n The amount of coal required in Kg is =\", m2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.14" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.14, Page:13 \n", - " \n", - "\n", - "\n", - " The energy release in part (a) in eV/molecule is = 2.51472\n", - "\n", - " The energy release in part (b) in eV/molecule is = 9.22688\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.14, Page:13 \\n \\n\"\n", - "#Given:\n", - "H1=241.8; # in KJ/mol\n", - "H2=887.2; # in KJ/mol\n", - "# 1 KJ/mol = 0.0104 eV/atom\n", - "\n", - "#solution: part (a)\n", - "e1=H1*0.0104;\n", - "print\"\\n The energy release in part (a) in eV/molecule is =\",e1\n", - "\n", - "#solution: part (b)\n", - "e2=H2*0.0104;\n", - "print\"\\n The energy release in part (b) in eV/molecule is =\",e2\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.15" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.15, Page:14 \n", - " \n", - "\n", - "\n", - " The energy release in part (a) in KJ/mol of carbondioxide is = 394.912\n", - "\n", - " The energy release in part (b) in KJ/mol of alumina is = 1675.968\n", - "\n", - " The energy release in part (c) in MJ/atom of U(235) is = 19264000.0\n" - ] - } - ], - "source": [ - "#cal of The energy releases\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.15, Page:14 \\n \\n\"\n", - "#Given:\n", - "H1=4.1; # in eV/molecule\n", - "H2=17.4; # in eV/molecule\n", - "H3=200;# in MeV/atom of U\n", - "\n", - "# 1 eV/atom = 96.32 KJ/mol\n", - "\n", - "#solution: part (a)\n", - "e1=H1*96.32;\n", - "print\"\\n The energy release in part (a) in KJ/mol of carbondioxide is =\",e1\n", - "\n", - "#solution: part (b)\n", - "e2=H2*96.32;\n", - "print\"\\n The energy release in part (b) in KJ/mol of alumina is =\",e2\n", - "\n", - "#solution: part (c)\n", - "e3=H3*1000*96.32;# in MJ/atom of U(235)\n", - "print\"\\n The energy release in part (c) in MJ/atom of U(235) is =\",e3\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.16" - ] - }, - { - "cell_type": "code", - "execution_count": 37, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.16, Page:15 \n", - " \n", - "\n", - "\n", - " The rate of energy release in W is 949251379.039\n" - ] - } - ], - "source": [ - "#cal of The rate of energy release\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.16, Page:15 \\n \\n\"\n", - "#Given:\n", - "e=200; #MeV/ atom of U\n", - "# 1 eV = 1.6*10^-19 J\n", - "Na=6.023*10**23;\n", - "M=0.235; # mass in Kg\n", - "\n", - "#solution:\n", - "\n", - "e1=e*1.6*10**-19*10**6;\n", - "A=Na/M;\n", - "e2=A*e1; # energy released in MJ/day\n", - "e3=e2/(24*3600);\n", - "print\"\\n The rate of energy release in W is \",e3\n", - "\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.17" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.17, Page:16 \n", - " \n", - "\n", - "\n", - " The mass loss in 10^-27 Kg/He formed is = 0.046412244898\n" - ] - } - ], - "source": [ - "#cal of The mass loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.17, Page:16 \\n \\n\"\n", - "#Given:\n", - "e=26.03; # in MeV\n", - "\n", - "#solution:\n", - "\n", - "loss=e/931; #in atomic mass units (u)\n", - "# 1 u = 1.66*10^-27 Kg\n", - "m=(loss*1.66*10**-27)/(1*10**-27);\n", - "print\"\\n The mass loss in 10^-27 Kg/He formed is =\",m\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.18" - ] - }, - { - "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.18, Page:17 \n", - " \n", - "\n", - "\n", - " The energy loss in MeV is = 4.03123\n" - ] - } - ], - "source": [ - "#cal of The energy loss\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.18, Page:17 \\n \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mt=3.016049;\n", - "md=2.014102;\n", - "\n", - "#solution:\n", - "\n", - "m1=(mh+mt-2*md);\n", - "e=(-m1)*931; # in MeV\n", - "print\"\\n The energy loss in MeV is =\",e\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.19" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.19, Page:18 \n", - " \n", - "\n", - "\n", - " The mean binding energy of tritium atom in MeV is = 2.81085817903\n", - "\n", - " The mean binding energy of nickel atom in MeV is = 8.71580311296\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of tritium and nickel atom\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.19, Page:18 \\n \\n\"\n", - "#Given:\n", - "mh=1.007825;\n", - "mn=1.008665;\n", - "mt=3.016049; # atomic mass of Tritium\n", - "mNi=59.93528; # atomic mass of Nickel\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=(1*mh+2*mn-mt)*931; # in MeV\n", - "Bh=B1/mt;\n", - "print\"\\n The mean binding energy of tritium atom in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=(28*mh+32*mn-mNi)*931; # in MeV\n", - "Bo=B2/mNi;\n", - "print\"\\n The mean binding energy of nickel atom in MeV is =\",Bo\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.20" - ] - }, - { - "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.20, Page:19 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Cl (35) atom in MeV is = 8.52810201079\n", - "\n", - " The mean binding energy of Cl (37) atom in MeV is = 8.57839008383\n", - "\n", - " The increase in mean binding energy of Cl atom in MeV is = 0.0502880730447\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Cl\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.20, Page:19 \\n \\n\"\n", - "#Given:\n", - "mh=1.00783;\n", - "mn=1.00867;\n", - "m35=34.96885; # atomic mass of Cl (35)\n", - "m37=36.96590; # atomic mass of Cl (37)\n", - "\n", - "#solution:\n", - "\n", - "B1=(17*mh+18*mn-m35)*931; # in MeV\n", - "Bh=B1/m35;\n", - "print\"\\n The mean binding energy of Cl (35) atom in MeV is =\",Bh\n", - "\n", - "B2=(17*mh+20*mn-m37)*931; # in MeV\n", - "Bo=B2/m37;\n", - "print\"\\n The mean binding energy of Cl (37) atom in MeV is =\",Bo\n", - "\n", - "Bi=Bo-Bh;\n", - "print\"\\n The increase in mean binding energy of Cl atom in MeV is =\",Bi\n", - "\n", - "# NOTE: The answer depends upon how much precise value you take for atomic masses.\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.21" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.21, Page:20 \n", - " \n", - "\n", - "\n", - " The mean binding energy of Na(22) in MeV is = 7.92358978299\n", - "\n", - " The mean binding energy of Na(23)in MeV is = 8.11544250059\n", - "\n", - " The mean binding energy of Na(24) in MeV is = 8.07172719656\n" - ] - } - ], - "source": [ - "#cal of mean binding energy of Na\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.21, Page:20 \\n \\n\"\n", - "#Given:\n", - "mh=1.0078;\n", - "mn=1.0087;\n", - "m22=21.99431;# atomic mass of Na 22\n", - "m23=22.9898;# atomic mass of Na 23\n", - "m24=23.9909;# atomic mass of Na 24\n", - "\n", - "#solution:\n", - "\n", - "# part (a)\n", - "\n", - "B1=((11*mh+11*mn)-m22)*931; # in MeV\n", - "Bh=B1/m22;\n", - "print\"\\n The mean binding energy of Na(22) in MeV is =\",Bh\n", - "\n", - "# part (b)\n", - "\n", - "B2=((11*mh+12*mn)-m23)*931; # in MeV\n", - "Bo=B2/m23;\n", - "print\"\\n The mean binding energy of Na(23)in MeV is =\",Bo\n", - "\n", - "# part (c)\n", - "\n", - "B3=((11*mh+13*mn)-m24)*931; # in MeV\n", - "Bs=B3/m24;\n", - "print\"\\n The mean binding energy of Na(24) in MeV is =\",Bs\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RaviGarg/RaviGarg_version_backup/chap1.ipynb b/sample_notebooks/RaviGarg/RaviGarg_version_backup/chap1.ipynb new file mode 100755 index 00000000..36a74a3e --- /dev/null +++ b/sample_notebooks/RaviGarg/RaviGarg_version_backup/chap1.ipynb @@ -0,0 +1,462 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:1a5424f1a289fa2ea02065679fbda8bfa43c7eec69070520139086e97a973104" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 Coulombs Law" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q=-3*10**-7 #C\n", + "e=-1.6*10**-19 #C\n", + "\n", + "#Calculation\n", + "n=q/e\n", + "\n", + "#Result\n", + "print\"Number of electrons transferred from wool to polythene is\", n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of electrons transferred from wool to polythene is 1.875e+12\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=3.11 #g\n", + "Z=29\n", + "A=63.5 \n", + "N=6.023*10**23\n", + "e=1.6*10**-19\n", + "\n", + "#Calculation\n", + "n=(N*m)/A\n", + "n1=n*Z\n", + "q=n1*e\n", + "\n", + "#Result\n", + "print\"Total positive or negative charge is\", round(q*10**-5,2),\"*10**5 C\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total positive or negative charge is 1.37 *10**5 C\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=2*10**-7\n", + "q2=3*10**-7\n", + "r=0.3 #m\n", + "a=9*10**9\n", + "\n", + "#Calculation\n", + "F=(a*q1*q2)/r**2\n", + "\n", + "#Result\n", + "print\"Force between two small charged spheres is\", F*10**3,\"*10**-3\",\"N(repulsive\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Force between two small charged spheres is 6.0 *10**-3 N(repulsive\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 page no. 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "F=3.7*10**-9 #N\n", + "r=5*10**-10 #m\n", + "a=9*10**9\n", + "q1=1.6*10**-19\n", + "\n", + "#Calculation\n", + "import math\n", + "n=math.sqrt(F*r**2/(a*q1**2))\n", + "\n", + "#Result\n", + "print\"number of electrons is\", round(n,0)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "number of electrons is 2.0\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=0.4*10**-6 #C\n", + "q2=0.8*10**-6 #C\n", + "F12=0.2 #N\n", + "a=9.0*10**9\n", + "\n", + "#Calculation\n", + "import math\n", + "r=math.sqrt((a*q1*q2)/F12)\n", + "\n", + "#Result\n", + "print\"(a) Distance between two spheres is\", r,\"m\"\n", + "print\"(b) Force on charge q2 due to q1 is\",F12,\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Distance between two spheres is 0.12 m\n", + "(b) Force on charge q2 due to q1 is 0.2 N\n" + ] + } + ], + "prompt_number": 32 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 Page no 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=5*10**-8 #C\n", + "m1=8*10**-3 #Kg\n", + "a=9*10**9\n", + "r=0.05 #m\n", + "\n", + "#Calculation\n", + "q2=m1*9.8*r**2/(a*q1)\n", + "\n", + "#Result\n", + "print\"Charge q2 is\", round(q2*10**7,2)*10**-7,\"C(positive)\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Charge q2 is 4.36e-07 C(positive)\n" + ] + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7 Page no 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=6.5*10**-7 #C\n", + "q2=6.5*10**-7\n", + "r=0.5 #m\n", + "a=9*10**9\n", + "K=80.0\n", + "\n", + "#Calculation\n", + "Fair=a*q1*q2/r**2\n", + "r1=0.5/2.0\n", + "F1=a*4*q1*q2/r1**2\n", + "Fwater=Fair/K\n", + "\n", + "#Result\n", + "print\"(a) Mutual force of electrostatic repulsion is\", Fair*10**2,\"*10**-2 N\"\n", + "print\"(b) (i) Force of repulsion is\", round(F1,4),\"N\"\n", + "print \"(ii) Force of repulsion is\",round(Fwater*10**4,1),\"*10**-4 N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Mutual force of electrostatic repulsion is 1.521 *10**-2 N\n", + "(b) (i) Force of repulsion is 0.2434 N\n", + "(ii) Force of repulsion is 1.9 *10**-4 N\n" + ] + } + ], + "prompt_number": 57 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8 Page no 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=6.5*10**-7 #C\n", + "r=0.05 #m\n", + "a=9*10**9\n", + "r1=0.5\n", + "\n", + "#Calculation\n", + "q11=q1/2.0\n", + "q21=(q1+q11)/2.0\n", + "F=(a*q11*q21)/r1**2\n", + "\n", + "#Result\n", + "print\"New force of repulsion between A and B is\", round(F*10**3,3),\"*10**-3 N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "New force of repulsion between A and B is 5.704 *10**-3 N\n" + ] + } + ], + "prompt_number": 64 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.10 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "a=9.0*10**9\n", + "r=0.2\n", + "m=9.8*10**-3\n", + "a1=0.1\n", + "a2=0.5\n", + "\n", + "#Calculation\n", + "import math\n", + "a11=m*(a1/(math.sqrt(a2**2-a1**2)))\n", + "q=math.sqrt((a11*r**2)/a)\n", + "\n", + "#Result\n", + "print\"Charge on each ball is\", round(q*10**8,2)*10**-6,\"C\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Charge on each ball is 9.43e-06 C\n" + ] + } + ], + "prompt_number": 100 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.12 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "qa=10**-5 #C\n", + "qb=5*10**-6 #C\n", + "qc=-5*10**-6 #C\n", + "r=0.1 #m\n", + "a=9*10**9\n", + "\n", + "#Calculation\n", + "import math\n", + "Fab=(a*qa*qb)/r**2\n", + "Fac=Fab\n", + "F=math.sqrt(Fab**2+Fac**2+(2*Fab*Fac*math.cos(120*3.14/180.0)))\n", + "\n", + "#Result\n", + "print\"Resultant force is\", round(F,0),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant force is 45.0 N\n" + ] + } + ], + "prompt_number": 75 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.13 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "qa=1\n", + "qb=100\n", + "ab=10\n", + "a=9*10**9\n", + "qd=75\n", + "a1=5\n", + "\n", + "#Calculation\n", + "import math\n", + "Fab=(a*qa*qb)/ab**2\n", + "Fac=Fab\n", + "Fac1=(a*qa*qd)/(ab**2-a1**2)\n", + "Fx=Fab*math.cos(60*3.14/180.0)+Fac1*math.cos(60*3.14/180.0)\n", + "Fy=Fac\n", + "F=math.sqrt(Fx**2+Fy**2)\n", + "B=Fy/Fx\n", + "B1=math.atan(B)*180/3.14\n", + "\n", + "#Result\n", + "print\"Resultant force on charge qa is inclined at\", round(B1,0),\"Degree\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant force on charge qa is inclined at 45.0 Degree\n" + ] + } + ], + "prompt_number": 90 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/RaviGarg/chap1.ipynb b/sample_notebooks/RaviGarg/chap1.ipynb deleted file mode 100755 index 36a74a3e..00000000 --- a/sample_notebooks/RaviGarg/chap1.ipynb +++ /dev/null @@ -1,462 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:1a5424f1a289fa2ea02065679fbda8bfa43c7eec69070520139086e97a973104" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 Coulombs Law" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q=-3*10**-7 #C\n", - "e=-1.6*10**-19 #C\n", - "\n", - "#Calculation\n", - "n=q/e\n", - "\n", - "#Result\n", - "print\"Number of electrons transferred from wool to polythene is\", n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Number of electrons transferred from wool to polythene is 1.875e+12\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=3.11 #g\n", - "Z=29\n", - "A=63.5 \n", - "N=6.023*10**23\n", - "e=1.6*10**-19\n", - "\n", - "#Calculation\n", - "n=(N*m)/A\n", - "n1=n*Z\n", - "q=n1*e\n", - "\n", - "#Result\n", - "print\"Total positive or negative charge is\", round(q*10**-5,2),\"*10**5 C\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total positive or negative charge is 1.37 *10**5 C\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=2*10**-7\n", - "q2=3*10**-7\n", - "r=0.3 #m\n", - "a=9*10**9\n", - "\n", - "#Calculation\n", - "F=(a*q1*q2)/r**2\n", - "\n", - "#Result\n", - "print\"Force between two small charged spheres is\", F*10**3,\"*10**-3\",\"N(repulsive\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Force between two small charged spheres is 6.0 *10**-3 N(repulsive\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4 page no. 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "F=3.7*10**-9 #N\n", - "r=5*10**-10 #m\n", - "a=9*10**9\n", - "q1=1.6*10**-19\n", - "\n", - "#Calculation\n", - "import math\n", - "n=math.sqrt(F*r**2/(a*q1**2))\n", - "\n", - "#Result\n", - "print\"number of electrons is\", round(n,0)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "number of electrons is 2.0\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=0.4*10**-6 #C\n", - "q2=0.8*10**-6 #C\n", - "F12=0.2 #N\n", - "a=9.0*10**9\n", - "\n", - "#Calculation\n", - "import math\n", - "r=math.sqrt((a*q1*q2)/F12)\n", - "\n", - "#Result\n", - "print\"(a) Distance between two spheres is\", r,\"m\"\n", - "print\"(b) Force on charge q2 due to q1 is\",F12,\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Distance between two spheres is 0.12 m\n", - "(b) Force on charge q2 due to q1 is 0.2 N\n" - ] - } - ], - "prompt_number": 32 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6 Page no 13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=5*10**-8 #C\n", - "m1=8*10**-3 #Kg\n", - "a=9*10**9\n", - "r=0.05 #m\n", - "\n", - "#Calculation\n", - "q2=m1*9.8*r**2/(a*q1)\n", - "\n", - "#Result\n", - "print\"Charge q2 is\", round(q2*10**7,2)*10**-7,\"C(positive)\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Charge q2 is 4.36e-07 C(positive)\n" - ] - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7 Page no 13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=6.5*10**-7 #C\n", - "q2=6.5*10**-7\n", - "r=0.5 #m\n", - "a=9*10**9\n", - "K=80.0\n", - "\n", - "#Calculation\n", - "Fair=a*q1*q2/r**2\n", - "r1=0.5/2.0\n", - "F1=a*4*q1*q2/r1**2\n", - "Fwater=Fair/K\n", - "\n", - "#Result\n", - "print\"(a) Mutual force of electrostatic repulsion is\", Fair*10**2,\"*10**-2 N\"\n", - "print\"(b) (i) Force of repulsion is\", round(F1,4),\"N\"\n", - "print \"(ii) Force of repulsion is\",round(Fwater*10**4,1),\"*10**-4 N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Mutual force of electrostatic repulsion is 1.521 *10**-2 N\n", - "(b) (i) Force of repulsion is 0.2434 N\n", - "(ii) Force of repulsion is 1.9 *10**-4 N\n" - ] - } - ], - "prompt_number": 57 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8 Page no 13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=6.5*10**-7 #C\n", - "r=0.05 #m\n", - "a=9*10**9\n", - "r1=0.5\n", - "\n", - "#Calculation\n", - "q11=q1/2.0\n", - "q21=(q1+q11)/2.0\n", - "F=(a*q11*q21)/r1**2\n", - "\n", - "#Result\n", - "print\"New force of repulsion between A and B is\", round(F*10**3,3),\"*10**-3 N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "New force of repulsion between A and B is 5.704 *10**-3 N\n" - ] - } - ], - "prompt_number": 64 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.10 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "a=9.0*10**9\n", - "r=0.2\n", - "m=9.8*10**-3\n", - "a1=0.1\n", - "a2=0.5\n", - "\n", - "#Calculation\n", - "import math\n", - "a11=m*(a1/(math.sqrt(a2**2-a1**2)))\n", - "q=math.sqrt((a11*r**2)/a)\n", - "\n", - "#Result\n", - "print\"Charge on each ball is\", round(q*10**8,2)*10**-6,\"C\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Charge on each ball is 9.43e-06 C\n" - ] - } - ], - "prompt_number": 100 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.12 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "qa=10**-5 #C\n", - "qb=5*10**-6 #C\n", - "qc=-5*10**-6 #C\n", - "r=0.1 #m\n", - "a=9*10**9\n", - "\n", - "#Calculation\n", - "import math\n", - "Fab=(a*qa*qb)/r**2\n", - "Fac=Fab\n", - "F=math.sqrt(Fab**2+Fac**2+(2*Fab*Fac*math.cos(120*3.14/180.0)))\n", - "\n", - "#Result\n", - "print\"Resultant force is\", round(F,0),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant force is 45.0 N\n" - ] - } - ], - "prompt_number": 75 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.13 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "qa=1\n", - "qb=100\n", - "ab=10\n", - "a=9*10**9\n", - "qd=75\n", - "a1=5\n", - "\n", - "#Calculation\n", - "import math\n", - "Fab=(a*qa*qb)/ab**2\n", - "Fac=Fab\n", - "Fac1=(a*qa*qd)/(ab**2-a1**2)\n", - "Fx=Fab*math.cos(60*3.14/180.0)+Fac1*math.cos(60*3.14/180.0)\n", - "Fy=Fac\n", - "F=math.sqrt(Fx**2+Fy**2)\n", - "B=Fy/Fx\n", - "B1=math.atan(B)*180/3.14\n", - "\n", - "#Result\n", - "print\"Resultant force on charge qa is inclined at\", round(B1,0),\"Degree\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant force on charge qa is inclined at 45.0 Degree\n" - ] - } - ], - "prompt_number": 90 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/RavirajJadeja/ch16.ipynb b/sample_notebooks/RavirajJadeja/ch16.ipynb deleted file mode 100755 index 2b395898..00000000 --- a/sample_notebooks/RavirajJadeja/ch16.ipynb +++ /dev/null @@ -1,64 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:3c3856bc217e5f495e078375001a6745906e09c45dfca2c5d1fe105500ef94b8" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 16 : Machinery and Equipment" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 16.2 Page No : 16-11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\t\n", - "#initialisation of variables\n", - "p = 500\t#ft\n", - "p1 = 6\t#in\n", - "t = 500\t#cfm\n", - "p2 = 7\t#psig\n", - "P = p2+14.7\t#psia\n", - "T = 520*(P/14.7)**0.283\t#F\n", - "f = 0.048*p1**0.027/(t)**0.148\t#in\n", - "\t\n", - "#CALCULATIONS\n", - "delP = 20.*10**-3*p*T*(t)**2/(38*10**3*P*p1**5)\t#psia\n", - "\t\n", - "#RESULTS\n", - "print 'the pressure drop = %.2f psia'%(delP)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the pressure drop = 0.23 psia\n" - ] - } - ], - "prompt_number": 1 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of.ipynb b/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of.ipynb new file mode 100755 index 00000000..823b8e71 --- /dev/null +++ b/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of.ipynb @@ -0,0 +1,146 @@ +{ + "metadata": { + "name": "Chapter 2 Properties Of Material" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 2 Properties Of Material" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 1 Page No:19" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Input data\nL=5 # length of steel bar in m\nd=25*10**-3 # diametr of steel bar in mm\ndeltaLt=25*10**-3 #steel \npt=800 # power load of steel bar in N\n\n\n#calculation\nA=((pi/4)*((deltaLt)**2)) #Cross-section area\nsigmat=(pt)/(A) #Stress in steel bar\net=(deltaLt)/L #strain in steel bar\nE=(sigmat)/(et) #Young's modulus\n\n\n#output\nprint(\"value of Cross-section area A=\",A,\"m**2\")\nprint(\"value of tress in steel bar sigmat=\",sigmat,\"MN/m**2\")\nprint(\"value of strain in steel bar et= \",et)\nprint(\"value of Young's modulus E \",E,\"N/m**2\")\n\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "value of Cross-section area A= 0.0004906250000000001 m**2\nvalue of tress in steel bar sigmat= 1630573.248407643 MN/m**2\nvalue of strain in steel bar et= 0.005\nvalue of Young's modulus E 326114649.6815286 N/m**2\n" + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 2 Page No:20\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Input data\nL=300*10**-3 #length of hexagonal prismatic steel bar in mm\nA=500*10**-6 #Area of cross section of steel bar mm**2\nPt=500*10**3 # load of steel bar in KN\nE=210*10**9 # modulus of elasticity GN/m**2\n\n#Calculation\nsigmat=((Pt)/(A)) #stress in steel bar\net=((sigmat)/(E)) #strain steel bar is\ndeltaLt=((et)*(L)) #therefore,elongation of the steel bar is given by\n\n#output\nprint('stress in steel bar =',sigmat,\"N/m**2\")\nprint('therefore,strain steel bar is given by =',et,)\nprint('therefore,elongation of the steel bar is given by=',deltaLt,\"m\")\n\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "stress in steel bar = 1000000000.0 N/m**2\ntherefore,strain steel bar is given by = 0.004761904761904762\ntherefore,elongation of the steel bar is given by= 0.0014285714285714286 m\n" + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 3 Page No:21\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Input Data\nPt=600 #tensils force in N\nd=2*10**-3 #diameter of steel wire in mm\nL=15 #length of wire in m\nE=210*10**9 #modulus of elasticity of the material in GN/M**2\npi=3.1482\n\n\n#Calculation\nA=((pi/4)*((d)**2)) #(1)cross section area\nsigmat=(Pt)/(A) # stress in the steel wire \net=((sigmat)/(E)) #(2)therefore, strain in steel wire is given by\ndeltaLt=et*L #(3)Enlongation of the steel wire is given by \npe=((deltaLt/L)*100) #(4)percentage elongation\n\n\n#Output\nprint(\"cross section area A= \",A,\"m**2\")\nprint(\"stress in the steel wire sigmat=\",sigmat,\"GN/m**2\")\nprint(\"modulus of elasticity et=\",et,)\nprint(\"strain in steel wire deltaLt=\",deltaLt,\"mm\")\nprint(\"percentage elongation\",pe,\"%\")\n\n\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "cross section area A= 3.1481999999999998e-06 m**2\nstress in the steel wire sigmat= 190585096.24547362 GN/m**2\nmodulus of elasticity et= 0.0009075480773593982\nstrain in steel wire deltaLt= 0.013613221160390973 mm\npercentage elongation 0.09075480773593982 %\n" + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 4 Page No:22\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#input data\nA=30*30*10**-6 #area of square rod in mm**2\nL=5 #length of square rod in m\nPc=150*10**3 # axial comperessive load of a rod in kN\nE=215*10**9 # modulus of elasticity in GN/m**2\n\n\n#Calculation\nsigmac=((Pc)/(A)) #stress in square rod\nec=((sigmac)/(E)) #modulusof elasticity is E=sigmac/ec ,therefore strain in square rod is\ndeltaLc=ec*5 #therefore shortening of length of the rod \n\n\n#Output\nprint (\"stress in square rod\",sigmac,\"N/m**2\")\nprint(\"strain in square rod ec=\",ec,)\nprint(\"shortening of length of the rod=\",deltaLc,\"m\")", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "stress in square rod 166666666.66666666 N/m**2\nstrain in square rod ec= 0.0007751937984496124\nshortening of length of the rod= 0.003875968992248062 m\n" + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 5 Page No:23" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#input data\nd=50*10**-6 #diameter of metalic rod in mm**2\nL=220*10**-3 #length of metalic rod in mm\nPt=40*10**3 #load of metalic rod in KN\ndeltaLt=0.03*10**-3 #elastic enlongation in mm\nypl=160*10**3 # yield point load in KN\nml=250*10**3 #maximum load in KN\nlsf=270*10**-3 #length of specimen at fracture in mm\npi=3.1482\n\n#calculation\nA=(((pi)/(4)*((d)**2))) #(1)cross section area\nsigmat=(Pt/A) #stress in metallic rod\net=(deltaLt/L) #strain n metallic rod\nE=(sigmat/et) #young's modulus\nys=(ypl/A) #(2)yeild strength\nuts=(ml/A) #(3)ultimate tensile strength\nPebf=((lsf-L)/L)*100 #percentage elongation before fracture \n\n\n\n#output\nprint(\"cross section area\",A,\"m**2\")\nprint(\"stress in metallic rod\",sigmat,\"N/m**2\")\nprint(\"strain n metallic rod\",et,)\nprint(\"young's modulus\",E,\"GN/m**2\")\nprint(\"yeild strength\",ys,\"MN/m**2\")\nprint(\"ultimate tensile strength\",uts,\"MN/m**2\")\nprint(\"percentage elongation before fracture\",Pebf,\"%\")\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "cross section area 1.967625e-09 m**2\nstress in metallic rod 20329076932850.52 N/m**2\nstrain n metallic rod 0.00013636363636363637\nyoung's modulus 1.4907989750757046e+17 GN/m**2\nyeild strength 81316307731402.08 MN/m**2\nultimate tensile strength 127056730830315.75 MN/m**2\npercentage elongation before fracture 22.727272727272734 %\n" + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6 Page No:24\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#input data\nA=50*50*10**-6 #area ofsquare metal bar in mm**2\nPc=600*10**3 #axial compress laod in KN\nL=200*10**-3 # gauge length of metal bar in mm\ndeltaLc=0.4*10**-3 #contraction length of metal bar in mm\ndeltaLlateral=0.05*10**-3 #lateral length of metal bar in mm\n\n#Calculation\nsigmac=((Pc)/(A)) #stress in square metal bar \nec=((deltaLc)/(L)) #longitudinal or linear strain in square metal bar\nE =((sigmac)/(ec)) #smodule of elasticity\nelateral=((deltaLlateral)/(L)) #lateral strain in square metal bar\npoissonsratio=(elateral)/(ec)\n\n\n#output\nprint(\"stress in bar=\",sigmac,\"n/m**2\")\nprint(\"longitudinal or linear strain in square metal bar=\",ec,)\nprint(\"module of elasticity=\",E,\"N/m**2\")\nprint(\"lateral strain in square metal bar=\",elateral,)\nprint(\"poissons ratio=\",poissonsratio,)\n\n#poisson's ratio", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "stress in bar= 240000000.0 n/m**2\nlongitudinal or linear strain in square metal bar= 0.002\nmodule of elasticity= 120000000000.0 N/m**2\nlateral strain in square metal bar= 0.00025\npoissons ratio= 0.125\n" + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of_Material.ipynb b/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of_Material.ipynb deleted file mode 100755 index 823b8e71..00000000 --- a/sample_notebooks/Reshma Ustad/Chapter_2_Properties_Of_Material.ipynb +++ /dev/null @@ -1,146 +0,0 @@ -{ - "metadata": { - "name": "Chapter 2 Properties Of Material" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Chapter 2 Properties Of Material" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 1 Page No:19" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Input data\nL=5 # length of steel bar in m\nd=25*10**-3 # diametr of steel bar in mm\ndeltaLt=25*10**-3 #steel \npt=800 # power load of steel bar in N\n\n\n#calculation\nA=((pi/4)*((deltaLt)**2)) #Cross-section area\nsigmat=(pt)/(A) #Stress in steel bar\net=(deltaLt)/L #strain in steel bar\nE=(sigmat)/(et) #Young's modulus\n\n\n#output\nprint(\"value of Cross-section area A=\",A,\"m**2\")\nprint(\"value of tress in steel bar sigmat=\",sigmat,\"MN/m**2\")\nprint(\"value of strain in steel bar et= \",et)\nprint(\"value of Young's modulus E \",E,\"N/m**2\")\n\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "value of Cross-section area A= 0.0004906250000000001 m**2\nvalue of tress in steel bar sigmat= 1630573.248407643 MN/m**2\nvalue of strain in steel bar et= 0.005\nvalue of Young's modulus E 326114649.6815286 N/m**2\n" - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 2 Page No:20\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Input data\nL=300*10**-3 #length of hexagonal prismatic steel bar in mm\nA=500*10**-6 #Area of cross section of steel bar mm**2\nPt=500*10**3 # load of steel bar in KN\nE=210*10**9 # modulus of elasticity GN/m**2\n\n#Calculation\nsigmat=((Pt)/(A)) #stress in steel bar\net=((sigmat)/(E)) #strain steel bar is\ndeltaLt=((et)*(L)) #therefore,elongation of the steel bar is given by\n\n#output\nprint('stress in steel bar =',sigmat,\"N/m**2\")\nprint('therefore,strain steel bar is given by =',et,)\nprint('therefore,elongation of the steel bar is given by=',deltaLt,\"m\")\n\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "stress in steel bar = 1000000000.0 N/m**2\ntherefore,strain steel bar is given by = 0.004761904761904762\ntherefore,elongation of the steel bar is given by= 0.0014285714285714286 m\n" - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 3 Page No:21\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Input Data\nPt=600 #tensils force in N\nd=2*10**-3 #diameter of steel wire in mm\nL=15 #length of wire in m\nE=210*10**9 #modulus of elasticity of the material in GN/M**2\npi=3.1482\n\n\n#Calculation\nA=((pi/4)*((d)**2)) #(1)cross section area\nsigmat=(Pt)/(A) # stress in the steel wire \net=((sigmat)/(E)) #(2)therefore, strain in steel wire is given by\ndeltaLt=et*L #(3)Enlongation of the steel wire is given by \npe=((deltaLt/L)*100) #(4)percentage elongation\n\n\n#Output\nprint(\"cross section area A= \",A,\"m**2\")\nprint(\"stress in the steel wire sigmat=\",sigmat,\"GN/m**2\")\nprint(\"modulus of elasticity et=\",et,)\nprint(\"strain in steel wire deltaLt=\",deltaLt,\"mm\")\nprint(\"percentage elongation\",pe,\"%\")\n\n\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "cross section area A= 3.1481999999999998e-06 m**2\nstress in the steel wire sigmat= 190585096.24547362 GN/m**2\nmodulus of elasticity et= 0.0009075480773593982\nstrain in steel wire deltaLt= 0.013613221160390973 mm\npercentage elongation 0.09075480773593982 %\n" - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 4 Page No:22\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#input data\nA=30*30*10**-6 #area of square rod in mm**2\nL=5 #length of square rod in m\nPc=150*10**3 # axial comperessive load of a rod in kN\nE=215*10**9 # modulus of elasticity in GN/m**2\n\n\n#Calculation\nsigmac=((Pc)/(A)) #stress in square rod\nec=((sigmac)/(E)) #modulusof elasticity is E=sigmac/ec ,therefore strain in square rod is\ndeltaLc=ec*5 #therefore shortening of length of the rod \n\n\n#Output\nprint (\"stress in square rod\",sigmac,\"N/m**2\")\nprint(\"strain in square rod ec=\",ec,)\nprint(\"shortening of length of the rod=\",deltaLc,\"m\")", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "stress in square rod 166666666.66666666 N/m**2\nstrain in square rod ec= 0.0007751937984496124\nshortening of length of the rod= 0.003875968992248062 m\n" - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 5 Page No:23" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#input data\nd=50*10**-6 #diameter of metalic rod in mm**2\nL=220*10**-3 #length of metalic rod in mm\nPt=40*10**3 #load of metalic rod in KN\ndeltaLt=0.03*10**-3 #elastic enlongation in mm\nypl=160*10**3 # yield point load in KN\nml=250*10**3 #maximum load in KN\nlsf=270*10**-3 #length of specimen at fracture in mm\npi=3.1482\n\n#calculation\nA=(((pi)/(4)*((d)**2))) #(1)cross section area\nsigmat=(Pt/A) #stress in metallic rod\net=(deltaLt/L) #strain n metallic rod\nE=(sigmat/et) #young's modulus\nys=(ypl/A) #(2)yeild strength\nuts=(ml/A) #(3)ultimate tensile strength\nPebf=((lsf-L)/L)*100 #percentage elongation before fracture \n\n\n\n#output\nprint(\"cross section area\",A,\"m**2\")\nprint(\"stress in metallic rod\",sigmat,\"N/m**2\")\nprint(\"strain n metallic rod\",et,)\nprint(\"young's modulus\",E,\"GN/m**2\")\nprint(\"yeild strength\",ys,\"MN/m**2\")\nprint(\"ultimate tensile strength\",uts,\"MN/m**2\")\nprint(\"percentage elongation before fracture\",Pebf,\"%\")\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "cross section area 1.967625e-09 m**2\nstress in metallic rod 20329076932850.52 N/m**2\nstrain n metallic rod 0.00013636363636363637\nyoung's modulus 1.4907989750757046e+17 GN/m**2\nyeild strength 81316307731402.08 MN/m**2\nultimate tensile strength 127056730830315.75 MN/m**2\npercentage elongation before fracture 22.727272727272734 %\n" - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6 Page No:24\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#input data\nA=50*50*10**-6 #area ofsquare metal bar in mm**2\nPc=600*10**3 #axial compress laod in KN\nL=200*10**-3 # gauge length of metal bar in mm\ndeltaLc=0.4*10**-3 #contraction length of metal bar in mm\ndeltaLlateral=0.05*10**-3 #lateral length of metal bar in mm\n\n#Calculation\nsigmac=((Pc)/(A)) #stress in square metal bar \nec=((deltaLc)/(L)) #longitudinal or linear strain in square metal bar\nE =((sigmac)/(ec)) #smodule of elasticity\nelateral=((deltaLlateral)/(L)) #lateral strain in square metal bar\npoissonsratio=(elateral)/(ec)\n\n\n#output\nprint(\"stress in bar=\",sigmac,\"n/m**2\")\nprint(\"longitudinal or linear strain in square metal bar=\",ec,)\nprint(\"module of elasticity=\",E,\"N/m**2\")\nprint(\"lateral strain in square metal bar=\",elateral,)\nprint(\"poissons ratio=\",poissonsratio,)\n\n#poisson's ratio", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "stress in bar= 240000000.0 n/m**2\nlongitudinal or linear strain in square metal bar= 0.002\nmodule of elasticity= 120000000000.0 N/m**2\nlateral strain in square metal bar= 0.00025\npoissons ratio= 0.125\n" - } - ], - "prompt_number": 12 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/RohitPhadtare/RohitPhadtare_version_backup/chapter.6.ipynb b/sample_notebooks/RohitPhadtare/RohitPhadtare_version_backup/chapter.6.ipynb new file mode 100755 index 00000000..4657aa0b --- /dev/null +++ b/sample_notebooks/RohitPhadtare/RohitPhadtare_version_backup/chapter.6.ipynb @@ -0,0 +1,1494 @@ +{ + "metadata": { + "name": "chapter no.6.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter No.6:Torsion" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.1,Page No.225" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "L=10000 #mm #Length of solid shaft\n", + "d=100 #mm #Diameter of shaft\n", + "n=150 #rpm\n", + "P=112.5*10**6 #N-mm/sec #Power Transmitted\n", + "G=82*10**3 #N/mm**2 #modulus of Rigidity\n", + "\n", + "#Calculations\n", + "\n", + "J=pi*d**4*(32)**-1 #mm**3 #Polar Modulus\n", + "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", + "\n", + "r=50 #mm #Radius\n", + "\n", + "q_s=T*r*J**-1 #N/mm**2 #Max shear stress intensity\n", + "Theta=T*L*(G*J)**-1 #angle of twist\n", + "\n", + "#Result\n", + "print\"Max shear stress intensity\",round(q_s,2),\"N/mm**2\"\n", + "print\"Angle of Twist\",round(Theta,3),\"radian\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max shear stress intensity 36.48 N/mm**2\n", + "Angle of Twist 0.089 radian\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.2,Page No.226" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "P=440*10**6 #N-m/sec #Power transmitted\n", + "n=280 #rpm\n", + "theta=pi*180**-1 #radian #angle of twist\n", + "L=1000 #mm #Length of solid shaft\n", + "q_s=40 #N/mm**2 #Max torsional shear stress\n", + "G=84*10**3 #N/mm**2 #Modulus of rigidity\n", + "\n", + "#Calculations\n", + "\n", + "#P=2*pi*n*T*(60)**-1 #Equation of Power transmitted\n", + "T=P*60*(2*pi*n)**-1 #N-mm #torsional moment\n", + "\n", + "#From Consideration of shear stress\n", + "d1=(T*16*(pi*40)**-1)**0.333333 \n", + "\n", + "#From Consideration of angle of twist\n", + "d2=(T*L*32*180*(pi*84*10**3*pi)**-1)**0.25\n", + "\n", + "#result\n", + "print\"Diameter of solid shaft is\",round(d1,2),\"mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of solid shaft is 124.09 mm\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.3,Page No.227" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "G=80*10**3 #N/mm**2 #Modulus of rigidity\n", + "q_s=80 #N/mm**2 #Max sheare stress\n", + "P=736*10**6 #N-mm/sec #Power transmitted\n", + "n=200\n", + "\n", + "#Calculations\n", + "\n", + "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", + "\n", + "#Now From consideration of angle of twist\n", + "theta=pi*180**-1\n", + "#L=15*d\n", + "\n", + "d=(T*32*180*15*(pi**2*G)**-1)**0.33333\n", + "\n", + "#Now corresponding stress at the surface is\n", + "q_s2=T*32*d*(pi*2*d**4)**-1\n", + "\n", + "#Result\n", + "print\"Max diameter required is\",round(d,2),\"mm\"\n", + "print\"Corresponding shear stress is\",round(q_s2,2),\"N/mm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max diameter required is 156.66 mm\n", + "Corresponding shear stress is 46.55 N/mm**2\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.4,Page No.228" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d=25 #mm #Diameter of steel bar\n", + "p=50*10**3 #N #Pull\n", + "dell_1=0.095 #mm #Extension of bar\n", + "l=200 #mm #Guage Length\n", + "T=200*10**3 #N-mm #Torsional moment\n", + "theta=0.9*pi*180**-1 #angle of twist\n", + "L=250 #mm Length of steel bar\n", + "\n", + "#Calculations\n", + "\n", + "A=pi*4**-1*d**2 #Area of steel bar #mm**2\n", + "E=p*l*(dell_1*A)**-1 #N/mm**2 #Modulus of elasticity \n", + "\n", + "J=pi*32**-1*d**4 #mm**4 #Polar modulus\n", + "\n", + "G=T*L*(theta*J)**-1 #Modulus of rigidity #N/mm**2\n", + "\n", + "#Now from the relation of Elastic constants\n", + "mu=E*(2*G)**-1-1\n", + "\n", + "#result\n", + "print\"The Poissoin's ratio is\",round(mu,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Poissoin's ratio is 0.292\n" + ] + } + ], + "prompt_number": 30 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.5,Page No.229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "L=6000 #mm #Length of circular shaft\n", + "d1=100 #mm #Outer Diameter\n", + "d2=75 #mm #Inner Diameter\n", + "R=100*2**-1 #Radius of shaft\n", + "T=10*10**6 #N-mm #Torsional moment\n", + "G=80*10**3 #N/mm**2 #Modulus of Rigidity\n", + "\n", + "#Calculations\n", + "\n", + "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus \n", + "\n", + "#Max Shear stress produced\n", + "q_s=T*R*J**-1 #N/mm**2\n", + "\n", + "#Angle of twist\n", + "theta=T*L*(G*J)**-1 #Radian\n", + "\n", + "#Result\n", + "print\"MAx shear stress produced is\",round(q_s,2),\"N/mm**2\"\n", + "print\"Angle of Twist is\",round(theta,2),\"Radian\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "MAx shear stress produced is 74.5 N/mm**2\n", + "Angle of Twist is 0.11 Radian\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.6,Page No.229" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d1=200 #mm #External Diameter of shaft\n", + "t=25 #mm #Thickness of shaft\n", + "n=200 #rpm\n", + "theta=0.5*pi*180**-1 #Radian #angle of twist\n", + "L=2000 #mm #Length of shaft\n", + "G=84*10**3 #N/mm**2\n", + "d2=d1-2*t #mm #Internal Diameter of shaft\n", + "\n", + "#Calculations\n", + "\n", + "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus \n", + "\n", + "#Torsional moment\n", + "T=G*J*theta*L**-1 #N/mm**2 \n", + "\n", + "#Power Transmitted\n", + "P=2*pi*n*T*60**-1*10**-6 #N-mm\n", + "\n", + "#Max shear stress transmitted\n", + "q_s=G*theta*(d1*2**-1)*L**-1 #N/mm**2 \n", + "\n", + "#Result\n", + "print\"Power Transmitted is\",round(P,2),\"N-mm\"\n", + "print\"Max Shear stress produced is\",round(q_s,2),\"N/mm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power Transmitted is 824.28 N-mm\n", + "Max Shear stress produced is 36.65 N/mm**2\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.7,Page No.230" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "P=3750*10**6 #N-mm/sec\n", + "n=240 #Rpm\n", + "q_s=160 #N/mm**2 #Max shear stress\n", + "\n", + "#Calculations\n", + "\n", + "#d2=0.8*d2 #mm #Internal Diameter of shaft\n", + "\n", + "#J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar modulus\n", + "#After substituting value in above Equation we get\n", + "#J=0.05796*d1**4\n", + "\n", + "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", + "\n", + "#Now from Torsion Formula\n", + "#T*J**-1=q_s*R**-1 ......................................(1)\n", + "\n", + "#But R=d1*2**-1 \n", + "\n", + "#Now substituting value of R and J in Equation (1) we get\n", + "d1=(T*(0.05796*q_s*2)**-1)**0.33333\n", + "\n", + "d2=d1*0.8\n", + "\n", + "#Result\n", + "print\"The size of the Shaft is:d1\",round(d1,3),\"mm\"\n", + "print\" :d2\",round(d2,3),\"mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The size of the Shaft is:d1 200.362 mm\n", + " :d2 160.289 mm\n" + ] + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.8,Page No.231" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "P=245*10**6 #N-mm/sec #Power transmitted\n", + "n=240 #rpm\n", + "q_s=40 #N/mm**2 #Shear stress\n", + "theta=pi*180**-1 #radian #Angle of twist\n", + "L=1000 #mm #Length of shaft\n", + "G=80*10**3 #N/mm**2\n", + "\n", + "#Tmax=1.5*T\n", + "\n", + "#Calculations\n", + "\n", + "T=P*60*(2*pi*n)**-1 #N-mm #Torsional Moment\n", + "Tmax=1.5*T\n", + "\n", + "#Now For Solid shaft\n", + "#J=pi*32*d**4\n", + "\n", + "#Now from the consideration of shear stress we get\n", + "#T*J**-1=q_s*(d*2**-1)**-1\n", + "#After substituting value in above Equation we get\n", + "#T=pi*16**-1*d**3*q_s\n", + "\n", + "#Designing For max Torque\n", + "d=(Tmax*16*(pi*40)**-1)**0.33333 #mm #Diameter of shaft\n", + "\n", + "#For max Angle of Twist\n", + "#Tmax*J**-1=G*theta*L**-1 \n", + "#After substituting value in above Equation we get\n", + "d2=(Tmax*32*180*L*(pi**2*G)**-1)**0.25\n", + "\n", + "#For Hollow Shaft\n", + "\n", + "#d1_2=Outer Diameter\n", + "#d2_2=Inner Diameter\n", + "\n", + "#d2_2=0.5*d1_2\n", + "\n", + "# Polar modulus\n", + "#J=pi*32**-1*(d1_2**4-d2_2**4)\n", + "#After substituting values we get\n", + "#J=0.092038*d1_2**4\n", + "\n", + "#Now from the consideration of stress\n", + "#Tmax*J**-1=q_s*(d1_2*2**-1)**-1\n", + "#After substituting values and further simplifying we get\n", + "d1_2=(Tmax*(0.092038*2*q_s)**-1)**0.33333\n", + "\n", + "#Now from the consideration of angle of twist\n", + "#Tmax*J**-1=G*theta*L**-1\n", + "#After substituting values and further simplifying we get\n", + "d1_3=(Tmax*180*L*(0.092038*G*pi)**-1)**0.25\n", + "\n", + "d2_2=0.5*d1_2\n", + "\n", + "#result\n", + "print\"Diameter of shaft is:For solid shaft:d\",round(d,2),\"mm\"\n", + "print\" :For Hollow shaft:d1_2\",round(d1_2,3),\"mm\"\n", + "print\" : :d2_2\",round(d2_2,3),\"mm\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of shaft is:For solid shaft:d 123.01 mm\n", + " :For Hollow shaft:d1_2 125.69 mm\n", + " : :d2_2 62.845 mm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.11,Page No.235" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "P=250*10**6 #N-mm/sec #Power transmitted\n", + "n=100 #rpm\n", + "q_s=75 #N/mm**2 #Shear stress\n", + "\n", + "#Calculations\n", + "\n", + "#From Equation of Power we have\n", + "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", + "\n", + "#Now from torsional moment equation we have\n", + "#T=j*q_s*(d/2**-1)**-1\n", + "#After substituting values in above equation and further simplifying we get\n", + "#T=pi*16**-1**d**3*q_s\n", + "d=(T*16*(pi*q_s)**-1)**0.3333 #mm #Diameter of solid shaft\n", + "\n", + "#PArt-2\n", + "\n", + "#Let d1 and d2 be the outer and inner diameter of hollow shaft\n", + "#d2=0.6*d1\n", + "\n", + "#Again from torsional moment equation we have\n", + "#T=pi*32**-1*(d1**4-d2**4)*q_s*(d1/2)**-1\n", + "d1=(T*16*(pi*(1-0.6**4)*q_s)**-1)**0.33333\n", + "d2=0.6*d1\n", + "\n", + "#Cross sectional area of solid shaft\n", + "A1=pi*4**-1*d**2 #mm**2\n", + "\n", + "#cross sectional area of hollow shaft\n", + "A2=pi*4**-1*(d1**2-d2**2)\n", + "\n", + "#Now percentage saving in weight\n", + "#Let W be the percentage saving in weight\n", + "W=(A1-A2)*100*A1**-1\n", + "\n", + "#Result\n", + "print\"Percentage saving in Weight is\",round(W,3),\"%\"\n", + "print\"Size of shaft is:solid shaft:d\",round(d,3),\"mm\"\n", + "print\" :Hollow shaft:d1\",round(d1,3),\"mm\"\n", + "print\" : :d2\",round(d2,3),\"mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage saving in Weight is 29.735 %\n", + "Size of shaft is:solid shaft:d 117.418 mm\n", + " :Hollow shaft:d1 123.031 mm\n", + " : :d2 73.818 mm\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.12,Page No.237" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "d=100 #mm #Diameter of solid shaft\n", + "d1=100 #mm #Outer Diameter of hollow shaft\n", + "d2=50 #mm #Inner Diameter of hollow shaft\n", + "\n", + "#Calculations\n", + "\n", + "#Torsional moment of solid shaft\n", + "#T_s=J*q_s*(d*2**-1)**-1 \n", + "#After substituting values in above equation and further simplifying we get\n", + "#T_s=pi*16*d**3*q_s ...............(1)\n", + "\n", + "#torsional moment for hollow shaft is\n", + "#T_h=J*q_s*(d1**4-d2**4)**-1*(d1*2**-1)\n", + "#After substituting values in above equation and further simplifying we get\n", + "#T_h=pi*32**-1*2*d1**-1*(d1**4-d2**4)*q_s ...........(2)\n", + "\n", + "#Dividing Equation 2 by 1 we get\n", + "#Let the ratio of T_h*T_s**-1 Be X\n", + "X=1-0.5**4\n", + "\n", + "#Loss in strength \n", + "#Let s be the loss in strength\n", + "#s=T_s*T_h*100*T_s**-1\n", + "#After substituting values in above equation and further simplifying we get\n", + "s=(1-0.9375)*100\n", + "\n", + "#Weight Ratio \n", + "#Let w be the Weight ratio\n", + "#w=W_h*W_s**-1\n", + "\n", + "A_h=pi*32**-1*(d1**2-d2**2) #mm**2 #Area of Hollow shaft\n", + "A_s=pi*32**-1*d**2 #mm**2 #Area of solid shaft\n", + "\n", + "w=A_h*A_s**-1 \n", + "\n", + "#Result\n", + "print\"Loss in strength is\",round(s,2)\n", + "print\"Weight ratio is\",round(w,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Loss in strength is 6.25\n", + "Weight ratio is 0.75\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.13,Page No.239" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "T=8 #KN-m #Torque \n", + "d=100 #mm #Diameter of portion AB\n", + "d1=100 #mm #External Diameter of Portion BC\n", + "d2=75 #mm #Internal Diameter of Portion BC\n", + "G=80 #KN/mm**2 #Modulus of Rigidity\n", + "L1=1500 #mm #Radial Distance of Portion AB\n", + "L2=2500 #mm #Radial Distance ofPortion BC\n", + "\n", + "#Calculations\n", + "\n", + "R=d*2**-1 #mm #Radius of shaft\n", + "\n", + "#For Portion AB,Polar Modulus\n", + "J1=pi*32**-1*d**4 #mm**4 \n", + "\n", + "#For Portion BC,Polar modulus \n", + "J2=pi*32**-1*(d1**4-d2**4) #mm**4\n", + "\n", + "#Now Max stress occurs in portion BC since max radial Distance is sme in both cases\n", + "q_max=T*J2**-1*R*10**6 #N/mm**2 \n", + "\n", + "#Let theta1 be the rotation in Portion AB and theta2 be the rotation in portion BC\n", + "theta1=T*L1*(G*J1)**-1 #Radians\n", + "theta2=T*L2*(G*J2)**-1 #Radians\n", + "\n", + "#Total Rotational at end C\n", + "theta=(theta1+theta2)*10**3 #Radians\n", + "\n", + "#Result\n", + "print\"Max stress induced is\",round(q_max,2),\"N/mm**2\"\n", + "print\"Angle of Twist is\",round(theta,3),\"radians\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max stress induced is 59.6 N/mm**2\n", + "Angle of Twist is 0.053 radians\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.14,Page No.240" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "q_b=80 #N/mm**2 #Shear stress in Brass\n", + "q_s=100 #N/mm**2 #Shear stress in Steel\n", + "G_b=40*10**3 #N/mm**2 \n", + "G_s=80*10**3 \n", + "L_b=1000 #mm #Length of brass shaft\n", + "L_s=1200 #mm #Length of steel shaft\n", + "d1=80 #mm #Diameter of brass shaft\n", + "d2=60 #mm #Diameter of steel shaft\n", + "\n", + "#Calculations\n", + "\n", + "#Polar modulus of brass rod\n", + "J_b=pi*32**-1*d1**4 #mm**4 \n", + "\n", + "#Polar modulus of steel rod\n", + "J_s=pi*32**-1*d2**4 #mm**4\n", + "\n", + "#Considering bras Rod:AB\n", + "T1=J_b*q_b*(d1*2**-1)**-1 #N-mm \n", + "\n", + "#Considering Steel Rod:BC\n", + "T2=J_s*q_s*(d2*2**-1)**-1 #N-mm\n", + "\n", + "#Max Torque that can be applied\n", + "T2\n", + "\n", + "#Let theta_b and theta_s be the rotations in Brass and steel respectively\n", + "theta_b=T2*L_b*(G_b*J_b)**-1 #Radians\n", + "theta_s=T2*L_s*(G_s*J_s)**-1 #Radians\n", + "\n", + "theta=theta_b+theta_s #Radians #Rotation of free end\n", + "\n", + "#Result\n", + "print\"Total of free end is\",round(theta,3),\"Radians\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total of free end is 0.076 Radians\n" + ] + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.15,Page No.241" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "G=80*10**3 #N/mm**2 #Modulus of Rigidity\n", + "d1=100 #mm #Outer diameter of hollow shft\n", + "d2=80 #mm #Inner diameter of hollow shaft\n", + "d=80 #mm #diameter of Solid shaft\n", + "d3=60 #mm #diameter of Solid shaft having L=0.5m\n", + "L1=300 #mm #Length of Hollow shaft\n", + "L2=400 #mm #Length of solid shaft\n", + "L3=500 #mm #LEngth of solid shaft of diameter 60mm\n", + "T1=2*10**6 #N-mm #Torsion in Shaft AB\n", + "T2=1*10**6 #N-mm #Torsion in shaft BC\n", + "T3=1*10**6 #N-mm #Torsion in shaft CD\n", + "\n", + "#Calculations\n", + "\n", + "#Now Polar modulus of section AB\n", + "J1=pi*32**-1*(d1**4-d2**4) #mm**4 \n", + "\n", + "#Polar modulus of section BC\n", + "J2=pi*32**-1*d**4 #mm**4\n", + "\n", + "#Polar modulus of section CD\n", + "J3=pi*32**-1*d3**4 #mm**4\n", + "\n", + "#Now angle of twist of AB\n", + "theta1=T1*L1*(G*J1)**-1 #radians\n", + "\n", + "#Angle of twist of BC\n", + "theta2=T2*L2*(G*J2)**-1 #radians\n", + "\n", + "#Angle of twist of CD\n", + "theta3=T3*L3*(G*J3)**-1 #radians\n", + "\n", + "#Angle of twist\n", + "theta=theta1-theta2+theta3 #Radians\n", + "\n", + "#Shear stress in AB From Torsion Equation\n", + "q_s1=T1*(d1*2**-1)*J1**-1 #N/mm**2 \n", + "\n", + "#Shear stress in BC\n", + "q_s2=T2*(d*2**-1)*J2**-1 #N/mm**2 \n", + "\n", + "#Shear stress in CD\n", + "q_s3=T3*(d3*2**-1)*J3**-1 #N-mm**2\n", + "\n", + "#As max shear stress occurs in portion CD,so consider CD\n", + "\n", + "#Result\n", + "print\"Angle of twist at free end is\",round(theta,5),\"Radian\"\n", + "print\"Max Shear stress\",round(q_s3,2),\"N/mm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Angle of twist at free end is 0.00496 Radian\n", + "Max Shear stress 23.58 N/mm**2\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.16,Page No.242" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "L=1000 #mm #Length of bar\n", + "L1=600 #mm #Length of Bar AB\n", + "L2=400 #mm #Length of Bar BC\n", + "d1=60 #mm #Outer Diameter of bar BC\n", + "d2=30 #mm #Inner Diameter of bar BC\n", + "d=60 #mm #Diameter of bar AB\n", + "T=2*10**6 #N-mm #Total Torque\n", + "\n", + "#Calculations\n", + "\n", + "#Polar Modulus of Portion AB\n", + "J1=pi*32**-1*d**4 #mm*4\n", + "\n", + "#Polar Modulus of Portion BC\n", + "J2=pi*32**-1*(d1**4-d2**4) #mm**4\n", + "\n", + "#Let T1 be the torque resisted by bar AB and T2 be torque resisted by Bar BC\n", + "#Let theta1 and theta2 be the rotation of shaft in portion AB & BC\n", + "\n", + "#theta1=T1*L1*(G*J1)**-1 #radians\n", + "#After substituting values and further simplifying we get \n", + "#theta1=32*600*T1*(pi*60**4*G)**-1\n", + "\n", + "#theta2=T2*L*(J2*G)**-1 #Radians\n", + "#After substituting values and further simplifying we get \n", + "#theta2=32*400*T2*(pi*60**4*(1-0.5**4)*G)**-1 \n", + "\n", + "#Now For consistency of Deformation,theta1=theta2\n", + "#After substituting values and further simplifying we get \n", + "#T1=0.7111*T2 ..................................................(1)\n", + "\n", + "#But T1+T2=T=2*10**6 ...........................................(2)\n", + "#Substituting value of T1 in above equation\n", + "\n", + "T2=T*(0.7111+1)**-1\n", + "T1=0.71111*T2\n", + "\n", + "#Max stress in Portion AB\n", + "q_s1=T1*(d*2**-1)*(J1)**-1 #N/mm**2\n", + "\n", + "#Max stress in Portion BC\n", + "q_s2=T2*(d1*2**-1)*J2**-1 #N/mm**2 \n", + "\n", + "#Result\n", + "print\"Stresses Developed in Portion:AB\",round(q_s1,2),\"N/mm**2\"\n", + "print\" :BC\",round(q_s2,2),\"N/mm**2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Stresses Developed in Portion:AB 19.6 N/mm**2\n", + " :BC 29.4 N/mm**2\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.17,Page No.243" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d1=80 #mm #External Diameter of Brass tube\n", + "d2=50 #mm #Internal Diameter of Brass tube\n", + "d=50 #mm #Diameter of steel Tube\n", + "G_b=40*10**3 #N/mm**2 #Modulus of Rigidity of brass tube\n", + "G_s=80*10**3 #N/mm**2 #Modulus of rigidity of steel tube\n", + "T=6*10**6 #N-mm #Torque\n", + "L=2000 #mm #Length of Tube\n", + "\n", + "#Calculations\n", + "\n", + "#Polar Modulus of brass tube\n", + "J1=pi*32**-1*(d1**4-d2**4) #mm**4 \n", + "\n", + "#Polar modulus of steel Tube\n", + "J2=pi*32**-1*d**4 #mm**4\n", + "\n", + "#Let T_s & T_b be the torque resisted by steel and brass respectively\n", + "#Then, T_b+T_s=T ............................................(1)\n", + "\n", + "#Since the angle of twist will be the same\n", + "#Theta1=Theta2\n", + "#After substituting values and further simplifying we get \n", + "#Ts=0.360*Tb ...........................................(2)\n", + "\n", + "#After substituting value of Ts in eqn 1 and further simplifying we get \n", + "T_b=T*(0.36+1)**-1 #N-mm\n", + "T_s=0.360*T_b\n", + "\n", + "#Let q_s and q_b be the max stress in steel and brass respectively\n", + "q_b=T_b*(d1*2**-1)*J1**-1 #N/mm**2\n", + "q_s=T_s*(d2*2**-1)*J2**-1 #N/mm**2\n", + "\n", + "#Since angle of twist in brass=angle of twist in steel\n", + "theta_s=T_s*L*(J2*G_s)**-1\n", + "\n", + "#Result\n", + "print\"Stresses Developed in Materials are:Brass\",round(q_b,2),\"N/mm**2\"\n", + "print\" :Steel\",round(q_s,2),\"N/mm**2\"\n", + "print\"Angle of Twist in 2m Length\",round(theta_s,3),\"Radians\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Stresses Developed in Materials are:Brass 51.79 N/mm**2\n", + " :Steel 64.71 N/mm**2\n", + "Angle of Twist in 2m Length 0.065 Radians\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.18,Page No.245" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d1=60 #mm #External Diameter of aluminium Tube\n", + "d2=40 #mm #Internal Diameter of aluminium Tube\n", + "d=40 #mm #Diameter of steel tube\n", + "q_a=60 #N/mm**2 #Permissible stress in aluminium\n", + "q_s=100 #N/mm**2 #Permissible stress in steel tube\n", + "G_a=27*10**3 #N/mm**2 \n", + "G_s=80*10**3 #N/mm**2 \n", + "\n", + "#Calculations\n", + "\n", + "#Polar modulus of aluminium Tube\n", + "J_a=pi*32**-1*(d1**4-d2**4) #mm**4\n", + "\n", + "#Polar Modulus of steel Tube\n", + "J_s=pi*32**-1*d**4 #mm**4\n", + "\n", + "#Now the angle of twist of steel tube = angle of twist of aluminium tube\n", + "#T_s*L_s*(J_s*theta_s)**-1=T_a*L_a*(J_a*theta_a)**-1\n", + "#After substituting values in above Equation and Further simplifyin we get\n", + "#T_s=0.7293*T_a .....................(1)\n", + "\n", + "#If steel Governs the resisting capacity\n", + "T_s1=q_s*J_s*(d*2**-1)**-1 #N-mm\n", + "T_a1=T_s1*0.7293**-1 #N-mm\n", + "T1=(T_s1+T_a1)*10**-6 #KN-m #Total Torque in steel Tube\n", + "\n", + "#If aluminium Governs the resisting capacity \n", + "T_a2=q_a*J_a*(d1*2**-1) #N-mm\n", + "T_s2=T_a2*0.7293 #N-mm\n", + "T2=(T_s2+T_a2)*10**-6 #KN-m #Total Torque in aluminium tube\n", + "\n", + "#Result\n", + "print\"Steel Governs the torque carrying capacity\",round(T1,2),\"KN-m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Steel Governs the torque carrying capacity 2.98 KN-m\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.19,Page No.247" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "P=225*10**6 #N-mm/sec #Power Trasmitted\n", + "q_b=80 #N/mm**2 #Shear stress\n", + "n=200 #Rpm\n", + "q_k=100 #N/mm**2 #PErmissible stress in Keys\n", + "D=300 #mm #Diameter of bolt circle\n", + "L=150 #mm #Length of shear key\n", + "d=16 #mm #Diameterr of bolt\n", + "\n", + "#Calculations\n", + "T=60*P*(2*pi*n)**-1 #N-mm #Torque\n", + "\n", + "#Now From Torsion Formula\n", + "#T*J**-1=q_s*R**-1\n", + "#After substituting values we get\n", + "#T=pi*16*d**3*n\n", + "#After further simplifying we get\n", + "d1=(T*16*(pi*q_s)**-1)**0.33333\n", + "\n", + "#Let b be the width of shear Key\n", + "#T=q_k*L*b*R\n", + "#After simplifying further we get\n", + "b=T*(q_k*L*(d1*2**-1))**-1 #mm\n", + "\n", + "#Let n2 be the no. of bolts required at bolt circle of radius\n", + "R_b=D*2**-1 #mm \n", + "\n", + "n2=T*4*(q_b*pi*d**2*R_b)**-1\n", + "\n", + "#result\n", + "print\"Minimum no. of Bolts Required are\",round(n2,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum no. of Bolts Required are 4.45\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.20,Page No.250" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "T=2*10**6 #N-mm #Torque transmitted\n", + "G=80*10**3 #N/mm**2 #Modulus of rigidity\n", + "d1=40 #mm \n", + "d2=80 #mm\n", + "r1=20 #mm\n", + "r2=40 #mm\n", + "L=2000 #mm #Length of shaft\n", + "\n", + "#Calculations\n", + "\n", + "#Angle of twist \n", + "theta=2*T*L*(r1**2+r1*r2+r2**2)*(3*pi*G*r2**3*r1**3)**-1 #radians\n", + "\n", + "#If the shaft is treated as shaft of average Diameter\n", + "d_avg=(d1+d2)*2**-1 #mm\n", + "\n", + "theta1=T*L*(G*pi*32**-1*d_avg**4)**-1 #Radians\n", + "\n", + "#Percentage Error\n", + "#Let Percentage Error be E\n", + "X=theta-theta1\n", + "E=(X*theta**-1)*100 \n", + "\n", + "#Result\n", + "print\"Percentage Error is\",round(E,2),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Percentage Error is 32.28 %\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.21,Page No.252" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "G=80*10**3 #N/mm**2 \n", + "P=1*10**9 #N-mm/sec #Power\n", + "n=300 \n", + "d1=150 #mm #Outer Diameter\n", + "d2=120 #mm #Inner Diameter\n", + "L=2000 #mm #Length of circular shaft\n", + "\n", + "#Calculations\n", + "\n", + "T=P*60*(2*pi*n)**-1 #N-mm\n", + "\n", + "#Polar Modulus \n", + "J=pi*32**-1*(d1**4-d2**4) #mm**4\n", + "\n", + "q_s=T*J**-1*(d1*2**-1) #N/mm**2 \n", + "\n", + "\n", + "#Strain ENergy\n", + "U=q_s**2*(4*G)**-1*pi*4**-1*(d1**2-d2**2)*L\n", + "\n", + "#Result\n", + "print\"Max shear stress is\",round(q_s,2),\"N/mm**2\"\n", + "print\"Strain Energy stored in the shaft is\",round(U,2),\"N-mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max shear stress is 81.36 N/mm**2\n", + "Strain Energy stored in the shaft is 263181.37 N-mm\n" + ] + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.22,Page No.254" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d=12 #mm #Diameter of helical spring\n", + "D=150 #mm #Mean Diameter\n", + "R=D*2**-1 #mm #Radius of helical spring\n", + "n=10 #no.of turns\n", + "G=80*10**3 #N/mm**2 \n", + "W=450 #N #Load\n", + "\n", + "#Calculations\n", + "\n", + "#Max shear stress \n", + "q_s=16*W*R*(pi*d**3)**-1 #N/mm**2\n", + "\n", + "#Strain Energy stored\n", + "U=32*W**2*R**3*n*(G*d**4)**-1 #N-mm\n", + "\n", + "#Deflection Produced\n", + "dell=64*W*R**3*n*(G*d**4)**-1 #mm\n", + "\n", + "#Stiffness Spring\n", + "k=W*dell**-1 #N/mm\n", + "\n", + "#Result\n", + "print\"Max shear stress is\",round(q_s,2),\"N/mm**2\"\n", + "print\"Strain Energy stored is\",round(U,2),\"N-mm\"\n", + "print\"Deflection Produced is\",round(dell,2),\"mm\"\n", + "print\"Stiffness spring is\",round(k,2),\"N/mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Max shear stress is 99.47 N/mm**2\n", + "Strain Energy stored is 16479.49 N-mm\n", + "Deflection Produced is 73.24 mm\n", + "Stiffness spring is 6.14 N/mm\n" + ] + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.23,Page No.255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "K=5 #N/mm #Stiffness\n", + "L=100 #mm #Solid Length\n", + "q_s=60 #N/mm**2 #Max shear stress\n", + "W=200 #N #Max Load\n", + "G=80*10**3 #N/mm**2\n", + "\n", + "#Calculations\n", + "\n", + "#K=W*dell**-1\n", + "#After substituting values and further simplifying we get\n", + "#d=0.004*R**3*n ........(1) #mm #Diameter of wire\n", + "#n=L*d**-1 ........(2)\n", + "\n", + "#From Shearing stress\n", + "#q_s=16*W*R*(pi*d**3)**-1 \n", + "#After substituting values and further simplifying we get\n", + "#d**4=0.004*R**3*n .................(4)\n", + "\n", + "#From Equation 1,2,3\n", + "#d**4=0.004*(0.0785*d**3)**3*100*d**-1\n", + "#after further simplifying we get\n", + "d=5168.101**0.25\n", + "n=100*d**-1\n", + "R=(d**4*(0.004*n)**-1)**0.3333\n", + "\n", + "#Result\n", + "print\"Diameter of Wire is\",round(d,2),\"mm\"\n", + "print\"No.of turns is\",round(n,2)\n", + "print\"Mean Radius of spring is\",round(R,2),\"mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Diameter of Wire is 8.48 mm\n", + "No.fo turns is 11.79\n", + "Mean Radius of spring is 47.83 mm\n" + ] + } + ], + "prompt_number": 54 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.24,Page No.255" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "m=5*10**5 #Wagon Weighing\n", + "v=18*1000*36000**-1 \n", + "d=300 #mm #Diameter of Beffer springs\n", + "n=18 #no.of turns\n", + "G=80*10**3 #N/mm**2\n", + "dell=225\n", + "R=100 #mm #Mean Radius\n", + "\n", + "#Calculations\n", + "\n", + "#Energy of Wagon\n", + "E=m*v**2*(9.81*2)**-1 #N-mm\n", + "\n", + "#Load applied\n", + "W=dell*G*d**4*(64*R**3*n)**-1 #N \n", + "\n", + "#Energy each spring can absorb is\n", + "E2=W*dell*2**-1 #N-mm\n", + "\n", + "#No.of springs required to absorb energy of Wagon\n", + "n2=E*E2**-1 *10**7\n", + "\n", + "#Result\n", + "print\"No.of springs Required for Buffer is\",round(n2,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No.of springs Required for Buffer is 4.47\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.25,Page No.259" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "b=180 #mm #width of flange\n", + "d=10 #mm #Depth of flange\n", + "t=10 #mm #Thickness of flange\n", + "D=400 #mm #Overall Depth \n", + "\n", + "#Calculations\n", + "\n", + "I_xx=1*12**-1*(b*D**3-(b-t)*(D-2*d)**3)\n", + "I_yy=1*12**-1*((D-2*d)*t**3+2*t*b**3)\n", + "\n", + "#If warping is neglected\n", + "J=I_xx+I_yy #mm**4\n", + "\n", + "#Since b/d>1.6,we get\n", + "J2=1*3**-1*d**3*b*(1-0.63*d*b**-1)*2+1*3**-1*t**3*(D-2*d)*(1-0.63*t*b**-1)\n", + "\n", + "#Over Estimation of torsional Rigidity would have been \n", + "T=J*J2**-1\n", + "\n", + "#Result\n", + "print\"Error in assessing torsional Rigidity if the warping is neglected is\",round(T,2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Error in assessing torsional Rigidity if the warping is neglected is 808.28\n" + ] + } + ], + "prompt_number": 68 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 6.6.26,Page No.261" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "d1=100 #mm #Outer Diameter\n", + "d2=95 #mm #Inner Diameter\n", + "T=2*10**6 #N-mm #Torque\n", + "\n", + "#Calculations\n", + "\n", + "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus\n", + "\n", + "#Shear stress\n", + "q_max=T*J**-1*d1*2**-1 #N/mm**2 \n", + "\n", + "#Now theta*L**-1=T*(G*J)**-1\n", + "#After substituting values and further simplifying we get\n", + "#Let theta*L**-1=X\n", + "X=T*J**-1\n", + "\n", + "#Now Treating it as very thin walled tube\n", + "d=(d1+d2)*2**-1 #mm\n", + "\n", + "r=d*2**-1 \n", + "t=(d1-d2)*2**-1\n", + "q_max2=T*(2*pi*r**2*t)**-1 #N/mm**2\n", + "\n", + "X2=T*(2*pi*r**3*t)**-1 \n", + "\n", + "#Result\n", + "print\"When it is treated as hollow shaft:Max shear stress\",round(q_max,2),\"N/mm**2\"\n", + "print\" :Angle of Twist per unit Length\",round(X,3)\n", + "print\"When it is very thin Walled Tube :Max shear stress\",round(q_max2,2),\"N/mm**2\"\n", + "print\" :Angle of twist per Unit Length\",round(X2,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "When it is treated as hollow shaft:Max shear stress 54.91 N/mm**2\n", + " :Angle of Twist per unit Length 1.098\n", + "When it is very thin Walled Tube :Max shear stress 53.57 N/mm**2\n", + " :Angle of twist per Unit Length 1.099\n" + ] + } + ], + "prompt_number": 72 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/RohitPhadtare/chapter_1.ipynb b/sample_notebooks/RohitPhadtare/chapter_1.ipynb new file mode 100755 index 00000000..ff3fcb22 --- /dev/null +++ b/sample_notebooks/RohitPhadtare/chapter_1.ipynb @@ -0,0 +1,438 @@ +{ + "metadata": { + "name": "chapter 1 som.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Centre Of Gravity\n" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.1,Page No.8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of Variables\n", + "\n", + "#Rectangle-1\n", + "a_1=37.5 #cm**2 \n", + "y_1=26.25 #cm \n", + "\n", + "#Rectangle-2\n", + "a_2=50 #cm**2 \n", + "y_2=15 #cm \n", + "\n", + "#Rectangle-3\n", + "a_3=150 #cm**2 \n", + "y_3=2.5 #cm \n", + "\n", + "\n", + "#Calculation\n", + "\n", + "\n", + "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3)*(a_1+a_2+a_3)**-1 #cm \n", + "\n", + "#Result\n", + "print\"The centroid of the section is\",round(Y_bar,2),\"cm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centroid of the section is 8.88 cm\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.2,Page No.9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "#Area-1\n", + "a_1=6 #cm**2 \n", + "x_1=3 #cm\n", + "y_1=0.5 #cm\n", + "\n", + "#Area-2\n", + "a_2=6 #cm**2\n", + "x_2=2.671 #cm\n", + "y_2=3 #cm\n", + "\n", + "#Area-3\n", + "a_3=16 #cm**2\n", + "x_3=1 #cm\n", + "y_3=5 #cm\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "\n", + "X_bar=(a_1*x_1+a_2*x_2+a_3*x_3)*(a_1+a_2+a_3)**-1 #cm\n", + "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3)*(a_1+a_2+a_3)**-1 #cm\n", + "\n", + "\n", + "#Result\n", + "print\"The centre of gravity of section is\",round(X_bar,2),\"cm\"\n", + "print\"The centre of gravity of section is\",round(Y_bar,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centre of gravity of section is 1.79 cm\n", + "The centre of gravity of section is 3.61 cm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.3,Page no.10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "#Area-1\n", + "a_1=93.75 #cm**2 \n", + "y_1=6.25 #cm\n", + "\n", + "#Area-2\n", + "a_2=93.75 #cm**2 \n", + "y_2=6.25 #cm\n", + "\n", + "#Area-3\n", + "a_3=375 #cm**2 \n", + "y_3=9.375 #cm\n", + "\n", + "#Area-4\n", + "a_4=353.43 #cm**2\n", + "y_4=6.366 #cm\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3-a_4*y_4)*(a_1+a_2+a_3-a_4)**-1 #cm\n", + "\n", + "\n", + "#Result\n", + "print\"The centre of gravity lies at a distance of \",round(Y_bar,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centre of gravity lies at a distance of 11.66 cm\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.4,Page no.10\n", + "\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "\n", + "a_1=36*pi #cm**2 #Area of Quadrant of a circle\n", + "x_1=16/pi #cm \n", + "y_1=16*pi**-1 #cm\n", + "\n", + "\n", + "a_2=18*pi #cm**2 #Area of the semicircle\n", + "x_2=6 #cm\n", + "y_2=8*pi**-1 #cm\n", + "\n", + "\n", + "#Calculation-1\n", + "\n", + "X_bar=(a_1*x_1-a_2*x_2)*(a_1-a_2)**-1 #cm\n", + "\n", + "#Calculation-2\n", + "#To calculate Y_bar,taking AB as the Reference line\n", + "\n", + "Y_bar=(a_1*y_1-a_2*y_2)*(a_1-a_2)**-1 #cm\n", + "\n", + "#Result\n", + "\n", + "print\"The centre of gravity is \",round(X_bar,2),\"cm\"\n", + "print\"The centre of gravity is\",round(Y_bar,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centre of gravity is 4.19 cm\n", + "The centre of gravity is 7.64 cm\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.5,Page no.11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "#Circle-1 \n", + "a_1=100*pi #cm**2\n", + "x_1=10 #cm\n", + " \n", + "#Square-2 \n", + "a_2=50 #cm**2\n", + "x_2=15 #cm\n", + " \n", + "#Calculation\n", + "\n", + "X_bar=(a_1*x_1-a_2*x_2)*(a_1-a_2)**-1 #cm\n", + "\n", + "\n", + "#Result\n", + "print\"The centre of gravity is\",round(X_bar,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centre of gravity is 9.05 cm\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.6,Page no.12\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#intilization of variables \n", + "\n", + "#Rectangle-1\n", + "a_1=51200 #mm**2 \n", + "x_1=160 #mm\n", + "y_1=80 #mm\n", + "\n", + "#Triangle-2\n", + "a_2=6400 #mm**2\n", + "x_2=80*3**-1 #mm\n", + "y_2=320*3**-1 #mm\n", + "\n", + "#Semicircle-3\n", + "a_3=1250*pi #mm**2\n", + "x_3=210 #mm\n", + "y_3=(160-(4*50-(3*pi)**-1)) #mm\n", + "\n", + "\n", + "#Calculation\n", + "\n", + "X_bar=(a_1*x_1-a_2*x_2-a_3*x_3)*(a_1-a_2-a_3)**-1 #mm\n", + "Y_bar=(a_1*y_1-a_2*y_2-a_3*y_3)*(a_1-a_2-a_3)**-1 #mm\n", + "\n", + "#Result\n", + "print\"The centroid of the given area is\",round(X_bar,2),\"mm\"\n", + "print\"The centroid of the given area is\",round(Y_bar,2),\"mm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centroid of the given area is 176.07 mm\n", + "The centroid of the given area is 87.34 mm\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1.8,Page no.12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "\n", + "alpha=pi/2 #degree #In case of semicircle\n", + "\n", + "#Semicircle-1\n", + "r_1=20 #cm #radius of semicircle \n", + "y_1=4*r_1*(3*pi)**-1 #cm #distance from the base\n", + "a_1=(pi*r_1**2)*2**-1 #cm**2 #area of semicircle\n", + "\n", + "#Semicircle-2\n", + "r_2=16 #cm #radius of semicircle\n", + "y_2=4*r_2*(3*pi)**-1 #cm #distance from the base\n", + "a_2=(pi*r_2**2)*2**-1 #cm**2 #area of semicircle\n", + "\n", + "#Calculations\n", + "\n", + "\n", + "Y_bar=(a_1*y_1-a_2*y_2)*(a_1-a_2)**-1 #cm #centroid\n", + "\n", + "\n", + "#Result\n", + "print\"The centroid of the area is \",round(Y_bar,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The centroid of the area is 11.51 cm\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem no1.12,Page no.16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Initilization of variables\n", + "\n", + "#Right Circular Cyclinder\n", + "#m_1=(16*pi*h*rho_1) #gm \n", + "#y_1=4+h*2**-1 #cm\n", + "\n", + "#Hemisphere\n", + "#m_2=256*pi*rho_1 #gm \n", + "y_2=2.5 #cm \n", + "\n", + "Y_bar=4 #cm\n", + "r=4 #cm\n", + "\n", + "#Calculation\n", + "\n", + "#Y_bar=(m_1*y_1+m_2*y_2)*(m_1+m_2)**-1 #cm #Centroid\n", + "h=(402.114*25.132**-1)**0.5\n", + "\n", + "#Result\n", + "print\"The value of h is\",round(h,2),\"cm\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The value of h is 4.0 cm\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/RohitPhadtare/chapter_1_som.ipynb b/sample_notebooks/RohitPhadtare/chapter_1_som.ipynb deleted file mode 100755 index ff3fcb22..00000000 --- a/sample_notebooks/RohitPhadtare/chapter_1_som.ipynb +++ /dev/null @@ -1,438 +0,0 @@ -{ - "metadata": { - "name": "chapter 1 som.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Centre Of Gravity\n" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.1,Page No.8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "#Rectangle-1\n", - "a_1=37.5 #cm**2 \n", - "y_1=26.25 #cm \n", - "\n", - "#Rectangle-2\n", - "a_2=50 #cm**2 \n", - "y_2=15 #cm \n", - "\n", - "#Rectangle-3\n", - "a_3=150 #cm**2 \n", - "y_3=2.5 #cm \n", - "\n", - "\n", - "#Calculation\n", - "\n", - "\n", - "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3)*(a_1+a_2+a_3)**-1 #cm \n", - "\n", - "#Result\n", - "print\"The centroid of the section is\",round(Y_bar,2),\"cm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centroid of the section is 8.88 cm\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.2,Page No.9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "#Area-1\n", - "a_1=6 #cm**2 \n", - "x_1=3 #cm\n", - "y_1=0.5 #cm\n", - "\n", - "#Area-2\n", - "a_2=6 #cm**2\n", - "x_2=2.671 #cm\n", - "y_2=3 #cm\n", - "\n", - "#Area-3\n", - "a_3=16 #cm**2\n", - "x_3=1 #cm\n", - "y_3=5 #cm\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "\n", - "X_bar=(a_1*x_1+a_2*x_2+a_3*x_3)*(a_1+a_2+a_3)**-1 #cm\n", - "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3)*(a_1+a_2+a_3)**-1 #cm\n", - "\n", - "\n", - "#Result\n", - "print\"The centre of gravity of section is\",round(X_bar,2),\"cm\"\n", - "print\"The centre of gravity of section is\",round(Y_bar,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centre of gravity of section is 1.79 cm\n", - "The centre of gravity of section is 3.61 cm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.3,Page no.10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "#Area-1\n", - "a_1=93.75 #cm**2 \n", - "y_1=6.25 #cm\n", - "\n", - "#Area-2\n", - "a_2=93.75 #cm**2 \n", - "y_2=6.25 #cm\n", - "\n", - "#Area-3\n", - "a_3=375 #cm**2 \n", - "y_3=9.375 #cm\n", - "\n", - "#Area-4\n", - "a_4=353.43 #cm**2\n", - "y_4=6.366 #cm\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "Y_bar=(a_1*y_1+a_2*y_2+a_3*y_3-a_4*y_4)*(a_1+a_2+a_3-a_4)**-1 #cm\n", - "\n", - "\n", - "#Result\n", - "print\"The centre of gravity lies at a distance of \",round(Y_bar,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centre of gravity lies at a distance of 11.66 cm\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.4,Page no.10\n", - "\n" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "\n", - "a_1=36*pi #cm**2 #Area of Quadrant of a circle\n", - "x_1=16/pi #cm \n", - "y_1=16*pi**-1 #cm\n", - "\n", - "\n", - "a_2=18*pi #cm**2 #Area of the semicircle\n", - "x_2=6 #cm\n", - "y_2=8*pi**-1 #cm\n", - "\n", - "\n", - "#Calculation-1\n", - "\n", - "X_bar=(a_1*x_1-a_2*x_2)*(a_1-a_2)**-1 #cm\n", - "\n", - "#Calculation-2\n", - "#To calculate Y_bar,taking AB as the Reference line\n", - "\n", - "Y_bar=(a_1*y_1-a_2*y_2)*(a_1-a_2)**-1 #cm\n", - "\n", - "#Result\n", - "\n", - "print\"The centre of gravity is \",round(X_bar,2),\"cm\"\n", - "print\"The centre of gravity is\",round(Y_bar,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centre of gravity is 4.19 cm\n", - "The centre of gravity is 7.64 cm\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.5,Page no.11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "#Circle-1 \n", - "a_1=100*pi #cm**2\n", - "x_1=10 #cm\n", - " \n", - "#Square-2 \n", - "a_2=50 #cm**2\n", - "x_2=15 #cm\n", - " \n", - "#Calculation\n", - "\n", - "X_bar=(a_1*x_1-a_2*x_2)*(a_1-a_2)**-1 #cm\n", - "\n", - "\n", - "#Result\n", - "print\"The centre of gravity is\",round(X_bar,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centre of gravity is 9.05 cm\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.6,Page no.12\n" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#intilization of variables \n", - "\n", - "#Rectangle-1\n", - "a_1=51200 #mm**2 \n", - "x_1=160 #mm\n", - "y_1=80 #mm\n", - "\n", - "#Triangle-2\n", - "a_2=6400 #mm**2\n", - "x_2=80*3**-1 #mm\n", - "y_2=320*3**-1 #mm\n", - "\n", - "#Semicircle-3\n", - "a_3=1250*pi #mm**2\n", - "x_3=210 #mm\n", - "y_3=(160-(4*50-(3*pi)**-1)) #mm\n", - "\n", - "\n", - "#Calculation\n", - "\n", - "X_bar=(a_1*x_1-a_2*x_2-a_3*x_3)*(a_1-a_2-a_3)**-1 #mm\n", - "Y_bar=(a_1*y_1-a_2*y_2-a_3*y_3)*(a_1-a_2-a_3)**-1 #mm\n", - "\n", - "#Result\n", - "print\"The centroid of the given area is\",round(X_bar,2),\"mm\"\n", - "print\"The centroid of the given area is\",round(Y_bar,2),\"mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centroid of the given area is 176.07 mm\n", - "The centroid of the given area is 87.34 mm\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1.8,Page no.12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "\n", - "alpha=pi/2 #degree #In case of semicircle\n", - "\n", - "#Semicircle-1\n", - "r_1=20 #cm #radius of semicircle \n", - "y_1=4*r_1*(3*pi)**-1 #cm #distance from the base\n", - "a_1=(pi*r_1**2)*2**-1 #cm**2 #area of semicircle\n", - "\n", - "#Semicircle-2\n", - "r_2=16 #cm #radius of semicircle\n", - "y_2=4*r_2*(3*pi)**-1 #cm #distance from the base\n", - "a_2=(pi*r_2**2)*2**-1 #cm**2 #area of semicircle\n", - "\n", - "#Calculations\n", - "\n", - "\n", - "Y_bar=(a_1*y_1-a_2*y_2)*(a_1-a_2)**-1 #cm #centroid\n", - "\n", - "\n", - "#Result\n", - "print\"The centroid of the area is \",round(Y_bar,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The centroid of the area is 11.51 cm\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem no1.12,Page no.16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of variables\n", - "\n", - "#Right Circular Cyclinder\n", - "#m_1=(16*pi*h*rho_1) #gm \n", - "#y_1=4+h*2**-1 #cm\n", - "\n", - "#Hemisphere\n", - "#m_2=256*pi*rho_1 #gm \n", - "y_2=2.5 #cm \n", - "\n", - "Y_bar=4 #cm\n", - "r=4 #cm\n", - "\n", - "#Calculation\n", - "\n", - "#Y_bar=(m_1*y_1+m_2*y_2)*(m_1+m_2)**-1 #cm #Centroid\n", - "h=(402.114*25.132**-1)**0.5\n", - "\n", - "#Result\n", - "print\"The value of h is\",round(h,2),\"cm\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The value of h is 4.0 cm\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/RohitPhadtare/chapter_no.6.ipynb b/sample_notebooks/RohitPhadtare/chapter_no.6.ipynb deleted file mode 100755 index 4657aa0b..00000000 --- a/sample_notebooks/RohitPhadtare/chapter_no.6.ipynb +++ /dev/null @@ -1,1494 +0,0 @@ -{ - "metadata": { - "name": "chapter no.6.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter No.6:Torsion" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.1,Page No.225" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "L=10000 #mm #Length of solid shaft\n", - "d=100 #mm #Diameter of shaft\n", - "n=150 #rpm\n", - "P=112.5*10**6 #N-mm/sec #Power Transmitted\n", - "G=82*10**3 #N/mm**2 #modulus of Rigidity\n", - "\n", - "#Calculations\n", - "\n", - "J=pi*d**4*(32)**-1 #mm**3 #Polar Modulus\n", - "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", - "\n", - "r=50 #mm #Radius\n", - "\n", - "q_s=T*r*J**-1 #N/mm**2 #Max shear stress intensity\n", - "Theta=T*L*(G*J)**-1 #angle of twist\n", - "\n", - "#Result\n", - "print\"Max shear stress intensity\",round(q_s,2),\"N/mm**2\"\n", - "print\"Angle of Twist\",round(Theta,3),\"radian\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Max shear stress intensity 36.48 N/mm**2\n", - "Angle of Twist 0.089 radian\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.2,Page No.226" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "P=440*10**6 #N-m/sec #Power transmitted\n", - "n=280 #rpm\n", - "theta=pi*180**-1 #radian #angle of twist\n", - "L=1000 #mm #Length of solid shaft\n", - "q_s=40 #N/mm**2 #Max torsional shear stress\n", - "G=84*10**3 #N/mm**2 #Modulus of rigidity\n", - "\n", - "#Calculations\n", - "\n", - "#P=2*pi*n*T*(60)**-1 #Equation of Power transmitted\n", - "T=P*60*(2*pi*n)**-1 #N-mm #torsional moment\n", - "\n", - "#From Consideration of shear stress\n", - "d1=(T*16*(pi*40)**-1)**0.333333 \n", - "\n", - "#From Consideration of angle of twist\n", - "d2=(T*L*32*180*(pi*84*10**3*pi)**-1)**0.25\n", - "\n", - "#result\n", - "print\"Diameter of solid shaft is\",round(d1,2),\"mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diameter of solid shaft is 124.09 mm\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.3,Page No.227" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "G=80*10**3 #N/mm**2 #Modulus of rigidity\n", - "q_s=80 #N/mm**2 #Max sheare stress\n", - "P=736*10**6 #N-mm/sec #Power transmitted\n", - "n=200\n", - "\n", - "#Calculations\n", - "\n", - "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", - "\n", - "#Now From consideration of angle of twist\n", - "theta=pi*180**-1\n", - "#L=15*d\n", - "\n", - "d=(T*32*180*15*(pi**2*G)**-1)**0.33333\n", - "\n", - "#Now corresponding stress at the surface is\n", - "q_s2=T*32*d*(pi*2*d**4)**-1\n", - "\n", - "#Result\n", - "print\"Max diameter required is\",round(d,2),\"mm\"\n", - "print\"Corresponding shear stress is\",round(q_s2,2),\"N/mm**2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Max diameter required is 156.66 mm\n", - "Corresponding shear stress is 46.55 N/mm**2\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.4,Page No.228" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d=25 #mm #Diameter of steel bar\n", - "p=50*10**3 #N #Pull\n", - "dell_1=0.095 #mm #Extension of bar\n", - "l=200 #mm #Guage Length\n", - "T=200*10**3 #N-mm #Torsional moment\n", - "theta=0.9*pi*180**-1 #angle of twist\n", - "L=250 #mm Length of steel bar\n", - "\n", - "#Calculations\n", - "\n", - "A=pi*4**-1*d**2 #Area of steel bar #mm**2\n", - "E=p*l*(dell_1*A)**-1 #N/mm**2 #Modulus of elasticity \n", - "\n", - "J=pi*32**-1*d**4 #mm**4 #Polar modulus\n", - "\n", - "G=T*L*(theta*J)**-1 #Modulus of rigidity #N/mm**2\n", - "\n", - "#Now from the relation of Elastic constants\n", - "mu=E*(2*G)**-1-1\n", - "\n", - "#result\n", - "print\"The Poissoin's ratio is\",round(mu,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Poissoin's ratio is 0.292\n" - ] - } - ], - "prompt_number": 30 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.5,Page No.229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "L=6000 #mm #Length of circular shaft\n", - "d1=100 #mm #Outer Diameter\n", - "d2=75 #mm #Inner Diameter\n", - "R=100*2**-1 #Radius of shaft\n", - "T=10*10**6 #N-mm #Torsional moment\n", - "G=80*10**3 #N/mm**2 #Modulus of Rigidity\n", - "\n", - "#Calculations\n", - "\n", - "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus \n", - "\n", - "#Max Shear stress produced\n", - "q_s=T*R*J**-1 #N/mm**2\n", - "\n", - "#Angle of twist\n", - "theta=T*L*(G*J)**-1 #Radian\n", - "\n", - "#Result\n", - "print\"MAx shear stress produced is\",round(q_s,2),\"N/mm**2\"\n", - "print\"Angle of Twist is\",round(theta,2),\"Radian\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "MAx shear stress produced is 74.5 N/mm**2\n", - "Angle of Twist is 0.11 Radian\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.6,Page No.229" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d1=200 #mm #External Diameter of shaft\n", - "t=25 #mm #Thickness of shaft\n", - "n=200 #rpm\n", - "theta=0.5*pi*180**-1 #Radian #angle of twist\n", - "L=2000 #mm #Length of shaft\n", - "G=84*10**3 #N/mm**2\n", - "d2=d1-2*t #mm #Internal Diameter of shaft\n", - "\n", - "#Calculations\n", - "\n", - "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus \n", - "\n", - "#Torsional moment\n", - "T=G*J*theta*L**-1 #N/mm**2 \n", - "\n", - "#Power Transmitted\n", - "P=2*pi*n*T*60**-1*10**-6 #N-mm\n", - "\n", - "#Max shear stress transmitted\n", - "q_s=G*theta*(d1*2**-1)*L**-1 #N/mm**2 \n", - "\n", - "#Result\n", - "print\"Power Transmitted is\",round(P,2),\"N-mm\"\n", - "print\"Max Shear stress produced is\",round(q_s,2),\"N/mm**2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Power Transmitted is 824.28 N-mm\n", - "Max Shear stress produced is 36.65 N/mm**2\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.7,Page No.230" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "P=3750*10**6 #N-mm/sec\n", - "n=240 #Rpm\n", - "q_s=160 #N/mm**2 #Max shear stress\n", - "\n", - "#Calculations\n", - "\n", - "#d2=0.8*d2 #mm #Internal Diameter of shaft\n", - "\n", - "#J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar modulus\n", - "#After substituting value in above Equation we get\n", - "#J=0.05796*d1**4\n", - "\n", - "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", - "\n", - "#Now from Torsion Formula\n", - "#T*J**-1=q_s*R**-1 ......................................(1)\n", - "\n", - "#But R=d1*2**-1 \n", - "\n", - "#Now substituting value of R and J in Equation (1) we get\n", - "d1=(T*(0.05796*q_s*2)**-1)**0.33333\n", - "\n", - "d2=d1*0.8\n", - "\n", - "#Result\n", - "print\"The size of the Shaft is:d1\",round(d1,3),\"mm\"\n", - "print\" :d2\",round(d2,3),\"mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The size of the Shaft is:d1 200.362 mm\n", - " :d2 160.289 mm\n" - ] - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.8,Page No.231" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "P=245*10**6 #N-mm/sec #Power transmitted\n", - "n=240 #rpm\n", - "q_s=40 #N/mm**2 #Shear stress\n", - "theta=pi*180**-1 #radian #Angle of twist\n", - "L=1000 #mm #Length of shaft\n", - "G=80*10**3 #N/mm**2\n", - "\n", - "#Tmax=1.5*T\n", - "\n", - "#Calculations\n", - "\n", - "T=P*60*(2*pi*n)**-1 #N-mm #Torsional Moment\n", - "Tmax=1.5*T\n", - "\n", - "#Now For Solid shaft\n", - "#J=pi*32*d**4\n", - "\n", - "#Now from the consideration of shear stress we get\n", - "#T*J**-1=q_s*(d*2**-1)**-1\n", - "#After substituting value in above Equation we get\n", - "#T=pi*16**-1*d**3*q_s\n", - "\n", - "#Designing For max Torque\n", - "d=(Tmax*16*(pi*40)**-1)**0.33333 #mm #Diameter of shaft\n", - "\n", - "#For max Angle of Twist\n", - "#Tmax*J**-1=G*theta*L**-1 \n", - "#After substituting value in above Equation we get\n", - "d2=(Tmax*32*180*L*(pi**2*G)**-1)**0.25\n", - "\n", - "#For Hollow Shaft\n", - "\n", - "#d1_2=Outer Diameter\n", - "#d2_2=Inner Diameter\n", - "\n", - "#d2_2=0.5*d1_2\n", - "\n", - "# Polar modulus\n", - "#J=pi*32**-1*(d1_2**4-d2_2**4)\n", - "#After substituting values we get\n", - "#J=0.092038*d1_2**4\n", - "\n", - "#Now from the consideration of stress\n", - "#Tmax*J**-1=q_s*(d1_2*2**-1)**-1\n", - "#After substituting values and further simplifying we get\n", - "d1_2=(Tmax*(0.092038*2*q_s)**-1)**0.33333\n", - "\n", - "#Now from the consideration of angle of twist\n", - "#Tmax*J**-1=G*theta*L**-1\n", - "#After substituting values and further simplifying we get\n", - "d1_3=(Tmax*180*L*(0.092038*G*pi)**-1)**0.25\n", - "\n", - "d2_2=0.5*d1_2\n", - "\n", - "#result\n", - "print\"Diameter of shaft is:For solid shaft:d\",round(d,2),\"mm\"\n", - "print\" :For Hollow shaft:d1_2\",round(d1_2,3),\"mm\"\n", - "print\" : :d2_2\",round(d2_2,3),\"mm\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diameter of shaft is:For solid shaft:d 123.01 mm\n", - " :For Hollow shaft:d1_2 125.69 mm\n", - " : :d2_2 62.845 mm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.11,Page No.235" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "P=250*10**6 #N-mm/sec #Power transmitted\n", - "n=100 #rpm\n", - "q_s=75 #N/mm**2 #Shear stress\n", - "\n", - "#Calculations\n", - "\n", - "#From Equation of Power we have\n", - "T=P*60*(2*pi*n)**-1 #N-mm #Torsional moment\n", - "\n", - "#Now from torsional moment equation we have\n", - "#T=j*q_s*(d/2**-1)**-1\n", - "#After substituting values in above equation and further simplifying we get\n", - "#T=pi*16**-1**d**3*q_s\n", - "d=(T*16*(pi*q_s)**-1)**0.3333 #mm #Diameter of solid shaft\n", - "\n", - "#PArt-2\n", - "\n", - "#Let d1 and d2 be the outer and inner diameter of hollow shaft\n", - "#d2=0.6*d1\n", - "\n", - "#Again from torsional moment equation we have\n", - "#T=pi*32**-1*(d1**4-d2**4)*q_s*(d1/2)**-1\n", - "d1=(T*16*(pi*(1-0.6**4)*q_s)**-1)**0.33333\n", - "d2=0.6*d1\n", - "\n", - "#Cross sectional area of solid shaft\n", - "A1=pi*4**-1*d**2 #mm**2\n", - "\n", - "#cross sectional area of hollow shaft\n", - "A2=pi*4**-1*(d1**2-d2**2)\n", - "\n", - "#Now percentage saving in weight\n", - "#Let W be the percentage saving in weight\n", - "W=(A1-A2)*100*A1**-1\n", - "\n", - "#Result\n", - "print\"Percentage saving in Weight is\",round(W,3),\"%\"\n", - "print\"Size of shaft is:solid shaft:d\",round(d,3),\"mm\"\n", - "print\" :Hollow shaft:d1\",round(d1,3),\"mm\"\n", - "print\" : :d2\",round(d2,3),\"mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Percentage saving in Weight is 29.735 %\n", - "Size of shaft is:solid shaft:d 117.418 mm\n", - " :Hollow shaft:d1 123.031 mm\n", - " : :d2 73.818 mm\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.12,Page No.237" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "d=100 #mm #Diameter of solid shaft\n", - "d1=100 #mm #Outer Diameter of hollow shaft\n", - "d2=50 #mm #Inner Diameter of hollow shaft\n", - "\n", - "#Calculations\n", - "\n", - "#Torsional moment of solid shaft\n", - "#T_s=J*q_s*(d*2**-1)**-1 \n", - "#After substituting values in above equation and further simplifying we get\n", - "#T_s=pi*16*d**3*q_s ...............(1)\n", - "\n", - "#torsional moment for hollow shaft is\n", - "#T_h=J*q_s*(d1**4-d2**4)**-1*(d1*2**-1)\n", - "#After substituting values in above equation and further simplifying we get\n", - "#T_h=pi*32**-1*2*d1**-1*(d1**4-d2**4)*q_s ...........(2)\n", - "\n", - "#Dividing Equation 2 by 1 we get\n", - "#Let the ratio of T_h*T_s**-1 Be X\n", - "X=1-0.5**4\n", - "\n", - "#Loss in strength \n", - "#Let s be the loss in strength\n", - "#s=T_s*T_h*100*T_s**-1\n", - "#After substituting values in above equation and further simplifying we get\n", - "s=(1-0.9375)*100\n", - "\n", - "#Weight Ratio \n", - "#Let w be the Weight ratio\n", - "#w=W_h*W_s**-1\n", - "\n", - "A_h=pi*32**-1*(d1**2-d2**2) #mm**2 #Area of Hollow shaft\n", - "A_s=pi*32**-1*d**2 #mm**2 #Area of solid shaft\n", - "\n", - "w=A_h*A_s**-1 \n", - "\n", - "#Result\n", - "print\"Loss in strength is\",round(s,2)\n", - "print\"Weight ratio is\",round(w,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Loss in strength is 6.25\n", - "Weight ratio is 0.75\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.13,Page No.239" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "T=8 #KN-m #Torque \n", - "d=100 #mm #Diameter of portion AB\n", - "d1=100 #mm #External Diameter of Portion BC\n", - "d2=75 #mm #Internal Diameter of Portion BC\n", - "G=80 #KN/mm**2 #Modulus of Rigidity\n", - "L1=1500 #mm #Radial Distance of Portion AB\n", - "L2=2500 #mm #Radial Distance ofPortion BC\n", - "\n", - "#Calculations\n", - "\n", - "R=d*2**-1 #mm #Radius of shaft\n", - "\n", - "#For Portion AB,Polar Modulus\n", - "J1=pi*32**-1*d**4 #mm**4 \n", - "\n", - "#For Portion BC,Polar modulus \n", - "J2=pi*32**-1*(d1**4-d2**4) #mm**4\n", - "\n", - "#Now Max stress occurs in portion BC since max radial Distance is sme in both cases\n", - "q_max=T*J2**-1*R*10**6 #N/mm**2 \n", - "\n", - "#Let theta1 be the rotation in Portion AB and theta2 be the rotation in portion BC\n", - "theta1=T*L1*(G*J1)**-1 #Radians\n", - "theta2=T*L2*(G*J2)**-1 #Radians\n", - "\n", - "#Total Rotational at end C\n", - "theta=(theta1+theta2)*10**3 #Radians\n", - "\n", - "#Result\n", - "print\"Max stress induced is\",round(q_max,2),\"N/mm**2\"\n", - "print\"Angle of Twist is\",round(theta,3),\"radians\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Max stress induced is 59.6 N/mm**2\n", - "Angle of Twist is 0.053 radians\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.14,Page No.240" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "q_b=80 #N/mm**2 #Shear stress in Brass\n", - "q_s=100 #N/mm**2 #Shear stress in Steel\n", - "G_b=40*10**3 #N/mm**2 \n", - "G_s=80*10**3 \n", - "L_b=1000 #mm #Length of brass shaft\n", - "L_s=1200 #mm #Length of steel shaft\n", - "d1=80 #mm #Diameter of brass shaft\n", - "d2=60 #mm #Diameter of steel shaft\n", - "\n", - "#Calculations\n", - "\n", - "#Polar modulus of brass rod\n", - "J_b=pi*32**-1*d1**4 #mm**4 \n", - "\n", - "#Polar modulus of steel rod\n", - "J_s=pi*32**-1*d2**4 #mm**4\n", - "\n", - "#Considering bras Rod:AB\n", - "T1=J_b*q_b*(d1*2**-1)**-1 #N-mm \n", - "\n", - "#Considering Steel Rod:BC\n", - "T2=J_s*q_s*(d2*2**-1)**-1 #N-mm\n", - "\n", - "#Max Torque that can be applied\n", - "T2\n", - "\n", - "#Let theta_b and theta_s be the rotations in Brass and steel respectively\n", - "theta_b=T2*L_b*(G_b*J_b)**-1 #Radians\n", - "theta_s=T2*L_s*(G_s*J_s)**-1 #Radians\n", - "\n", - "theta=theta_b+theta_s #Radians #Rotation of free end\n", - "\n", - "#Result\n", - "print\"Total of free end is\",round(theta,3),\"Radians\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total of free end is 0.076 Radians\n" - ] - } - ], - "prompt_number": 36 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.15,Page No.241" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "G=80*10**3 #N/mm**2 #Modulus of Rigidity\n", - "d1=100 #mm #Outer diameter of hollow shft\n", - "d2=80 #mm #Inner diameter of hollow shaft\n", - "d=80 #mm #diameter of Solid shaft\n", - "d3=60 #mm #diameter of Solid shaft having L=0.5m\n", - "L1=300 #mm #Length of Hollow shaft\n", - "L2=400 #mm #Length of solid shaft\n", - "L3=500 #mm #LEngth of solid shaft of diameter 60mm\n", - "T1=2*10**6 #N-mm #Torsion in Shaft AB\n", - "T2=1*10**6 #N-mm #Torsion in shaft BC\n", - "T3=1*10**6 #N-mm #Torsion in shaft CD\n", - "\n", - "#Calculations\n", - "\n", - "#Now Polar modulus of section AB\n", - "J1=pi*32**-1*(d1**4-d2**4) #mm**4 \n", - "\n", - "#Polar modulus of section BC\n", - "J2=pi*32**-1*d**4 #mm**4\n", - "\n", - "#Polar modulus of section CD\n", - "J3=pi*32**-1*d3**4 #mm**4\n", - "\n", - "#Now angle of twist of AB\n", - "theta1=T1*L1*(G*J1)**-1 #radians\n", - "\n", - "#Angle of twist of BC\n", - "theta2=T2*L2*(G*J2)**-1 #radians\n", - "\n", - "#Angle of twist of CD\n", - "theta3=T3*L3*(G*J3)**-1 #radians\n", - "\n", - "#Angle of twist\n", - "theta=theta1-theta2+theta3 #Radians\n", - "\n", - "#Shear stress in AB From Torsion Equation\n", - "q_s1=T1*(d1*2**-1)*J1**-1 #N/mm**2 \n", - "\n", - "#Shear stress in BC\n", - "q_s2=T2*(d*2**-1)*J2**-1 #N/mm**2 \n", - "\n", - "#Shear stress in CD\n", - "q_s3=T3*(d3*2**-1)*J3**-1 #N-mm**2\n", - "\n", - "#As max shear stress occurs in portion CD,so consider CD\n", - "\n", - "#Result\n", - "print\"Angle of twist at free end is\",round(theta,5),\"Radian\"\n", - "print\"Max Shear stress\",round(q_s3,2),\"N/mm**2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Angle of twist at free end is 0.00496 Radian\n", - "Max Shear stress 23.58 N/mm**2\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.16,Page No.242" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "L=1000 #mm #Length of bar\n", - "L1=600 #mm #Length of Bar AB\n", - "L2=400 #mm #Length of Bar BC\n", - "d1=60 #mm #Outer Diameter of bar BC\n", - "d2=30 #mm #Inner Diameter of bar BC\n", - "d=60 #mm #Diameter of bar AB\n", - "T=2*10**6 #N-mm #Total Torque\n", - "\n", - "#Calculations\n", - "\n", - "#Polar Modulus of Portion AB\n", - "J1=pi*32**-1*d**4 #mm*4\n", - "\n", - "#Polar Modulus of Portion BC\n", - "J2=pi*32**-1*(d1**4-d2**4) #mm**4\n", - "\n", - "#Let T1 be the torque resisted by bar AB and T2 be torque resisted by Bar BC\n", - "#Let theta1 and theta2 be the rotation of shaft in portion AB & BC\n", - "\n", - "#theta1=T1*L1*(G*J1)**-1 #radians\n", - "#After substituting values and further simplifying we get \n", - "#theta1=32*600*T1*(pi*60**4*G)**-1\n", - "\n", - "#theta2=T2*L*(J2*G)**-1 #Radians\n", - "#After substituting values and further simplifying we get \n", - "#theta2=32*400*T2*(pi*60**4*(1-0.5**4)*G)**-1 \n", - "\n", - "#Now For consistency of Deformation,theta1=theta2\n", - "#After substituting values and further simplifying we get \n", - "#T1=0.7111*T2 ..................................................(1)\n", - "\n", - "#But T1+T2=T=2*10**6 ...........................................(2)\n", - "#Substituting value of T1 in above equation\n", - "\n", - "T2=T*(0.7111+1)**-1\n", - "T1=0.71111*T2\n", - "\n", - "#Max stress in Portion AB\n", - "q_s1=T1*(d*2**-1)*(J1)**-1 #N/mm**2\n", - "\n", - "#Max stress in Portion BC\n", - "q_s2=T2*(d1*2**-1)*J2**-1 #N/mm**2 \n", - "\n", - "#Result\n", - "print\"Stresses Developed in Portion:AB\",round(q_s1,2),\"N/mm**2\"\n", - "print\" :BC\",round(q_s2,2),\"N/mm**2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Stresses Developed in Portion:AB 19.6 N/mm**2\n", - " :BC 29.4 N/mm**2\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.17,Page No.243" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d1=80 #mm #External Diameter of Brass tube\n", - "d2=50 #mm #Internal Diameter of Brass tube\n", - "d=50 #mm #Diameter of steel Tube\n", - "G_b=40*10**3 #N/mm**2 #Modulus of Rigidity of brass tube\n", - "G_s=80*10**3 #N/mm**2 #Modulus of rigidity of steel tube\n", - "T=6*10**6 #N-mm #Torque\n", - "L=2000 #mm #Length of Tube\n", - "\n", - "#Calculations\n", - "\n", - "#Polar Modulus of brass tube\n", - "J1=pi*32**-1*(d1**4-d2**4) #mm**4 \n", - "\n", - "#Polar modulus of steel Tube\n", - "J2=pi*32**-1*d**4 #mm**4\n", - "\n", - "#Let T_s & T_b be the torque resisted by steel and brass respectively\n", - "#Then, T_b+T_s=T ............................................(1)\n", - "\n", - "#Since the angle of twist will be the same\n", - "#Theta1=Theta2\n", - "#After substituting values and further simplifying we get \n", - "#Ts=0.360*Tb ...........................................(2)\n", - "\n", - "#After substituting value of Ts in eqn 1 and further simplifying we get \n", - "T_b=T*(0.36+1)**-1 #N-mm\n", - "T_s=0.360*T_b\n", - "\n", - "#Let q_s and q_b be the max stress in steel and brass respectively\n", - "q_b=T_b*(d1*2**-1)*J1**-1 #N/mm**2\n", - "q_s=T_s*(d2*2**-1)*J2**-1 #N/mm**2\n", - "\n", - "#Since angle of twist in brass=angle of twist in steel\n", - "theta_s=T_s*L*(J2*G_s)**-1\n", - "\n", - "#Result\n", - "print\"Stresses Developed in Materials are:Brass\",round(q_b,2),\"N/mm**2\"\n", - "print\" :Steel\",round(q_s,2),\"N/mm**2\"\n", - "print\"Angle of Twist in 2m Length\",round(theta_s,3),\"Radians\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Stresses Developed in Materials are:Brass 51.79 N/mm**2\n", - " :Steel 64.71 N/mm**2\n", - "Angle of Twist in 2m Length 0.065 Radians\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.18,Page No.245" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d1=60 #mm #External Diameter of aluminium Tube\n", - "d2=40 #mm #Internal Diameter of aluminium Tube\n", - "d=40 #mm #Diameter of steel tube\n", - "q_a=60 #N/mm**2 #Permissible stress in aluminium\n", - "q_s=100 #N/mm**2 #Permissible stress in steel tube\n", - "G_a=27*10**3 #N/mm**2 \n", - "G_s=80*10**3 #N/mm**2 \n", - "\n", - "#Calculations\n", - "\n", - "#Polar modulus of aluminium Tube\n", - "J_a=pi*32**-1*(d1**4-d2**4) #mm**4\n", - "\n", - "#Polar Modulus of steel Tube\n", - "J_s=pi*32**-1*d**4 #mm**4\n", - "\n", - "#Now the angle of twist of steel tube = angle of twist of aluminium tube\n", - "#T_s*L_s*(J_s*theta_s)**-1=T_a*L_a*(J_a*theta_a)**-1\n", - "#After substituting values in above Equation and Further simplifyin we get\n", - "#T_s=0.7293*T_a .....................(1)\n", - "\n", - "#If steel Governs the resisting capacity\n", - "T_s1=q_s*J_s*(d*2**-1)**-1 #N-mm\n", - "T_a1=T_s1*0.7293**-1 #N-mm\n", - "T1=(T_s1+T_a1)*10**-6 #KN-m #Total Torque in steel Tube\n", - "\n", - "#If aluminium Governs the resisting capacity \n", - "T_a2=q_a*J_a*(d1*2**-1) #N-mm\n", - "T_s2=T_a2*0.7293 #N-mm\n", - "T2=(T_s2+T_a2)*10**-6 #KN-m #Total Torque in aluminium tube\n", - "\n", - "#Result\n", - "print\"Steel Governs the torque carrying capacity\",round(T1,2),\"KN-m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Steel Governs the torque carrying capacity 2.98 KN-m\n" - ] - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.19,Page No.247" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "P=225*10**6 #N-mm/sec #Power Trasmitted\n", - "q_b=80 #N/mm**2 #Shear stress\n", - "n=200 #Rpm\n", - "q_k=100 #N/mm**2 #PErmissible stress in Keys\n", - "D=300 #mm #Diameter of bolt circle\n", - "L=150 #mm #Length of shear key\n", - "d=16 #mm #Diameterr of bolt\n", - "\n", - "#Calculations\n", - "T=60*P*(2*pi*n)**-1 #N-mm #Torque\n", - "\n", - "#Now From Torsion Formula\n", - "#T*J**-1=q_s*R**-1\n", - "#After substituting values we get\n", - "#T=pi*16*d**3*n\n", - "#After further simplifying we get\n", - "d1=(T*16*(pi*q_s)**-1)**0.33333\n", - "\n", - "#Let b be the width of shear Key\n", - "#T=q_k*L*b*R\n", - "#After simplifying further we get\n", - "b=T*(q_k*L*(d1*2**-1))**-1 #mm\n", - "\n", - "#Let n2 be the no. of bolts required at bolt circle of radius\n", - "R_b=D*2**-1 #mm \n", - "\n", - "n2=T*4*(q_b*pi*d**2*R_b)**-1\n", - "\n", - "#result\n", - "print\"Minimum no. of Bolts Required are\",round(n2,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Minimum no. of Bolts Required are 4.45\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.20,Page No.250" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "T=2*10**6 #N-mm #Torque transmitted\n", - "G=80*10**3 #N/mm**2 #Modulus of rigidity\n", - "d1=40 #mm \n", - "d2=80 #mm\n", - "r1=20 #mm\n", - "r2=40 #mm\n", - "L=2000 #mm #Length of shaft\n", - "\n", - "#Calculations\n", - "\n", - "#Angle of twist \n", - "theta=2*T*L*(r1**2+r1*r2+r2**2)*(3*pi*G*r2**3*r1**3)**-1 #radians\n", - "\n", - "#If the shaft is treated as shaft of average Diameter\n", - "d_avg=(d1+d2)*2**-1 #mm\n", - "\n", - "theta1=T*L*(G*pi*32**-1*d_avg**4)**-1 #Radians\n", - "\n", - "#Percentage Error\n", - "#Let Percentage Error be E\n", - "X=theta-theta1\n", - "E=(X*theta**-1)*100 \n", - "\n", - "#Result\n", - "print\"Percentage Error is\",round(E,2),\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Percentage Error is 32.28 %\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.21,Page No.252" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "G=80*10**3 #N/mm**2 \n", - "P=1*10**9 #N-mm/sec #Power\n", - "n=300 \n", - "d1=150 #mm #Outer Diameter\n", - "d2=120 #mm #Inner Diameter\n", - "L=2000 #mm #Length of circular shaft\n", - "\n", - "#Calculations\n", - "\n", - "T=P*60*(2*pi*n)**-1 #N-mm\n", - "\n", - "#Polar Modulus \n", - "J=pi*32**-1*(d1**4-d2**4) #mm**4\n", - "\n", - "q_s=T*J**-1*(d1*2**-1) #N/mm**2 \n", - "\n", - "\n", - "#Strain ENergy\n", - "U=q_s**2*(4*G)**-1*pi*4**-1*(d1**2-d2**2)*L\n", - "\n", - "#Result\n", - "print\"Max shear stress is\",round(q_s,2),\"N/mm**2\"\n", - "print\"Strain Energy stored in the shaft is\",round(U,2),\"N-mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Max shear stress is 81.36 N/mm**2\n", - "Strain Energy stored in the shaft is 263181.37 N-mm\n" - ] - } - ], - "prompt_number": 51 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.22,Page No.254" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d=12 #mm #Diameter of helical spring\n", - "D=150 #mm #Mean Diameter\n", - "R=D*2**-1 #mm #Radius of helical spring\n", - "n=10 #no.of turns\n", - "G=80*10**3 #N/mm**2 \n", - "W=450 #N #Load\n", - "\n", - "#Calculations\n", - "\n", - "#Max shear stress \n", - "q_s=16*W*R*(pi*d**3)**-1 #N/mm**2\n", - "\n", - "#Strain Energy stored\n", - "U=32*W**2*R**3*n*(G*d**4)**-1 #N-mm\n", - "\n", - "#Deflection Produced\n", - "dell=64*W*R**3*n*(G*d**4)**-1 #mm\n", - "\n", - "#Stiffness Spring\n", - "k=W*dell**-1 #N/mm\n", - "\n", - "#Result\n", - "print\"Max shear stress is\",round(q_s,2),\"N/mm**2\"\n", - "print\"Strain Energy stored is\",round(U,2),\"N-mm\"\n", - "print\"Deflection Produced is\",round(dell,2),\"mm\"\n", - "print\"Stiffness spring is\",round(k,2),\"N/mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Max shear stress is 99.47 N/mm**2\n", - "Strain Energy stored is 16479.49 N-mm\n", - "Deflection Produced is 73.24 mm\n", - "Stiffness spring is 6.14 N/mm\n" - ] - } - ], - "prompt_number": 53 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.23,Page No.255" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "K=5 #N/mm #Stiffness\n", - "L=100 #mm #Solid Length\n", - "q_s=60 #N/mm**2 #Max shear stress\n", - "W=200 #N #Max Load\n", - "G=80*10**3 #N/mm**2\n", - "\n", - "#Calculations\n", - "\n", - "#K=W*dell**-1\n", - "#After substituting values and further simplifying we get\n", - "#d=0.004*R**3*n ........(1) #mm #Diameter of wire\n", - "#n=L*d**-1 ........(2)\n", - "\n", - "#From Shearing stress\n", - "#q_s=16*W*R*(pi*d**3)**-1 \n", - "#After substituting values and further simplifying we get\n", - "#d**4=0.004*R**3*n .................(4)\n", - "\n", - "#From Equation 1,2,3\n", - "#d**4=0.004*(0.0785*d**3)**3*100*d**-1\n", - "#after further simplifying we get\n", - "d=5168.101**0.25\n", - "n=100*d**-1\n", - "R=(d**4*(0.004*n)**-1)**0.3333\n", - "\n", - "#Result\n", - "print\"Diameter of Wire is\",round(d,2),\"mm\"\n", - "print\"No.of turns is\",round(n,2)\n", - "print\"Mean Radius of spring is\",round(R,2),\"mm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Diameter of Wire is 8.48 mm\n", - "No.fo turns is 11.79\n", - "Mean Radius of spring is 47.83 mm\n" - ] - } - ], - "prompt_number": 54 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.24,Page No.255" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "m=5*10**5 #Wagon Weighing\n", - "v=18*1000*36000**-1 \n", - "d=300 #mm #Diameter of Beffer springs\n", - "n=18 #no.of turns\n", - "G=80*10**3 #N/mm**2\n", - "dell=225\n", - "R=100 #mm #Mean Radius\n", - "\n", - "#Calculations\n", - "\n", - "#Energy of Wagon\n", - "E=m*v**2*(9.81*2)**-1 #N-mm\n", - "\n", - "#Load applied\n", - "W=dell*G*d**4*(64*R**3*n)**-1 #N \n", - "\n", - "#Energy each spring can absorb is\n", - "E2=W*dell*2**-1 #N-mm\n", - "\n", - "#No.of springs required to absorb energy of Wagon\n", - "n2=E*E2**-1 *10**7\n", - "\n", - "#Result\n", - "print\"No.of springs Required for Buffer is\",round(n2,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No.of springs Required for Buffer is 4.47\n" - ] - } - ], - "prompt_number": 66 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.25,Page No.259" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "b=180 #mm #width of flange\n", - "d=10 #mm #Depth of flange\n", - "t=10 #mm #Thickness of flange\n", - "D=400 #mm #Overall Depth \n", - "\n", - "#Calculations\n", - "\n", - "I_xx=1*12**-1*(b*D**3-(b-t)*(D-2*d)**3)\n", - "I_yy=1*12**-1*((D-2*d)*t**3+2*t*b**3)\n", - "\n", - "#If warping is neglected\n", - "J=I_xx+I_yy #mm**4\n", - "\n", - "#Since b/d>1.6,we get\n", - "J2=1*3**-1*d**3*b*(1-0.63*d*b**-1)*2+1*3**-1*t**3*(D-2*d)*(1-0.63*t*b**-1)\n", - "\n", - "#Over Estimation of torsional Rigidity would have been \n", - "T=J*J2**-1\n", - "\n", - "#Result\n", - "print\"Error in assessing torsional Rigidity if the warping is neglected is\",round(T,2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Error in assessing torsional Rigidity if the warping is neglected is 808.28\n" - ] - } - ], - "prompt_number": 68 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 6.6.26,Page No.261" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Initilization of Variables\n", - "\n", - "d1=100 #mm #Outer Diameter\n", - "d2=95 #mm #Inner Diameter\n", - "T=2*10**6 #N-mm #Torque\n", - "\n", - "#Calculations\n", - "\n", - "J=pi*32**-1*(d1**4-d2**4) #mm**4 #Polar Modulus\n", - "\n", - "#Shear stress\n", - "q_max=T*J**-1*d1*2**-1 #N/mm**2 \n", - "\n", - "#Now theta*L**-1=T*(G*J)**-1\n", - "#After substituting values and further simplifying we get\n", - "#Let theta*L**-1=X\n", - "X=T*J**-1\n", - "\n", - "#Now Treating it as very thin walled tube\n", - "d=(d1+d2)*2**-1 #mm\n", - "\n", - "r=d*2**-1 \n", - "t=(d1-d2)*2**-1\n", - "q_max2=T*(2*pi*r**2*t)**-1 #N/mm**2\n", - "\n", - "X2=T*(2*pi*r**3*t)**-1 \n", - "\n", - "#Result\n", - "print\"When it is treated as hollow shaft:Max shear stress\",round(q_max,2),\"N/mm**2\"\n", - "print\" :Angle of Twist per unit Length\",round(X,3)\n", - "print\"When it is very thin Walled Tube :Max shear stress\",round(q_max2,2),\"N/mm**2\"\n", - "print\" :Angle of twist per Unit Length\",round(X2,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "When it is treated as hollow shaft:Max shear stress 54.91 N/mm**2\n", - " :Angle of Twist per unit Length 1.098\n", - "When it is very thin Walled Tube :Max shear stress 53.57 N/mm**2\n", - " :Angle of twist per Unit Length 1.099\n" - ] - } - ], - "prompt_number": 72 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures.ipynb b/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures.ipynb deleted file mode 100755 index 43ba034f..00000000 --- a/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures.ipynb +++ /dev/null @@ -1,548 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.1, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "temperature rise is 8.43 K\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "El=10**-2*50; #energy loss(J)\n", - "H=El*60; #heat produced(J)\n", - "d=7.7*10**3; #iron rod(kg/m**3)\n", - "s=0.462*10**-3; #specific heat(J/kg K)\n", - "\n", - "#Calculation\n", - "theta=H/(d*s); #temperature rise(K)\n", - "\n", - "#Result\n", - "print \"temperature rise is\",round(theta,2),\"K\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.2, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "magnetic field at the centre is 14.0 weber/m**2\n", - "dipole moment is 9.0 *10**-24 ampere/m**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "e=1.6*10**-19; #charge(coulomb)\n", - "new=6.8*10**15; #frequency(revolutions per second)\n", - "mew0=4*math.pi*10**-7;\n", - "R=5.1*10**-11; #radius(m)\n", - "\n", - "#Calculation\n", - "i=round(e*new,4); #current(ampere)\n", - "B=mew0*i/(2*R); #magnetic field at the centre(weber/m**2)\n", - "A=math.pi*R**2;\n", - "d=i*A; #dipole moment(ampere/m**2)\n", - "\n", - "#Result\n", - "print \"magnetic field at the centre is\",round(B),\"weber/m**2\"\n", - "print \"dipole moment is\",round(d*10**24),\"*10**-24 ampere/m**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.3, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "intensity of magnetisation is 5.0 ampere/m\n", - "flux density in material is 1.257 weber/m**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "chi=0.5*10**-5; #magnetic susceptibility\n", - "H=10**6; #field strength(ampere/m)\n", - "mew0=4*math.pi*10**-7;\n", - "\n", - "#Calculation\n", - "I=chi*H; #intensity of magnetisation(ampere/m)\n", - "B=mew0*(I+H); #flux density in material(weber/m**2)\n", - "\n", - "#Result\n", - "print \"intensity of magnetisation is\",I,\"ampere/m\"\n", - "print \"flux density in material is\",round(B,3),\"weber/m**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.4, Page number 6.47" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "number of Bohr magnetons is 2.22 bohr magneon/atom\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "B=9.27*10**-24; #bohr magneton(ampere m**2)\n", - "a=2.86*10**-10; #edge(m)\n", - "Is=1.76*10**6; #saturation value of magnetisation(ampere/m)\n", - "\n", - "#Calculation\n", - "N=2/a**3;\n", - "mew_bar=Is/N; #number of Bohr magnetons(ampere m**2)\n", - "mew_bar=mew_bar/B; #number of Bohr magnetons(bohr magneon/atom)\n", - "\n", - "#Result\n", - "print \"number of Bohr magnetons is\",round(mew_bar,2),\"bohr magneon/atom\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.5, Page number 6.47" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "average magnetic moment is 2.79 *10**-3 bohr magneton/spin\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "mew0=4*math.pi*10**-7;\n", - "H=9.27*10**-24; #bohr magneton(ampere m**2)\n", - "beta=10**6; #field(ampere/m)\n", - "k=1.38*10**-23; #boltzmann constant\n", - "T=303; #temperature(K)\n", - "\n", - "#Calculation\n", - "mm=mew0*H*beta/(k*T); #average magnetic moment(bohr magneton/spin)\n", - "\n", - "#Result\n", - "print \"average magnetic moment is\",round(mm*10**3,2),\"*10**-3 bohr magneton/spin\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.6, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hysteresis loss per cycle is 188.0 J/m**3\n", - "hysteresis loss per second is 9400.0 watt/m**3\n", - "power loss is 1.23 watt/kg\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "A=94; #area(m**2)\n", - "vy=0.1; #value of length(weber/m**2)\n", - "vx=20; #value of unit length\n", - "n=50; #number of magnetization cycles\n", - "d=7650; #density(kg/m**3)\n", - "\n", - "#Calculation\n", - "h=A*vy*vx; #hysteresis loss per cycle(J/m**3)\n", - "hs=h*n; #hysteresis loss per second(watt/m**3)\n", - "pl=hs/d; #power loss(watt/kg)\n", - "\n", - "#Result\n", - "print \"hysteresis loss per cycle is\",h,\"J/m**3\"\n", - "print \"hysteresis loss per second is\",hs,\"watt/m**3\"\n", - "print \"power loss is\",round(pl,2),\"watt/kg\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.7, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 5.43 Angstorm\n", - "density = 6.88 kg/m**3\n", - "#Answer given in the textbook is wrong\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "d=2.351 #bond lenght\n", - "N=6.02*10**26 #Avagadro number\n", - "n=8 #number of atoms in unit cell\n", - "A=28.09 #Atomin mass of silicon\n", - "m=6.02*10**26 #1mole\n", - "\n", - "#Calculations\n", - "a=(4*d)/math.sqrt(3)\n", - "p=(n*A)/((a*10**-10)*m) #density\n", - "\n", - "#Result\n", - "print \"a=\",round(a,2),\"Angstorm\"\n", - "print \"density =\",round(p*10**16,2),\"kg/m**3\"\n", - "print\"#Answer given in the textbook is wrong\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.8, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " radius of largest sphere is 0.154700538379252*r\n", - "maximum radius of sphere is 0.414213562373095*r\n" - ] - } - ], - "source": [ - " import math\n", - "from __future__ import division\n", - "from sympy import Symbol\n", - "\n", - "#Variable declaration\n", - "r=Symbol('r')\n", - "\n", - "#Calculation\n", - "a1=4*r/math.sqrt(3);\n", - "R1=(a1/2)-r; #radius of largest sphere\n", - "a2=4*r/math.sqrt(2);\n", - "R2=(a2/2)-r; #maximum radius of sphere\n", - "\n", - "#Result\n", - "print \"radius of largest sphere is\",R1\n", - "print \"maximum radius of sphere is\",R2 " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.9, Page number 6.49" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a1= 2.905 Angstrom\n", - "Unit cell volume =a1**3 = 24.521 *10**-30 m**3\n", - "Volume occupied by one atom = 12.26 *10**-30 m**3\n", - "a2= 3.654 Angstorm\n", - "Unit cell volume =a2**3 = 48.8 *10**-30 m**3\n", - "Volume occupied by one atom = 12.2 *10**-30 m**3\n", - "Volume Change in % = 0.493\n", - "Density Change in % = 0.5\n", - "Thus the increase of density or the decrease of volume is about 0.5%\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "r1=1.258 #Atomic radius of BCC\n", - "r2=1.292 #Atomic radius of FCC\n", - "\n", - "#calculations\n", - "a1=(4*r1)/math.sqrt(3) #in BCC\n", - "b1=((a1)**3)*10**-30 #Unit cell volume\n", - "v1=(b1)/2 #Volume occupied by one atom\n", - "a2=2*math.sqrt(2)*r2 #in FCC\n", - "b2=(a2)**3*10**-30 #Unit cell volume\n", - "v2=(b2)/4 #Volume occupied by one atom \n", - "v_c=((v1)-(v2))*100/(v1) #Volume Change in % \n", - "d_c=((v1)-(v2))*100/(v2) #Density Change in %\n", - "\n", - "#Results\n", - "print \"a1=\",round(a1,3),\"Angstrom\" \n", - "print \"Unit cell volume =a1**3 =\",round((b1)/10**-30,3),\"*10**-30 m**3\"\n", - "print \"Volume occupied by one atom =\",round(v1/10**-30,2),\"*10**-30 m**3\"\n", - "print \"a2=\",round(a2,3),\"Angstorm\"\n", - "print \"Unit cell volume =a2**3 =\",round((b2)/10**-30,3),\"*10**-30 m**3\"\n", - "print \"Volume occupied by one atom =\",round(v2/10**-30,2),\"*10**-30 m**3\"\n", - "print \"Volume Change in % =\",round(v_c,3)\n", - "print \"Density Change in % =\",round(d_c,2)\n", - "print \"Thus the increase of density or the decrease of volume is about 0.5%\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.10, Page number 6.50" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 0.563 *10**-9 metre\n", - "spacing between the nearest neighbouring ions = 0.2814 nm\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "n=4 \n", - "M=58.5 #Molecular wt. of NaCl\n", - "N=6.02*10**26 #Avagadro number\n", - "rho=2180 #density\n", - "\n", - "#Calculations\n", - "a=((n*M)/(N*rho))**(1/3) \n", - "s=a/2\n", - "\n", - "#Result\n", - "print \"a=\",round(a/10**-9,3),\"*10**-9 metre\"\n", - "print \"spacing between the nearest neighbouring ions =\",round(s/10**-9,4),\"nm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.11, Page number 6.51" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "lattice constant, a= 0.36 nm\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "n=4 \n", - "A=63.55 #Atomic wt. of NaCl\n", - "N=6.02*10**26 #Avagadro number\n", - "rho=8930 #density\n", - "\n", - "#Calculations\n", - "a=((n*A)/(N*rho))**(1/3) #Lattice Constant\n", - "\n", - "#Result\n", - "print \"lattice constant, a=\",round(a*10**9,2),\"nm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.12, Page number 6.51" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Density of iron = 8805.0 kg/m**-3\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "r=0.123 #Atomic radius\n", - "n=4\n", - "A=55.8 #Atomic wt\n", - "a=2*math.sqrt(2) \n", - "N=6.02*10**26 #Avagadro number\n", - "\n", - "#Calculations\n", - "rho=(n*A)/((a*r*10**-9)**3*N)\n", - "\n", - "#Result\n", - "print \"Density of iron =\",round(rho),\"kg/m**-3\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb b/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb deleted file mode 100755 index 8c0ce9a8..00000000 --- a/sample_notebooks/RohithYeedulapalli/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb +++ /dev/null @@ -1,555 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#Chapter 6:Magnetic Properties and Crystal Structures" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.1, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "temperature rise is 8.43 K\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "El=10**-2*50; #energy loss(J)\n", - "H=El*60; #heat produced(J)\n", - "d=7.7*10**3; #iron rod(kg/m**3)\n", - "s=0.462*10**-3; #specific heat(J/kg K)\n", - "\n", - "#Calculation\n", - "theta=H/(d*s); #temperature rise(K)\n", - "\n", - "#Result\n", - "print \"temperature rise is\",round(theta,2),\"K\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.2, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "magnetic field at the centre is 14.0 weber/m**2\n", - "dipole moment is 9.0 *10**-24 ampere/m**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "e=1.6*10**-19; #charge(coulomb)\n", - "new=6.8*10**15; #frequency(revolutions per second)\n", - "mew0=4*math.pi*10**-7;\n", - "R=5.1*10**-11; #radius(m)\n", - "\n", - "#Calculation\n", - "i=round(e*new,4); #current(ampere)\n", - "B=mew0*i/(2*R); #magnetic field at the centre(weber/m**2)\n", - "A=math.pi*R**2;\n", - "d=i*A; #dipole moment(ampere/m**2)\n", - "\n", - "#Result\n", - "print \"magnetic field at the centre is\",round(B),\"weber/m**2\"\n", - "print \"dipole moment is\",round(d*10**24),\"*10**-24 ampere/m**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.3, Page number 6.46" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "intensity of magnetisation is 5.0 ampere/m\n", - "flux density in material is 1.257 weber/m**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "chi=0.5*10**-5; #magnetic susceptibility\n", - "H=10**6; #field strength(ampere/m)\n", - "mew0=4*math.pi*10**-7;\n", - "\n", - "#Calculation\n", - "I=chi*H; #intensity of magnetisation(ampere/m)\n", - "B=mew0*(I+H); #flux density in material(weber/m**2)\n", - "\n", - "#Result\n", - "print \"intensity of magnetisation is\",I,\"ampere/m\"\n", - "print \"flux density in material is\",round(B,3),\"weber/m**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.4, Page number 6.47" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "number of Bohr magnetons is 2.22 bohr magneon/atom\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "B=9.27*10**-24; #bohr magneton(ampere m**2)\n", - "a=2.86*10**-10; #edge(m)\n", - "Is=1.76*10**6; #saturation value of magnetisation(ampere/m)\n", - "\n", - "#Calculation\n", - "N=2/a**3;\n", - "mew_bar=Is/N; #number of Bohr magnetons(ampere m**2)\n", - "mew_bar=mew_bar/B; #number of Bohr magnetons(bohr magneon/atom)\n", - "\n", - "#Result\n", - "print \"number of Bohr magnetons is\",round(mew_bar,2),\"bohr magneon/atom\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.5, Page number 6.47" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "average magnetic moment is 2.79 *10**-3 bohr magneton/spin\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "mew0=4*math.pi*10**-7;\n", - "H=9.27*10**-24; #bohr magneton(ampere m**2)\n", - "beta=10**6; #field(ampere/m)\n", - "k=1.38*10**-23; #boltzmann constant\n", - "T=303; #temperature(K)\n", - "\n", - "#Calculation\n", - "mm=mew0*H*beta/(k*T); #average magnetic moment(bohr magneton/spin)\n", - "\n", - "#Result\n", - "print \"average magnetic moment is\",round(mm*10**3,2),\"*10**-3 bohr magneton/spin\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.6, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "hysteresis loss per cycle is 188.0 J/m**3\n", - "hysteresis loss per second is 9400.0 watt/m**3\n", - "power loss is 1.23 watt/kg\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "A=94; #area(m**2)\n", - "vy=0.1; #value of length(weber/m**2)\n", - "vx=20; #value of unit length\n", - "n=50; #number of magnetization cycles\n", - "d=7650; #density(kg/m**3)\n", - "\n", - "#Calculation\n", - "h=A*vy*vx; #hysteresis loss per cycle(J/m**3)\n", - "hs=h*n; #hysteresis loss per second(watt/m**3)\n", - "pl=hs/d; #power loss(watt/kg)\n", - "\n", - "#Result\n", - "print \"hysteresis loss per cycle is\",h,\"J/m**3\"\n", - "print \"hysteresis loss per second is\",hs,\"watt/m**3\"\n", - "print \"power loss is\",round(pl,2),\"watt/kg\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.7, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 5.43 Angstorm\n", - "density = 6.88 kg/m**3\n", - "#Answer given in the textbook is wrong\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "d=2.351 #bond lenght\n", - "N=6.02*10**26 #Avagadro number\n", - "n=8 #number of atoms in unit cell\n", - "A=28.09 #Atomin mass of silicon\n", - "m=6.02*10**26 #1mole\n", - "\n", - "#Calculations\n", - "a=(4*d)/math.sqrt(3)\n", - "p=(n*A)/((a*10**-10)*m) #density\n", - "\n", - "#Result\n", - "print \"a=\",round(a,2),\"Angstorm\"\n", - "print \"density =\",round(p*10**16,2),\"kg/m**3\"\n", - "print\"#Answer given in the textbook is wrong\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.8, Page number 6.48" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " radius of largest sphere is 0.154700538379252*r\n", - "maximum radius of sphere is 0.414213562373095*r\n" - ] - } - ], - "source": [ - " import math\n", - "from __future__ import division\n", - "from sympy import Symbol\n", - "\n", - "#Variable declaration\n", - "r=Symbol('r')\n", - "\n", - "#Calculation\n", - "a1=4*r/math.sqrt(3);\n", - "R1=(a1/2)-r; #radius of largest sphere\n", - "a2=4*r/math.sqrt(2);\n", - "R2=(a2/2)-r; #maximum radius of sphere\n", - "\n", - "#Result\n", - "print \"radius of largest sphere is\",R1\n", - "print \"maximum radius of sphere is\",R2 " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.9, Page number 6.49" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a1= 2.905 Angstrom\n", - "Unit cell volume =a1**3 = 24.521 *10**-30 m**3\n", - "Volume occupied by one atom = 12.26 *10**-30 m**3\n", - "a2= 3.654 Angstorm\n", - "Unit cell volume =a2**3 = 48.8 *10**-30 m**3\n", - "Volume occupied by one atom = 12.2 *10**-30 m**3\n", - "Volume Change in % = 0.493\n", - "Density Change in % = 0.5\n", - "Thus the increase of density or the decrease of volume is about 0.5%\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "r1=1.258 #Atomic radius of BCC\n", - "r2=1.292 #Atomic radius of FCC\n", - "\n", - "#calculations\n", - "a1=(4*r1)/math.sqrt(3) #in BCC\n", - "b1=((a1)**3)*10**-30 #Unit cell volume\n", - "v1=(b1)/2 #Volume occupied by one atom\n", - "a2=2*math.sqrt(2)*r2 #in FCC\n", - "b2=(a2)**3*10**-30 #Unit cell volume\n", - "v2=(b2)/4 #Volume occupied by one atom \n", - "v_c=((v1)-(v2))*100/(v1) #Volume Change in % \n", - "d_c=((v1)-(v2))*100/(v2) #Density Change in %\n", - "\n", - "#Results\n", - "print \"a1=\",round(a1,3),\"Angstrom\" \n", - "print \"Unit cell volume =a1**3 =\",round((b1)/10**-30,3),\"*10**-30 m**3\"\n", - "print \"Volume occupied by one atom =\",round(v1/10**-30,2),\"*10**-30 m**3\"\n", - "print \"a2=\",round(a2,3),\"Angstorm\"\n", - "print \"Unit cell volume =a2**3 =\",round((b2)/10**-30,3),\"*10**-30 m**3\"\n", - "print \"Volume occupied by one atom =\",round(v2/10**-30,2),\"*10**-30 m**3\"\n", - "print \"Volume Change in % =\",round(v_c,3)\n", - "print \"Density Change in % =\",round(d_c,2)\n", - "print \"Thus the increase of density or the decrease of volume is about 0.5%\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.10, Page number 6.50" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a= 0.563 *10**-9 metre\n", - "spacing between the nearest neighbouring ions = 0.2814 nm\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "n=4 \n", - "M=58.5 #Molecular wt. of NaCl\n", - "N=6.02*10**26 #Avagadro number\n", - "rho=2180 #density\n", - "\n", - "#Calculations\n", - "a=((n*M)/(N*rho))**(1/3) \n", - "s=a/2\n", - "\n", - "#Result\n", - "print \"a=\",round(a/10**-9,3),\"*10**-9 metre\"\n", - "print \"spacing between the nearest neighbouring ions =\",round(s/10**-9,4),\"nm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.11, Page number 6.51" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "lattice constant, a= 0.36 nm\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "n=4 \n", - "A=63.55 #Atomic wt. of NaCl\n", - "N=6.02*10**26 #Avagadro number\n", - "rho=8930 #density\n", - "\n", - "#Calculations\n", - "a=((n*A)/(N*rho))**(1/3) #Lattice Constant\n", - "\n", - "#Result\n", - "print \"lattice constant, a=\",round(a*10**9,2),\"nm\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 6.12, Page number 6.51" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Density of iron = 8805.0 kg/m**-3\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "r=0.123 #Atomic radius\n", - "n=4\n", - "A=55.8 #Atomic wt\n", - "a=2*math.sqrt(2) \n", - "N=6.02*10**26 #Avagadro number\n", - "\n", - "#Calculations\n", - "rho=(n*A)/((a*r*10**-9)**3*N)\n", - "\n", - "#Result\n", - "print \"Density of iron =\",round(rho),\"kg/m**-3\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RohithYeedulapalli/Chapter_7.ipynb b/sample_notebooks/RohithYeedulapalli/Chapter_7.ipynb deleted file mode 100755 index c41c4cd6..00000000 --- a/sample_notebooks/RohithYeedulapalli/Chapter_7.ipynb +++ /dev/null @@ -1,232 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 7:LASERS " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.1, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Divergence = 0.5 *10**-3 radian\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "r1 = 2; #in radians\n", - "r2 = 3; #in radians\n", - "d1 = 4; #Converting from mm to radians\n", - "d2 = 6; #Converting from mm to radians\n", - "\n", - "#calculations\n", - "D = (r2-r1)/(d2*10**3-d1*10**3)\n", - "\n", - "#Result\n", - "print \"Divergence =\",round(D*10**3,3),\"*10**-3 radian\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.2, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Frequency (V) = 4.32 *10**14 Hz\n", - "Relative Population= 1.081 *10**30\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "from sympy import *\n", - "#variable declaration\n", - "C=3*10**8 #The speed of light\n", - "L=6943 #Wavelength\n", - "T=300 #Temperature in Kelvin\n", - "h=6.626*10**-34 #Planck constant \n", - "k=1.38*10**-23 #Boltzmann's constant\n", - "\n", - "#Calculations\n", - "\n", - "V=(C)/(L*10**-10)\n", - "R=math.exp(h*V/(k*T))\n", - "\n", - "#Result\n", - "print \"Frequency (V) =\",round(V/10**14,2),\"*10**14 Hz\"\n", - "print \"Relative Population=\",round(R/10**30,3),\"*10**30\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.3, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Frequency= 4.74 *10**14 Hz\n", - "no.of photons emitted= 7.322 *10**15 photons/sec\n", - "Power density = 2.3 kWm**-2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "C=3*10**8 #Velocity of light\n", - "W=632.8*10**-9 #wavelength\n", - "P=2.3\n", - "t=1\n", - "h=6.626*10**-34 #Planck constant \n", - "S=1*10**-6\n", - "\n", - "#Calculations\n", - "V=C/W #Frequency\n", - "n=((P*10**-3)*t)/(h*V) #no.of photons emitted\n", - "PD=P*10**-3/S\n", - "\n", - "#Result\n", - "print \"Frequency=\",round(V/10**14,2),\"*10**14 Hz\"\n", - "print \"no.of photons emitted=\",round(n/10**15,3),\"*10**15 photons/sec\"\n", - "print \"Power density =\",round(PD/1000,1),\"kWm**-2\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.4, Page number 7.33" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wavelenght = 8628.0 Angstrom\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "h=6.626*10**-34 #Planck constant \n", - "C=3*10**8 #Velocity of light\n", - "E_g=1.44 #bandgap \n", - "\n", - "#calculations\n", - "W=(h*C)*10**10/(E_g*1.6*10**-19)\n", - "\n", - "#Result\n", - "print \"Wavelenght =\",round(W),\"Angstrom\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.5, Page number 7.33" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Band gap = 0.8 eV\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "W=1.55 #wavelength\n", - "\n", - "#Calculations\n", - "E_g=(1.24)/W #Bandgap in eV \n", - "\n", - "#Result\n", - "print \"Band gap =\",E_g,\"eV\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RohithYeedulapalli/Chapter_7_1.ipynb b/sample_notebooks/RohithYeedulapalli/Chapter_7_1.ipynb deleted file mode 100755 index 56cbd13b..00000000 --- a/sample_notebooks/RohithYeedulapalli/Chapter_7_1.ipynb +++ /dev/null @@ -1,236 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 7:LASERS " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.1, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Divergence = 0.5 *10**-3 radian\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "r1 = 2; #in radians\n", - "r2 = 3; #in radians\n", - "d1 = 4; #Converting from mm to radians\n", - "d2 = 6; #Converting from mm to radians\n", - "\n", - "#calculations\n", - "D = (r2-r1)/(d2*10**3-d1*10**3) #Divergence\n", - "\n", - "#Result\n", - "print \"Divergence =\",round(D*10**3,3),\"*10**-3 radian\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.2, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Frequency (V) = 4.32 *10**14 Hz\n", - "Relative Population= 1.081 *10**30\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "C=3*10**8 #The speed of light\n", - "Lamda=6943 #Wavelength\n", - "T=300 #Temperature in Kelvin\n", - "h=6.626*10**-34 #Planck constant \n", - "k=1.38*10**-23 #Boltzmann's constant\n", - "\n", - "#Calculations\n", - "\n", - "V=(C)/(Lamda*10**-10) #Frequency\n", - "R=math.exp(h*V/(k*T)) #Relative population\n", - "\n", - "#Result\n", - "print \"Frequency (V) =\",round(V/10**14,2),\"*10**14 Hz\"\n", - "print \"Relative Population=\",round(R/10**30,3),\"*10**30\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.3, Page number 7.32" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Frequency= 4.74 *10**14 Hz\n", - "no.of photons emitted= 7.322 *10**15 photons/sec\n", - "Power density = 2.3 kWm**-2\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "C=3*10**8 #Velocity of light\n", - "W=632.8*10**-9 #wavelength\n", - "P=2.3\n", - "t=1\n", - "h=6.626*10**-34 #Planck constant \n", - "S=1*10**-6\n", - "\n", - "#Calculations\n", - "V=C/W #Frequency\n", - "n=((P*10**-3)*t)/(h*V) #no.of photons emitted\n", - "PD=P*10**-3/S #Power density\n", - "\n", - "#Result\n", - "print \"Frequency=\",round(V/10**14,2),\"*10**14 Hz\"\n", - "print \"no.of photons emitted=\",round(n/10**15,3),\"*10**15 photons/sec\"\n", - "print \"Power density =\",round(PD/1000,1),\"kWm**-2\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.4, Page number 7.33" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wavelenght = 8628.0 Angstrom\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "h=6.626*10**-34 #Planck constant \n", - "C=3*10**8 #Velocity of light\n", - "E_g=1.44 #bandgap \n", - "\n", - "#calculations\n", - "lamda=(h*C)*10**10/(E_g*1.6*10**-19) #Wavelenght\n", - "\n", - "#Result\n", - "print \"Wavelenght =\",round(lamda),\"Angstrom\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example 7.5, Page number 7.33" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Band gap = 0.8 eV\n" - ] - } - ], - "source": [ - "import math\n", - "from __future__ import division\n", - "\n", - "#variable declaration\n", - "W=1.55 #wavelength\n", - "\n", - "#Calculations\n", - "E_g=(1.24)/W #Bandgap in eV \n", - "\n", - "#Result\n", - "print \"Band gap =\",E_g,\"eV\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures.ipynb b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures.ipynb new file mode 100755 index 00000000..43ba034f --- /dev/null +++ b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures.ipynb @@ -0,0 +1,548 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.1, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "temperature rise is 8.43 K\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "El=10**-2*50; #energy loss(J)\n", + "H=El*60; #heat produced(J)\n", + "d=7.7*10**3; #iron rod(kg/m**3)\n", + "s=0.462*10**-3; #specific heat(J/kg K)\n", + "\n", + "#Calculation\n", + "theta=H/(d*s); #temperature rise(K)\n", + "\n", + "#Result\n", + "print \"temperature rise is\",round(theta,2),\"K\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.2, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "magnetic field at the centre is 14.0 weber/m**2\n", + "dipole moment is 9.0 *10**-24 ampere/m**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "e=1.6*10**-19; #charge(coulomb)\n", + "new=6.8*10**15; #frequency(revolutions per second)\n", + "mew0=4*math.pi*10**-7;\n", + "R=5.1*10**-11; #radius(m)\n", + "\n", + "#Calculation\n", + "i=round(e*new,4); #current(ampere)\n", + "B=mew0*i/(2*R); #magnetic field at the centre(weber/m**2)\n", + "A=math.pi*R**2;\n", + "d=i*A; #dipole moment(ampere/m**2)\n", + "\n", + "#Result\n", + "print \"magnetic field at the centre is\",round(B),\"weber/m**2\"\n", + "print \"dipole moment is\",round(d*10**24),\"*10**-24 ampere/m**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.3, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "intensity of magnetisation is 5.0 ampere/m\n", + "flux density in material is 1.257 weber/m**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "chi=0.5*10**-5; #magnetic susceptibility\n", + "H=10**6; #field strength(ampere/m)\n", + "mew0=4*math.pi*10**-7;\n", + "\n", + "#Calculation\n", + "I=chi*H; #intensity of magnetisation(ampere/m)\n", + "B=mew0*(I+H); #flux density in material(weber/m**2)\n", + "\n", + "#Result\n", + "print \"intensity of magnetisation is\",I,\"ampere/m\"\n", + "print \"flux density in material is\",round(B,3),\"weber/m**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.4, Page number 6.47" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "number of Bohr magnetons is 2.22 bohr magneon/atom\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "B=9.27*10**-24; #bohr magneton(ampere m**2)\n", + "a=2.86*10**-10; #edge(m)\n", + "Is=1.76*10**6; #saturation value of magnetisation(ampere/m)\n", + "\n", + "#Calculation\n", + "N=2/a**3;\n", + "mew_bar=Is/N; #number of Bohr magnetons(ampere m**2)\n", + "mew_bar=mew_bar/B; #number of Bohr magnetons(bohr magneon/atom)\n", + "\n", + "#Result\n", + "print \"number of Bohr magnetons is\",round(mew_bar,2),\"bohr magneon/atom\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.5, Page number 6.47" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "average magnetic moment is 2.79 *10**-3 bohr magneton/spin\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "mew0=4*math.pi*10**-7;\n", + "H=9.27*10**-24; #bohr magneton(ampere m**2)\n", + "beta=10**6; #field(ampere/m)\n", + "k=1.38*10**-23; #boltzmann constant\n", + "T=303; #temperature(K)\n", + "\n", + "#Calculation\n", + "mm=mew0*H*beta/(k*T); #average magnetic moment(bohr magneton/spin)\n", + "\n", + "#Result\n", + "print \"average magnetic moment is\",round(mm*10**3,2),\"*10**-3 bohr magneton/spin\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.6, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hysteresis loss per cycle is 188.0 J/m**3\n", + "hysteresis loss per second is 9400.0 watt/m**3\n", + "power loss is 1.23 watt/kg\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "A=94; #area(m**2)\n", + "vy=0.1; #value of length(weber/m**2)\n", + "vx=20; #value of unit length\n", + "n=50; #number of magnetization cycles\n", + "d=7650; #density(kg/m**3)\n", + "\n", + "#Calculation\n", + "h=A*vy*vx; #hysteresis loss per cycle(J/m**3)\n", + "hs=h*n; #hysteresis loss per second(watt/m**3)\n", + "pl=hs/d; #power loss(watt/kg)\n", + "\n", + "#Result\n", + "print \"hysteresis loss per cycle is\",h,\"J/m**3\"\n", + "print \"hysteresis loss per second is\",hs,\"watt/m**3\"\n", + "print \"power loss is\",round(pl,2),\"watt/kg\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.7, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 5.43 Angstorm\n", + "density = 6.88 kg/m**3\n", + "#Answer given in the textbook is wrong\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "d=2.351 #bond lenght\n", + "N=6.02*10**26 #Avagadro number\n", + "n=8 #number of atoms in unit cell\n", + "A=28.09 #Atomin mass of silicon\n", + "m=6.02*10**26 #1mole\n", + "\n", + "#Calculations\n", + "a=(4*d)/math.sqrt(3)\n", + "p=(n*A)/((a*10**-10)*m) #density\n", + "\n", + "#Result\n", + "print \"a=\",round(a,2),\"Angstorm\"\n", + "print \"density =\",round(p*10**16,2),\"kg/m**3\"\n", + "print\"#Answer given in the textbook is wrong\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.8, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " radius of largest sphere is 0.154700538379252*r\n", + "maximum radius of sphere is 0.414213562373095*r\n" + ] + } + ], + "source": [ + " import math\n", + "from __future__ import division\n", + "from sympy import Symbol\n", + "\n", + "#Variable declaration\n", + "r=Symbol('r')\n", + "\n", + "#Calculation\n", + "a1=4*r/math.sqrt(3);\n", + "R1=(a1/2)-r; #radius of largest sphere\n", + "a2=4*r/math.sqrt(2);\n", + "R2=(a2/2)-r; #maximum radius of sphere\n", + "\n", + "#Result\n", + "print \"radius of largest sphere is\",R1\n", + "print \"maximum radius of sphere is\",R2 " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.9, Page number 6.49" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a1= 2.905 Angstrom\n", + "Unit cell volume =a1**3 = 24.521 *10**-30 m**3\n", + "Volume occupied by one atom = 12.26 *10**-30 m**3\n", + "a2= 3.654 Angstorm\n", + "Unit cell volume =a2**3 = 48.8 *10**-30 m**3\n", + "Volume occupied by one atom = 12.2 *10**-30 m**3\n", + "Volume Change in % = 0.493\n", + "Density Change in % = 0.5\n", + "Thus the increase of density or the decrease of volume is about 0.5%\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "r1=1.258 #Atomic radius of BCC\n", + "r2=1.292 #Atomic radius of FCC\n", + "\n", + "#calculations\n", + "a1=(4*r1)/math.sqrt(3) #in BCC\n", + "b1=((a1)**3)*10**-30 #Unit cell volume\n", + "v1=(b1)/2 #Volume occupied by one atom\n", + "a2=2*math.sqrt(2)*r2 #in FCC\n", + "b2=(a2)**3*10**-30 #Unit cell volume\n", + "v2=(b2)/4 #Volume occupied by one atom \n", + "v_c=((v1)-(v2))*100/(v1) #Volume Change in % \n", + "d_c=((v1)-(v2))*100/(v2) #Density Change in %\n", + "\n", + "#Results\n", + "print \"a1=\",round(a1,3),\"Angstrom\" \n", + "print \"Unit cell volume =a1**3 =\",round((b1)/10**-30,3),\"*10**-30 m**3\"\n", + "print \"Volume occupied by one atom =\",round(v1/10**-30,2),\"*10**-30 m**3\"\n", + "print \"a2=\",round(a2,3),\"Angstorm\"\n", + "print \"Unit cell volume =a2**3 =\",round((b2)/10**-30,3),\"*10**-30 m**3\"\n", + "print \"Volume occupied by one atom =\",round(v2/10**-30,2),\"*10**-30 m**3\"\n", + "print \"Volume Change in % =\",round(v_c,3)\n", + "print \"Density Change in % =\",round(d_c,2)\n", + "print \"Thus the increase of density or the decrease of volume is about 0.5%\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.10, Page number 6.50" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 0.563 *10**-9 metre\n", + "spacing between the nearest neighbouring ions = 0.2814 nm\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "n=4 \n", + "M=58.5 #Molecular wt. of NaCl\n", + "N=6.02*10**26 #Avagadro number\n", + "rho=2180 #density\n", + "\n", + "#Calculations\n", + "a=((n*M)/(N*rho))**(1/3) \n", + "s=a/2\n", + "\n", + "#Result\n", + "print \"a=\",round(a/10**-9,3),\"*10**-9 metre\"\n", + "print \"spacing between the nearest neighbouring ions =\",round(s/10**-9,4),\"nm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.11, Page number 6.51" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "lattice constant, a= 0.36 nm\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "n=4 \n", + "A=63.55 #Atomic wt. of NaCl\n", + "N=6.02*10**26 #Avagadro number\n", + "rho=8930 #density\n", + "\n", + "#Calculations\n", + "a=((n*A)/(N*rho))**(1/3) #Lattice Constant\n", + "\n", + "#Result\n", + "print \"lattice constant, a=\",round(a*10**9,2),\"nm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.12, Page number 6.51" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Density of iron = 8805.0 kg/m**-3\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "r=0.123 #Atomic radius\n", + "n=4\n", + "A=55.8 #Atomic wt\n", + "a=2*math.sqrt(2) \n", + "N=6.02*10**26 #Avagadro number\n", + "\n", + "#Calculations\n", + "rho=(n*A)/((a*r*10**-9)**3*N)\n", + "\n", + "#Result\n", + "print \"Density of iron =\",round(rho),\"kg/m**-3\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb new file mode 100755 index 00000000..8c0ce9a8 --- /dev/null +++ b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/6.Magnetic_Properties_and_Crystal_Structures_1.ipynb @@ -0,0 +1,555 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter 6:Magnetic Properties and Crystal Structures" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.1, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "temperature rise is 8.43 K\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "El=10**-2*50; #energy loss(J)\n", + "H=El*60; #heat produced(J)\n", + "d=7.7*10**3; #iron rod(kg/m**3)\n", + "s=0.462*10**-3; #specific heat(J/kg K)\n", + "\n", + "#Calculation\n", + "theta=H/(d*s); #temperature rise(K)\n", + "\n", + "#Result\n", + "print \"temperature rise is\",round(theta,2),\"K\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.2, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "magnetic field at the centre is 14.0 weber/m**2\n", + "dipole moment is 9.0 *10**-24 ampere/m**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "e=1.6*10**-19; #charge(coulomb)\n", + "new=6.8*10**15; #frequency(revolutions per second)\n", + "mew0=4*math.pi*10**-7;\n", + "R=5.1*10**-11; #radius(m)\n", + "\n", + "#Calculation\n", + "i=round(e*new,4); #current(ampere)\n", + "B=mew0*i/(2*R); #magnetic field at the centre(weber/m**2)\n", + "A=math.pi*R**2;\n", + "d=i*A; #dipole moment(ampere/m**2)\n", + "\n", + "#Result\n", + "print \"magnetic field at the centre is\",round(B),\"weber/m**2\"\n", + "print \"dipole moment is\",round(d*10**24),\"*10**-24 ampere/m**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.3, Page number 6.46" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "intensity of magnetisation is 5.0 ampere/m\n", + "flux density in material is 1.257 weber/m**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "chi=0.5*10**-5; #magnetic susceptibility\n", + "H=10**6; #field strength(ampere/m)\n", + "mew0=4*math.pi*10**-7;\n", + "\n", + "#Calculation\n", + "I=chi*H; #intensity of magnetisation(ampere/m)\n", + "B=mew0*(I+H); #flux density in material(weber/m**2)\n", + "\n", + "#Result\n", + "print \"intensity of magnetisation is\",I,\"ampere/m\"\n", + "print \"flux density in material is\",round(B,3),\"weber/m**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.4, Page number 6.47" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "number of Bohr magnetons is 2.22 bohr magneon/atom\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "B=9.27*10**-24; #bohr magneton(ampere m**2)\n", + "a=2.86*10**-10; #edge(m)\n", + "Is=1.76*10**6; #saturation value of magnetisation(ampere/m)\n", + "\n", + "#Calculation\n", + "N=2/a**3;\n", + "mew_bar=Is/N; #number of Bohr magnetons(ampere m**2)\n", + "mew_bar=mew_bar/B; #number of Bohr magnetons(bohr magneon/atom)\n", + "\n", + "#Result\n", + "print \"number of Bohr magnetons is\",round(mew_bar,2),\"bohr magneon/atom\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.5, Page number 6.47" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "average magnetic moment is 2.79 *10**-3 bohr magneton/spin\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "mew0=4*math.pi*10**-7;\n", + "H=9.27*10**-24; #bohr magneton(ampere m**2)\n", + "beta=10**6; #field(ampere/m)\n", + "k=1.38*10**-23; #boltzmann constant\n", + "T=303; #temperature(K)\n", + "\n", + "#Calculation\n", + "mm=mew0*H*beta/(k*T); #average magnetic moment(bohr magneton/spin)\n", + "\n", + "#Result\n", + "print \"average magnetic moment is\",round(mm*10**3,2),\"*10**-3 bohr magneton/spin\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.6, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "hysteresis loss per cycle is 188.0 J/m**3\n", + "hysteresis loss per second is 9400.0 watt/m**3\n", + "power loss is 1.23 watt/kg\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "A=94; #area(m**2)\n", + "vy=0.1; #value of length(weber/m**2)\n", + "vx=20; #value of unit length\n", + "n=50; #number of magnetization cycles\n", + "d=7650; #density(kg/m**3)\n", + "\n", + "#Calculation\n", + "h=A*vy*vx; #hysteresis loss per cycle(J/m**3)\n", + "hs=h*n; #hysteresis loss per second(watt/m**3)\n", + "pl=hs/d; #power loss(watt/kg)\n", + "\n", + "#Result\n", + "print \"hysteresis loss per cycle is\",h,\"J/m**3\"\n", + "print \"hysteresis loss per second is\",hs,\"watt/m**3\"\n", + "print \"power loss is\",round(pl,2),\"watt/kg\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.7, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 5.43 Angstorm\n", + "density = 6.88 kg/m**3\n", + "#Answer given in the textbook is wrong\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "d=2.351 #bond lenght\n", + "N=6.02*10**26 #Avagadro number\n", + "n=8 #number of atoms in unit cell\n", + "A=28.09 #Atomin mass of silicon\n", + "m=6.02*10**26 #1mole\n", + "\n", + "#Calculations\n", + "a=(4*d)/math.sqrt(3)\n", + "p=(n*A)/((a*10**-10)*m) #density\n", + "\n", + "#Result\n", + "print \"a=\",round(a,2),\"Angstorm\"\n", + "print \"density =\",round(p*10**16,2),\"kg/m**3\"\n", + "print\"#Answer given in the textbook is wrong\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.8, Page number 6.48" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " radius of largest sphere is 0.154700538379252*r\n", + "maximum radius of sphere is 0.414213562373095*r\n" + ] + } + ], + "source": [ + " import math\n", + "from __future__ import division\n", + "from sympy import Symbol\n", + "\n", + "#Variable declaration\n", + "r=Symbol('r')\n", + "\n", + "#Calculation\n", + "a1=4*r/math.sqrt(3);\n", + "R1=(a1/2)-r; #radius of largest sphere\n", + "a2=4*r/math.sqrt(2);\n", + "R2=(a2/2)-r; #maximum radius of sphere\n", + "\n", + "#Result\n", + "print \"radius of largest sphere is\",R1\n", + "print \"maximum radius of sphere is\",R2 " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.9, Page number 6.49" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a1= 2.905 Angstrom\n", + "Unit cell volume =a1**3 = 24.521 *10**-30 m**3\n", + "Volume occupied by one atom = 12.26 *10**-30 m**3\n", + "a2= 3.654 Angstorm\n", + "Unit cell volume =a2**3 = 48.8 *10**-30 m**3\n", + "Volume occupied by one atom = 12.2 *10**-30 m**3\n", + "Volume Change in % = 0.493\n", + "Density Change in % = 0.5\n", + "Thus the increase of density or the decrease of volume is about 0.5%\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "r1=1.258 #Atomic radius of BCC\n", + "r2=1.292 #Atomic radius of FCC\n", + "\n", + "#calculations\n", + "a1=(4*r1)/math.sqrt(3) #in BCC\n", + "b1=((a1)**3)*10**-30 #Unit cell volume\n", + "v1=(b1)/2 #Volume occupied by one atom\n", + "a2=2*math.sqrt(2)*r2 #in FCC\n", + "b2=(a2)**3*10**-30 #Unit cell volume\n", + "v2=(b2)/4 #Volume occupied by one atom \n", + "v_c=((v1)-(v2))*100/(v1) #Volume Change in % \n", + "d_c=((v1)-(v2))*100/(v2) #Density Change in %\n", + "\n", + "#Results\n", + "print \"a1=\",round(a1,3),\"Angstrom\" \n", + "print \"Unit cell volume =a1**3 =\",round((b1)/10**-30,3),\"*10**-30 m**3\"\n", + "print \"Volume occupied by one atom =\",round(v1/10**-30,2),\"*10**-30 m**3\"\n", + "print \"a2=\",round(a2,3),\"Angstorm\"\n", + "print \"Unit cell volume =a2**3 =\",round((b2)/10**-30,3),\"*10**-30 m**3\"\n", + "print \"Volume occupied by one atom =\",round(v2/10**-30,2),\"*10**-30 m**3\"\n", + "print \"Volume Change in % =\",round(v_c,3)\n", + "print \"Density Change in % =\",round(d_c,2)\n", + "print \"Thus the increase of density or the decrease of volume is about 0.5%\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.10, Page number 6.50" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a= 0.563 *10**-9 metre\n", + "spacing between the nearest neighbouring ions = 0.2814 nm\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "n=4 \n", + "M=58.5 #Molecular wt. of NaCl\n", + "N=6.02*10**26 #Avagadro number\n", + "rho=2180 #density\n", + "\n", + "#Calculations\n", + "a=((n*M)/(N*rho))**(1/3) \n", + "s=a/2\n", + "\n", + "#Result\n", + "print \"a=\",round(a/10**-9,3),\"*10**-9 metre\"\n", + "print \"spacing between the nearest neighbouring ions =\",round(s/10**-9,4),\"nm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.11, Page number 6.51" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "lattice constant, a= 0.36 nm\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "n=4 \n", + "A=63.55 #Atomic wt. of NaCl\n", + "N=6.02*10**26 #Avagadro number\n", + "rho=8930 #density\n", + "\n", + "#Calculations\n", + "a=((n*A)/(N*rho))**(1/3) #Lattice Constant\n", + "\n", + "#Result\n", + "print \"lattice constant, a=\",round(a*10**9,2),\"nm\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 6.12, Page number 6.51" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Density of iron = 8805.0 kg/m**-3\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "r=0.123 #Atomic radius\n", + "n=4\n", + "A=55.8 #Atomic wt\n", + "a=2*math.sqrt(2) \n", + "N=6.02*10**26 #Avagadro number\n", + "\n", + "#Calculations\n", + "rho=(n*A)/((a*r*10**-9)**3*N)\n", + "\n", + "#Result\n", + "print \"Density of iron =\",round(rho),\"kg/m**-3\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7.ipynb b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7.ipynb new file mode 100755 index 00000000..c41c4cd6 --- /dev/null +++ b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7.ipynb @@ -0,0 +1,232 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7:LASERS " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.1, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Divergence = 0.5 *10**-3 radian\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "r1 = 2; #in radians\n", + "r2 = 3; #in radians\n", + "d1 = 4; #Converting from mm to radians\n", + "d2 = 6; #Converting from mm to radians\n", + "\n", + "#calculations\n", + "D = (r2-r1)/(d2*10**3-d1*10**3)\n", + "\n", + "#Result\n", + "print \"Divergence =\",round(D*10**3,3),\"*10**-3 radian\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.2, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Frequency (V) = 4.32 *10**14 Hz\n", + "Relative Population= 1.081 *10**30\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "from sympy import *\n", + "#variable declaration\n", + "C=3*10**8 #The speed of light\n", + "L=6943 #Wavelength\n", + "T=300 #Temperature in Kelvin\n", + "h=6.626*10**-34 #Planck constant \n", + "k=1.38*10**-23 #Boltzmann's constant\n", + "\n", + "#Calculations\n", + "\n", + "V=(C)/(L*10**-10)\n", + "R=math.exp(h*V/(k*T))\n", + "\n", + "#Result\n", + "print \"Frequency (V) =\",round(V/10**14,2),\"*10**14 Hz\"\n", + "print \"Relative Population=\",round(R/10**30,3),\"*10**30\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.3, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Frequency= 4.74 *10**14 Hz\n", + "no.of photons emitted= 7.322 *10**15 photons/sec\n", + "Power density = 2.3 kWm**-2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "C=3*10**8 #Velocity of light\n", + "W=632.8*10**-9 #wavelength\n", + "P=2.3\n", + "t=1\n", + "h=6.626*10**-34 #Planck constant \n", + "S=1*10**-6\n", + "\n", + "#Calculations\n", + "V=C/W #Frequency\n", + "n=((P*10**-3)*t)/(h*V) #no.of photons emitted\n", + "PD=P*10**-3/S\n", + "\n", + "#Result\n", + "print \"Frequency=\",round(V/10**14,2),\"*10**14 Hz\"\n", + "print \"no.of photons emitted=\",round(n/10**15,3),\"*10**15 photons/sec\"\n", + "print \"Power density =\",round(PD/1000,1),\"kWm**-2\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.4, Page number 7.33" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wavelenght = 8628.0 Angstrom\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "h=6.626*10**-34 #Planck constant \n", + "C=3*10**8 #Velocity of light\n", + "E_g=1.44 #bandgap \n", + "\n", + "#calculations\n", + "W=(h*C)*10**10/(E_g*1.6*10**-19)\n", + "\n", + "#Result\n", + "print \"Wavelenght =\",round(W),\"Angstrom\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.5, Page number 7.33" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Band gap = 0.8 eV\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "W=1.55 #wavelength\n", + "\n", + "#Calculations\n", + "E_g=(1.24)/W #Bandgap in eV \n", + "\n", + "#Result\n", + "print \"Band gap =\",E_g,\"eV\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7_1.ipynb b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7_1.ipynb new file mode 100755 index 00000000..56cbd13b --- /dev/null +++ b/sample_notebooks/RohithYeedulapalli/RohithYeedulapalli_version_backup/Chapter_7_1.ipynb @@ -0,0 +1,236 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7:LASERS " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.1, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Divergence = 0.5 *10**-3 radian\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "r1 = 2; #in radians\n", + "r2 = 3; #in radians\n", + "d1 = 4; #Converting from mm to radians\n", + "d2 = 6; #Converting from mm to radians\n", + "\n", + "#calculations\n", + "D = (r2-r1)/(d2*10**3-d1*10**3) #Divergence\n", + "\n", + "#Result\n", + "print \"Divergence =\",round(D*10**3,3),\"*10**-3 radian\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.2, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Frequency (V) = 4.32 *10**14 Hz\n", + "Relative Population= 1.081 *10**30\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "C=3*10**8 #The speed of light\n", + "Lamda=6943 #Wavelength\n", + "T=300 #Temperature in Kelvin\n", + "h=6.626*10**-34 #Planck constant \n", + "k=1.38*10**-23 #Boltzmann's constant\n", + "\n", + "#Calculations\n", + "\n", + "V=(C)/(Lamda*10**-10) #Frequency\n", + "R=math.exp(h*V/(k*T)) #Relative population\n", + "\n", + "#Result\n", + "print \"Frequency (V) =\",round(V/10**14,2),\"*10**14 Hz\"\n", + "print \"Relative Population=\",round(R/10**30,3),\"*10**30\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.3, Page number 7.32" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Frequency= 4.74 *10**14 Hz\n", + "no.of photons emitted= 7.322 *10**15 photons/sec\n", + "Power density = 2.3 kWm**-2\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "C=3*10**8 #Velocity of light\n", + "W=632.8*10**-9 #wavelength\n", + "P=2.3\n", + "t=1\n", + "h=6.626*10**-34 #Planck constant \n", + "S=1*10**-6\n", + "\n", + "#Calculations\n", + "V=C/W #Frequency\n", + "n=((P*10**-3)*t)/(h*V) #no.of photons emitted\n", + "PD=P*10**-3/S #Power density\n", + "\n", + "#Result\n", + "print \"Frequency=\",round(V/10**14,2),\"*10**14 Hz\"\n", + "print \"no.of photons emitted=\",round(n/10**15,3),\"*10**15 photons/sec\"\n", + "print \"Power density =\",round(PD/1000,1),\"kWm**-2\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.4, Page number 7.33" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wavelenght = 8628.0 Angstrom\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "h=6.626*10**-34 #Planck constant \n", + "C=3*10**8 #Velocity of light\n", + "E_g=1.44 #bandgap \n", + "\n", + "#calculations\n", + "lamda=(h*C)*10**10/(E_g*1.6*10**-19) #Wavelenght\n", + "\n", + "#Result\n", + "print \"Wavelenght =\",round(lamda),\"Angstrom\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example 7.5, Page number 7.33" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Band gap = 0.8 eV\n" + ] + } + ], + "source": [ + "import math\n", + "from __future__ import division\n", + "\n", + "#variable declaration\n", + "W=1.55 #wavelength\n", + "\n", + "#Calculations\n", + "E_g=(1.24)/W #Bandgap in eV \n", + "\n", + "#Result\n", + "print \"Band gap =\",E_g,\"eV\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chap1.ipynb b/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chap1.ipynb new file mode 100755 index 00000000..c87721c5 --- /dev/null +++ b/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chap1.ipynb @@ -0,0 +1,412 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:0634d7bf5367e0141c25c22bd055ab7dd0d67262eacfb1ab474c7c9ba196985e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 Qualities of measurments" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 Page no 3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "V=80.0 #expected value of voltage in Volts\n", + "V1=79 #Volts\n", + "\n", + "#Calculation\n", + "E=V-V1\n", + "E1=((V-V1)/V)*100\n", + "E2=1-((V-V1)/V)\n", + "A=100*E2\n", + "#Result\n", + "print\"(i) Absolute error is \",E,\"V\"\n", + "print\"(ii) percent error is \", E1,\"%\"\n", + "print\"(iii) reletive error is \", E2\n", + "print\"(iv) percent of accuracy is \", A,\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Absolute error is 1.0 V\n", + "(ii) percent error is 1.25 %\n", + "(iii) reletive error is 0.9875\n", + "(iv) percent of accuracy is 98.75 %\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2 Page no 4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "x1=98\n", + "x2=101\n", + "x3=102\n", + "x4=97\n", + "x5=101\n", + "x6=100\n", + "x7=103\n", + "x8=98\n", + "x9=106\n", + "x10=99\n", + "\n", + "#Calculation\n", + "X=(x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)/10.0\n", + "P=(x6/X)\n", + "\n", + "#Result\n", + "print\"Precision of the 6th measurment is \",round(P,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Precision of the 6th measurment is 0.995\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3(a) Page no 7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "V=80 #milliammeter readings\n", + "I=10.0 #mA\n", + "V1=150 #Volts\n", + "R1=1000 #ohm/volt\n", + "\n", + "#Calculation\n", + "R=V/I\n", + "Rv=R1*V1\n", + "Rx=(R*V1)/(V1-R)\n", + "E=((Rx-R)/Rx)*100\n", + "\n", + "#Result\n", + "print\"(i) Apparent resistance of the unknown resistance \",R,\"K ohm\"\n", + "print \"Actual resistance of the unknown resistance is \",round(Rx,2),\"K ohm\"\n", + "print \"Error due to the loading effet of the voltmeter \",round(E,1),\"%\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Apparent resistance of the unknown resistance 8.0 K ohm\n", + "Actual resistance of the unknown resistance is 8.45 K ohm\n", + "Error due to the loading effet of the voltmeter 5.3 %\n" + ] + } + ], + "prompt_number": 104 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3(b) Page no 7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "V=30 #Volts\n", + "V1=150 #Volts\n", + "I=0.6 #A\n", + "R1=1000 #ohm/volts\n", + "\n", + "#Calculation\n", + "R=V/I\n", + "Rv=(R1*V1)\n", + "Rx=(R*Rv)/(Rv-R)\n", + "E=((Rx-R)/Rx)*100\n", + "\n", + "#Result\n", + "print\"(i) total circuit resistance is \", R,\"ohm\"\n", + "print \"(ii) The voltmeter resistance is \",round(Rx,2)\n", + "print\"(iii) Error due to loading effect of voltmeter \", round(E,3),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) total circuit resistance is 50.0 ohm\n", + "(ii) The voltmeter resistance is 50.02\n", + "(iii) Error due to loading effect of voltmeter 0.033 %\n" + ] + } + ], + "prompt_number": 113 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "x1=49.7\n", + "x2=50.1\n", + "x3=50.2\n", + "x4=49.6\n", + "x5=49.7\n", + "\n", + "#Calculation\n", + "X=(x1+x2+x3+x4+x5)/5.0\n", + "d1=x1-X\n", + "d2=x2-X\n", + "d3=x3-X\n", + "d4=x4-X\n", + "d5=x5-X\n", + "dtotal=(d1+d2+d3+d4+d5)\n", + "\n", + "#Result\n", + "print\"(i) Arithmetic mean is \", X\n", + "print\"(ii) derivations from each value are\"\n", + "print \"d1=\",d1,\"\\nd2=\",d2,\"\\nd3=\",d3,\"\\nd4=\",d4,\"\\nd5=\",d5\n", + "print\"(iii) The algebric sum of derivative is \",round(dtotal,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) Arithmetic mean is 49.86\n", + "(ii) derivations from each value are\n", + "d1= -0.16 \n", + "d2= 0.24 \n", + "d3= 0.34 \n", + "d4= -0.26 \n", + "d5= -0.16\n", + "(iii) The algebric sum of derivative is 0.0\n" + ] + } + ], + "prompt_number": 77 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "x1=49.7\n", + "x2=50.1\n", + "x3=50.2\n", + "x4=49.6\n", + "x5=49.7\n", + "\n", + "#Calculation\n", + "X=(x1+x2+x3+x4+x5)/5.0\n", + "d1=x1-X\n", + "d2=x2-X\n", + "d3=x3-X\n", + "d4=x4-X\n", + "d5=x5-X\n", + "dtotal=(d1+d2+d3+d4+d5)/5.0\n", + "\n", + "#Result\n", + "print\"The average deviation is \",round(dtotal*10**14,3)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The average deviation is 0.284\n" + ] + } + ], + "prompt_number": 86 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "d1= -0.16 \n", + "d2= 0.24 \n", + "d3= 0.34 \n", + "d4= -0.26 \n", + "d5= -0.16\n", + "\n", + "#Calculation\n", + "import math\n", + "D=math.sqrt((d1**2+d2**2+d3**2+d4**2+d5**2)/4.0)\n", + "print\"The standard deviation is \",round(D,2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The standard deviation is 0.27\n" + ] + } + ], + "prompt_number": 90 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "V=600 #Volts\n", + "V1=250.0 #Volts\n", + "a=0.02\n", + "\n", + "#Calculation\n", + "M=a*V\n", + "E=(M/V1)*100\n", + "\n", + "#Result\n", + "print\"The limited error is \", E,\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The limited error is 4.8 %\n" + ] + } + ], + "prompt_number": 94 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "V=70.0 #Volts\n", + "V1=100 #Volts\n", + "I=80.0 #mA\n", + "I1=150 #mA\n", + "a=0.015\n", + "\n", + "#calculation\n", + "M=a*V1\n", + "E=(M/V)*100\n", + "E1=a*I1\n", + "E2=(E1/I)*100\n", + "E3=E+E2\n", + "\n", + "#Result\n", + "print\"limiting error is \",round (E3,3),\"%\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "limiting error is 4.955 %\n" + ] + } + ], + "prompt_number": 102 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chapter1.ipynb b/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chapter1.ipynb new file mode 100755 index 00000000..f6180b5a --- /dev/null +++ b/sample_notebooks/RuchiMittal/RuchiMittal_version_backup/chapter1.ipynb @@ -0,0 +1,543 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:9880f2d8505e271317a099910ead6c2116ce86fa0e83f56feb35ac33a1b96b23" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 Electric charge" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q=4.5*10**-19 #C\n", + "e=1.6*10**-19 #C\n", + "\n", + "#Calculation\n", + "n=q/e\n", + "\n", + "#Result\n", + "print\"n= \",round(n,1),\"This value of charge is not possible\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "n= 2.8 This value of charge is not possible\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q=3.2*10**-7 #C\n", + "e=1.6*10**-19 #C\n", + "\n", + "#Calculation\n", + "n=q/e\n", + "\n", + "#Result\n", + "print\"The required number of electrons is \",n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The required number of electrons is 2e+12\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q=19.2*10**-19\n", + "e=1.6*10**-19\n", + "me=9*10**-31 #Kg\n", + "\n", + "#Calculation\n", + "n=q/e\n", + "M=n*me\n", + "\n", + "#Result\n", + "print\"(i) The value of n=\",n,\"\\n(ii) Charge on silk=\",-q*10**19,\"*10**-19\"\n", + "print\"(iii) Mass=\",M,\"Therefore mass transferred is negligibly small\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(i) The value of n= 12.0 \n", + "(ii) Charge on silk= -19.2 *10**-19\n", + "(iii) Mass= 1.08e-29 Therefore mass transferred is negligibly small\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "a=16\n", + "n=6.023*10**23 #C\n", + "\n", + "#Calculation\n", + "W=2+a\n", + "A=((n*100)/W)*10\n", + "\n", + "#Result\n", + "print\"Total number of electrons in 100 g of water \", round(A,-23)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total number of electrons in 100 g of water 3.35e+25\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "n=10**9\n", + "e=1.6*10**-19 #C\n", + "Q=1\n", + "\n", + "#Calculation\n", + "q=n*e\n", + "t=Q/q\n", + "\n", + "#Result\n", + "print (t*10**-9),\"10**9 S\"\n", + "print\"Time required is about 198 years\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "6.25 10**9 S\n", + "Time required is about 198 years\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 Page no 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "q1=20 #micro C\n", + "q2=-5 #micro C\n", + "a=9*10**9\n", + "r=0.1 \n", + "\n", + "#Calculation\n", + "q=q1+q2\n", + "q3=q/2.0\n", + "F=(a*q3*q3)/r**2\n", + "\n", + "#Result\n", + "print\"Force is \",round(F*10**-13,3),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Force is 5.062 N\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example 1.10 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=9*10**9\n", + "q=5*10**-6\n", + "r=0.1\n", + "\n", + "#Calculation\n", + "import math\n", + "F=(m*q*q)/r**2\n", + "C=2*F*math.cos(30)*(180/3.14)\n", + "\n", + "#Result\n", + "print\"Force on each charge is \", round(C,1)*10**-1,\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Force on each charge is 39.79 N\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.11 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=9*10**9\n", + "q=1\n", + "r=0.24\n", + "A=20\n", + "B=12.0\n", + "m1=10**-4\n", + "g=9.8\n", + "\n", + "#Calculation\n", + "import math\n", + "F=(m*q**2)/r**2\n", + "AD=math.sqrt(A**2-B**2)\n", + "C=AD/B\n", + "F1=(1/C)*m1*g\n", + "Q=math.sqrt(F1/F)\n", + "\n", + "#Result\n", + "print\"Charge on each sphere\", round(Q*10**8,1),\"10**-8\",\"C\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Charge on each sphere 6.9 10**-8 C\n" + ] + } + ], + "prompt_number": 79 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.12 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "F=3.7*10**-9 #C\n", + "q=1.6*10**-19 #c\n", + "m=9*10**9\n", + "r=5*10**-10\n", + "\n", + "#Calculation \n", + "import math\n", + "n=math.sqrt(F*r**2/(m*q**2))\n", + "\n", + "#Result\n", + "print round(n,0),\"electrons are missing from each icon\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "2.0 electrons are missing from each icon\n" + ] + } + ], + "prompt_number": 82 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.14 Page no 16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "e=1.6*10**-19\n", + "m=9*10**9\n", + "G=6.67*10**-11\n", + "me=9.11*10**-31\n", + "mp=1.67*10**-27\n", + "r=10**-10\n", + "\n", + "#Calculation\n", + "F0=(m*e**2)/(G*me*mp)\n", + "F1=(m*e**2)/(G*mp*mp)\n", + "F2=m*e**2/r**2\n", + "A1=F2/me\n", + "A2=F2/mp\n", + "\n", + "#Result\n", + "print\"(a)(i)strength of an electrons and protons\", round(F0*10**-39,1)*10**39\n", + "print\" (ii)Strength of two protons \",round(F1*10**-36,1)*10**36\n", + "print\"(b) Acceleration of electron is \",round(A1*10**-22,1)*10**22,\"m/s**2\"\n", + "print\" Acceleration of proton is \",round(A2*10**-19,1)*10**19,\"m/s*2\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a)(i)strength of an electrons and protons 2.3e+39\n", + " (ii)Strength of two protons 1.2e+36\n", + "(b) Acceleration of electron is 2.5e+22 m/s**2\n", + " Acceleration of proton is 1.4e+19 m/s*2\n" + ] + } + ], + "prompt_number": 112 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.16 Page no 19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=9*10**9 #C\n", + "q1=10*10**-6\n", + "q2=5*10**-6\n", + "r=0.05\n", + "\n", + "#Calculation\n", + "import math\n", + "F1=m*q1*q2/r**2\n", + "F2=m*q1*q2/r**2\n", + "F3=math.sqrt(F1**2+F2**2+(2*F1*F2*math.cos(120)*180/3.14))\n", + "\n", + "#Result\n", + "print\"Resultant charge is \", round(F3*10**-1,0),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant charge is 176.0 N\n" + ] + } + ], + "prompt_number": 132 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.17 Page no 20 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=9*10**9\n", + "q1=1.2*10**-8\n", + "q2=1\n", + "r=0.03\n", + "r1=0.04\n", + "q3=1.6*10**-8\n", + "\n", + "#Calculation\n", + "import math\n", + "F1=m*q1*q2/r**2\n", + "F2=m*q3*q2/r1**2\n", + "F3=math.sqrt(F1**2+F2**2)\n", + "\n", + "#Result\n", + "print\"Total force is \", F3*10**-5,\"10**5\",\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total force is 1.5 10**5 N\n" + ] + } + ], + "prompt_number": 149 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.18 Page no 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "m=9*10**9\n", + "q1=1\n", + "q2=100\n", + "r=10\n", + "q3=75 #C\n", + "r1=5\n", + "\n", + "#Calculation\n", + "import math\n", + "F=m*q1*q2/r**2 #along BA\n", + "F1=m*q1*q2/r**2 #along AC\n", + "F2=m*q3/(math.sqrt(r**2-r1**2)**2)\n", + "F3=math.sqrt(F1**2+F2**2)\n", + "X=F1/F2\n", + "\n", + "#Result\n", + "print\"Force experienced by 1 C Charge is \",round(F3*10**-9,2),\"N\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Force experienced by 1 C Charge is 12.73 N\n" + ] + } + ], + "prompt_number": 168 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/RuchiMittal/chap1.ipynb b/sample_notebooks/RuchiMittal/chap1.ipynb deleted file mode 100755 index c87721c5..00000000 --- a/sample_notebooks/RuchiMittal/chap1.ipynb +++ /dev/null @@ -1,412 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:0634d7bf5367e0141c25c22bd055ab7dd0d67262eacfb1ab474c7c9ba196985e" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 Qualities of measurments" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1 Page no 3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "V=80.0 #expected value of voltage in Volts\n", - "V1=79 #Volts\n", - "\n", - "#Calculation\n", - "E=V-V1\n", - "E1=((V-V1)/V)*100\n", - "E2=1-((V-V1)/V)\n", - "A=100*E2\n", - "#Result\n", - "print\"(i) Absolute error is \",E,\"V\"\n", - "print\"(ii) percent error is \", E1,\"%\"\n", - "print\"(iii) reletive error is \", E2\n", - "print\"(iv) percent of accuracy is \", A,\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Absolute error is 1.0 V\n", - "(ii) percent error is 1.25 %\n", - "(iii) reletive error is 0.9875\n", - "(iv) percent of accuracy is 98.75 %\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2 Page no 4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "x1=98\n", - "x2=101\n", - "x3=102\n", - "x4=97\n", - "x5=101\n", - "x6=100\n", - "x7=103\n", - "x8=98\n", - "x9=106\n", - "x10=99\n", - "\n", - "#Calculation\n", - "X=(x1+x2+x3+x4+x5+x6+x7+x8+x9+x10)/10.0\n", - "P=(x6/X)\n", - "\n", - "#Result\n", - "print\"Precision of the 6th measurment is \",round(P,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Precision of the 6th measurment is 0.995\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3(a) Page no 7" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "V=80 #milliammeter readings\n", - "I=10.0 #mA\n", - "V1=150 #Volts\n", - "R1=1000 #ohm/volt\n", - "\n", - "#Calculation\n", - "R=V/I\n", - "Rv=R1*V1\n", - "Rx=(R*V1)/(V1-R)\n", - "E=((Rx-R)/Rx)*100\n", - "\n", - "#Result\n", - "print\"(i) Apparent resistance of the unknown resistance \",R,\"K ohm\"\n", - "print \"Actual resistance of the unknown resistance is \",round(Rx,2),\"K ohm\"\n", - "print \"Error due to the loading effet of the voltmeter \",round(E,1),\"%\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Apparent resistance of the unknown resistance 8.0 K ohm\n", - "Actual resistance of the unknown resistance is 8.45 K ohm\n", - "Error due to the loading effet of the voltmeter 5.3 %\n" - ] - } - ], - "prompt_number": 104 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3(b) Page no 7" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "V=30 #Volts\n", - "V1=150 #Volts\n", - "I=0.6 #A\n", - "R1=1000 #ohm/volts\n", - "\n", - "#Calculation\n", - "R=V/I\n", - "Rv=(R1*V1)\n", - "Rx=(R*Rv)/(Rv-R)\n", - "E=((Rx-R)/Rx)*100\n", - "\n", - "#Result\n", - "print\"(i) total circuit resistance is \", R,\"ohm\"\n", - "print \"(ii) The voltmeter resistance is \",round(Rx,2)\n", - "print\"(iii) Error due to loading effect of voltmeter \", round(E,3),\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) total circuit resistance is 50.0 ohm\n", - "(ii) The voltmeter resistance is 50.02\n", - "(iii) Error due to loading effect of voltmeter 0.033 %\n" - ] - } - ], - "prompt_number": 113 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "x1=49.7\n", - "x2=50.1\n", - "x3=50.2\n", - "x4=49.6\n", - "x5=49.7\n", - "\n", - "#Calculation\n", - "X=(x1+x2+x3+x4+x5)/5.0\n", - "d1=x1-X\n", - "d2=x2-X\n", - "d3=x3-X\n", - "d4=x4-X\n", - "d5=x5-X\n", - "dtotal=(d1+d2+d3+d4+d5)\n", - "\n", - "#Result\n", - "print\"(i) Arithmetic mean is \", X\n", - "print\"(ii) derivations from each value are\"\n", - "print \"d1=\",d1,\"\\nd2=\",d2,\"\\nd3=\",d3,\"\\nd4=\",d4,\"\\nd5=\",d5\n", - "print\"(iii) The algebric sum of derivative is \",round(dtotal,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) Arithmetic mean is 49.86\n", - "(ii) derivations from each value are\n", - "d1= -0.16 \n", - "d2= 0.24 \n", - "d3= 0.34 \n", - "d4= -0.26 \n", - "d5= -0.16\n", - "(iii) The algebric sum of derivative is 0.0\n" - ] - } - ], - "prompt_number": 77 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "x1=49.7\n", - "x2=50.1\n", - "x3=50.2\n", - "x4=49.6\n", - "x5=49.7\n", - "\n", - "#Calculation\n", - "X=(x1+x2+x3+x4+x5)/5.0\n", - "d1=x1-X\n", - "d2=x2-X\n", - "d3=x3-X\n", - "d4=x4-X\n", - "d5=x5-X\n", - "dtotal=(d1+d2+d3+d4+d5)/5.0\n", - "\n", - "#Result\n", - "print\"The average deviation is \",round(dtotal*10**14,3)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The average deviation is 0.284\n" - ] - } - ], - "prompt_number": 86 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "d1= -0.16 \n", - "d2= 0.24 \n", - "d3= 0.34 \n", - "d4= -0.26 \n", - "d5= -0.16\n", - "\n", - "#Calculation\n", - "import math\n", - "D=math.sqrt((d1**2+d2**2+d3**2+d4**2+d5**2)/4.0)\n", - "print\"The standard deviation is \",round(D,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The standard deviation is 0.27\n" - ] - } - ], - "prompt_number": 90 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "V=600 #Volts\n", - "V1=250.0 #Volts\n", - "a=0.02\n", - "\n", - "#Calculation\n", - "M=a*V\n", - "E=(M/V1)*100\n", - "\n", - "#Result\n", - "print\"The limited error is \", E,\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The limited error is 4.8 %\n" - ] - } - ], - "prompt_number": 94 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "V=70.0 #Volts\n", - "V1=100 #Volts\n", - "I=80.0 #mA\n", - "I1=150 #mA\n", - "a=0.015\n", - "\n", - "#calculation\n", - "M=a*V1\n", - "E=(M/V)*100\n", - "E1=a*I1\n", - "E2=(E1/I)*100\n", - "E3=E+E2\n", - "\n", - "#Result\n", - "print\"limiting error is \",round (E3,3),\"%\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "limiting error is 4.955 %\n" - ] - } - ], - "prompt_number": 102 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/RuchiMittal/chapter1.ipynb b/sample_notebooks/RuchiMittal/chapter1.ipynb deleted file mode 100755 index f6180b5a..00000000 --- a/sample_notebooks/RuchiMittal/chapter1.ipynb +++ /dev/null @@ -1,543 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:9880f2d8505e271317a099910ead6c2116ce86fa0e83f56feb35ac33a1b96b23" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 Electric charge" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q=4.5*10**-19 #C\n", - "e=1.6*10**-19 #C\n", - "\n", - "#Calculation\n", - "n=q/e\n", - "\n", - "#Result\n", - "print\"n= \",round(n,1),\"This value of charge is not possible\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "n= 2.8 This value of charge is not possible\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q=3.2*10**-7 #C\n", - "e=1.6*10**-19 #C\n", - "\n", - "#Calculation\n", - "n=q/e\n", - "\n", - "#Result\n", - "print\"The required number of electrons is \",n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The required number of electrons is 2e+12\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q=19.2*10**-19\n", - "e=1.6*10**-19\n", - "me=9*10**-31 #Kg\n", - "\n", - "#Calculation\n", - "n=q/e\n", - "M=n*me\n", - "\n", - "#Result\n", - "print\"(i) The value of n=\",n,\"\\n(ii) Charge on silk=\",-q*10**19,\"*10**-19\"\n", - "print\"(iii) Mass=\",M,\"Therefore mass transferred is negligibly small\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(i) The value of n= 12.0 \n", - "(ii) Charge on silk= -19.2 *10**-19\n", - "(iii) Mass= 1.08e-29 Therefore mass transferred is negligibly small\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "a=16\n", - "n=6.023*10**23 #C\n", - "\n", - "#Calculation\n", - "W=2+a\n", - "A=((n*100)/W)*10\n", - "\n", - "#Result\n", - "print\"Total number of electrons in 100 g of water \", round(A,-23)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total number of electrons in 100 g of water 3.35e+25\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "n=10**9\n", - "e=1.6*10**-19 #C\n", - "Q=1\n", - "\n", - "#Calculation\n", - "q=n*e\n", - "t=Q/q\n", - "\n", - "#Result\n", - "print (t*10**-9),\"10**9 S\"\n", - "print\"Time required is about 198 years\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "6.25 10**9 S\n", - "Time required is about 198 years\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6 Page no 13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "q1=20 #micro C\n", - "q2=-5 #micro C\n", - "a=9*10**9\n", - "r=0.1 \n", - "\n", - "#Calculation\n", - "q=q1+q2\n", - "q3=q/2.0\n", - "F=(a*q3*q3)/r**2\n", - "\n", - "#Result\n", - "print\"Force is \",round(F*10**-13,3),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Force is 5.062 N\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example 1.10 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=9*10**9\n", - "q=5*10**-6\n", - "r=0.1\n", - "\n", - "#Calculation\n", - "import math\n", - "F=(m*q*q)/r**2\n", - "C=2*F*math.cos(30)*(180/3.14)\n", - "\n", - "#Result\n", - "print\"Force on each charge is \", round(C,1)*10**-1,\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Force on each charge is 39.79 N\n" - ] - } - ], - "prompt_number": 66 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.11 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=9*10**9\n", - "q=1\n", - "r=0.24\n", - "A=20\n", - "B=12.0\n", - "m1=10**-4\n", - "g=9.8\n", - "\n", - "#Calculation\n", - "import math\n", - "F=(m*q**2)/r**2\n", - "AD=math.sqrt(A**2-B**2)\n", - "C=AD/B\n", - "F1=(1/C)*m1*g\n", - "Q=math.sqrt(F1/F)\n", - "\n", - "#Result\n", - "print\"Charge on each sphere\", round(Q*10**8,1),\"10**-8\",\"C\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Charge on each sphere 6.9 10**-8 C\n" - ] - } - ], - "prompt_number": 79 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.12 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "F=3.7*10**-9 #C\n", - "q=1.6*10**-19 #c\n", - "m=9*10**9\n", - "r=5*10**-10\n", - "\n", - "#Calculation \n", - "import math\n", - "n=math.sqrt(F*r**2/(m*q**2))\n", - "\n", - "#Result\n", - "print round(n,0),\"electrons are missing from each icon\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "2.0 electrons are missing from each icon\n" - ] - } - ], - "prompt_number": 82 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.14 Page no 16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "e=1.6*10**-19\n", - "m=9*10**9\n", - "G=6.67*10**-11\n", - "me=9.11*10**-31\n", - "mp=1.67*10**-27\n", - "r=10**-10\n", - "\n", - "#Calculation\n", - "F0=(m*e**2)/(G*me*mp)\n", - "F1=(m*e**2)/(G*mp*mp)\n", - "F2=m*e**2/r**2\n", - "A1=F2/me\n", - "A2=F2/mp\n", - "\n", - "#Result\n", - "print\"(a)(i)strength of an electrons and protons\", round(F0*10**-39,1)*10**39\n", - "print\" (ii)Strength of two protons \",round(F1*10**-36,1)*10**36\n", - "print\"(b) Acceleration of electron is \",round(A1*10**-22,1)*10**22,\"m/s**2\"\n", - "print\" Acceleration of proton is \",round(A2*10**-19,1)*10**19,\"m/s*2\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a)(i)strength of an electrons and protons 2.3e+39\n", - " (ii)Strength of two protons 1.2e+36\n", - "(b) Acceleration of electron is 2.5e+22 m/s**2\n", - " Acceleration of proton is 1.4e+19 m/s*2\n" - ] - } - ], - "prompt_number": 112 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.16 Page no 19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=9*10**9 #C\n", - "q1=10*10**-6\n", - "q2=5*10**-6\n", - "r=0.05\n", - "\n", - "#Calculation\n", - "import math\n", - "F1=m*q1*q2/r**2\n", - "F2=m*q1*q2/r**2\n", - "F3=math.sqrt(F1**2+F2**2+(2*F1*F2*math.cos(120)*180/3.14))\n", - "\n", - "#Result\n", - "print\"Resultant charge is \", round(F3*10**-1,0),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant charge is 176.0 N\n" - ] - } - ], - "prompt_number": 132 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.17 Page no 20 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=9*10**9\n", - "q1=1.2*10**-8\n", - "q2=1\n", - "r=0.03\n", - "r1=0.04\n", - "q3=1.6*10**-8\n", - "\n", - "#Calculation\n", - "import math\n", - "F1=m*q1*q2/r**2\n", - "F2=m*q3*q2/r1**2\n", - "F3=math.sqrt(F1**2+F2**2)\n", - "\n", - "#Result\n", - "print\"Total force is \", F3*10**-5,\"10**5\",\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total force is 1.5 10**5 N\n" - ] - } - ], - "prompt_number": 149 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.18 Page no 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "m=9*10**9\n", - "q1=1\n", - "q2=100\n", - "r=10\n", - "q3=75 #C\n", - "r1=5\n", - "\n", - "#Calculation\n", - "import math\n", - "F=m*q1*q2/r**2 #along BA\n", - "F1=m*q1*q2/r**2 #along AC\n", - "F2=m*q3/(math.sqrt(r**2-r1**2)**2)\n", - "F3=math.sqrt(F1**2+F2**2)\n", - "X=F1/F2\n", - "\n", - "#Result\n", - "print\"Force experienced by 1 C Charge is \",round(F3*10**-9,2),\"N\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Force experienced by 1 C Charge is 12.73 N\n" - ] - } - ], - "prompt_number": 168 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SINDHUARROJU/Chapter10.ipynb b/sample_notebooks/SINDHUARROJU/Chapter10.ipynb deleted file mode 100755 index e1e3146e..00000000 --- a/sample_notebooks/SINDHUARROJU/Chapter10.ipynb +++ /dev/null @@ -1,410 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#10: Dielectric properties" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.1, Page number 10.23" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "energy stored in the condenser is 1.0 J\n", - "energy stored in the dielectric is 0.99 J\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "C=2*10**-6; #capacitance(F)\n", - "V=1000; #voltage(V)\n", - "epsilon_r=100;\n", - "\n", - "#Calculation\n", - "W=C*V**2/2; #energy stored in the condenser(J)\n", - "C0=C/epsilon_r;\n", - "W0=C0*V**2/2;\n", - "E=1-W0; #energy stored in the dielectric(J)\n", - "\n", - "#Result\n", - "print \"energy stored in the condenser is\",W,\"J\"\n", - "print \"energy stored in the dielectric is\",E,\"J\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.2, Page number 10.24" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "ratio betwen electronic and ionic polarizability is 1.738\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "epsilon_r=4.94;\n", - "n2=2.69;\n", - "\n", - "#Calculation\n", - "x=(epsilon_r-1)/(epsilon_r+2);\n", - "y=(n2-1)/(n2+2);\n", - "r=(x/y)-1; #ratio betwen electronic and ionic polarizability\n", - "\n", - "#Result\n", - "print \"ratio betwen electronic and ionic polarizability is\",round(1/r,3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.3, Page number 10.24" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "parallel loss resistance is 10.0 ohm\n", - "answer varies due to rounding off errors\n", - "parallel loss capacitance is 226.56 *10**-12 Farad\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "epsilon_r=2.56;\n", - "epsilon_R=2.65*0.7*10**-4;\n", - "tan_delta=0.7*10**-4; \n", - "A=8*10**-4; #area(m**2)\n", - "d=0.08*10**-3; #diameter(m)\n", - "f=1*10**6; #frequency(Hz)\n", - "epsilon0=8.85*10**-12;\n", - "\n", - "#Calculation\n", - "Rp=d/(2*math.pi*f*epsilon0*epsilon_R*A); #parallel loss resistance(ohm)\n", - "Cp=A*epsilon0*epsilon_r/d; #parallel loss capacitance(Farad)\n", - "\n", - "#Result\n", - "print \"parallel loss resistance is\",round(Rp/10**6),\"ohm\"\n", - "print \"answer varies due to rounding off errors\"\n", - "print \"parallel loss capacitance is\",round(Cp*10**12,2),\"*10**-12 Farad\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.4, Page number 10.25" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dielectric constant of material is 1.339\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "N=3*10**28; #number of atoms(per m**3)\n", - "alphae=10**-40; \n", - "epsilon0=8.854*10**-12;\n", - "\n", - "#Calculation\n", - "epsilon_r=1+(N*alphae/epsilon0); #dielectric constant of material\n", - "\n", - "#Result\n", - "print \"dielectric constant of material is\",round(epsilon_r,3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.5, Page number 10.26" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "electronic polarizability is 2.243 *10**-41 Fm**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "N=2.7*10**25; #number of atoms(per m**3)\n", - "epsilon0=8.854*10**-12;\n", - "epsilon_r=1.0000684;\n", - "\n", - "#Calculation\n", - "alphae=epsilon0*(epsilon_r-1)/N; #electronic polarizability(Fm**2)\n", - "\n", - "#Result\n", - "print \"electronic polarizability is\",round(alphae*10**41,3),\"*10**-41 Fm**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.6, Page number 10.26" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "capacitance is 8.85e-12 F\n", - "charge on plates is 8.85e-10 coulomb\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "epsilon0=8.85*10**-12;\n", - "A=100*10**-4; #area(m**2)\n", - "d=10**-2; #diameter(m)\n", - "V=100; #potential(V)\n", - "\n", - "#Calculation\n", - "C=epsilon0*A/d; #capacitance(F)\n", - "Q=C*V; #charge on plates(coulomb)\n", - "\n", - "#Result\n", - "print \"capacitance is\",C,\"F\"\n", - "print \"charge on plates is\",Q,\"coulomb\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.7, Page number 10.27" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "electronic polarizability is 3.181 *10**-40 Fm**2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "n=6.02*10**26; #avagadro number\n", - "d=2050; #density(kg/m**3)\n", - "w=32; #atomic weight\n", - "gama=1/3; #internal field constant\n", - "epsilon0=8.55*10**-12;\n", - "epsilon_r=3.75;\n", - "\n", - "#Calculation\n", - "N=n*d/w; #number of atoms(per m**3)\n", - "alphae=3*epsilon0*((epsilon_r-1)/(epsilon_r+2))/N; #electronic polarizability(Fm**2)\n", - "\n", - "#Result\n", - "print \"electronic polarizability is\",round(alphae*10**40,3),\"*10**-40 Fm**2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.8, Page number 10.28" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "resultant voltage is 39.73 Volts\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Q=2*10**-10; #charge(C)\n", - "d=4*10**-3; #seperation(m)\n", - "epsilon_r=3.5;\n", - "A=650*10**-6; #area(m**2)\n", - "epsilon0=8.85*10**-12;\n", - "\n", - "#Calculation\n", - "V=Q*d/(epsilon0*epsilon_r*A); #resultant voltage(V)\n", - "\n", - "#Result\n", - "print \"resultant voltage is\",round(V,2),\"Volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.9, Page number 10.28" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dielectric displacement is 265.5 *10**-9 C m**-2\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "d=2*10**-3; #seperation(m)\n", - "epsilon_r=6;\n", - "V=10; #voltage(V)\n", - "epsilon0=8.85*10**-12;\n", - "\n", - "#Calculation\n", - "E=V/d;\n", - "D=epsilon0*epsilon_r*E; #dielectric displacement(C m**-2)\n", - "\n", - "#Result\n", - "print \"dielectric displacement is\",round(D*10**9,1),\"*10**-9 C m**-2\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SINDHUARROJU/SINDHUARROJU_version_backup/Chapter10.ipynb b/sample_notebooks/SINDHUARROJU/SINDHUARROJU_version_backup/Chapter10.ipynb new file mode 100755 index 00000000..e1e3146e --- /dev/null +++ b/sample_notebooks/SINDHUARROJU/SINDHUARROJU_version_backup/Chapter10.ipynb @@ -0,0 +1,410 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#10: Dielectric properties" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.1, Page number 10.23" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "energy stored in the condenser is 1.0 J\n", + "energy stored in the dielectric is 0.99 J\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "C=2*10**-6; #capacitance(F)\n", + "V=1000; #voltage(V)\n", + "epsilon_r=100;\n", + "\n", + "#Calculation\n", + "W=C*V**2/2; #energy stored in the condenser(J)\n", + "C0=C/epsilon_r;\n", + "W0=C0*V**2/2;\n", + "E=1-W0; #energy stored in the dielectric(J)\n", + "\n", + "#Result\n", + "print \"energy stored in the condenser is\",W,\"J\"\n", + "print \"energy stored in the dielectric is\",E,\"J\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.2, Page number 10.24" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "ratio betwen electronic and ionic polarizability is 1.738\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "epsilon_r=4.94;\n", + "n2=2.69;\n", + "\n", + "#Calculation\n", + "x=(epsilon_r-1)/(epsilon_r+2);\n", + "y=(n2-1)/(n2+2);\n", + "r=(x/y)-1; #ratio betwen electronic and ionic polarizability\n", + "\n", + "#Result\n", + "print \"ratio betwen electronic and ionic polarizability is\",round(1/r,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.3, Page number 10.24" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "parallel loss resistance is 10.0 ohm\n", + "answer varies due to rounding off errors\n", + "parallel loss capacitance is 226.56 *10**-12 Farad\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "epsilon_r=2.56;\n", + "epsilon_R=2.65*0.7*10**-4;\n", + "tan_delta=0.7*10**-4; \n", + "A=8*10**-4; #area(m**2)\n", + "d=0.08*10**-3; #diameter(m)\n", + "f=1*10**6; #frequency(Hz)\n", + "epsilon0=8.85*10**-12;\n", + "\n", + "#Calculation\n", + "Rp=d/(2*math.pi*f*epsilon0*epsilon_R*A); #parallel loss resistance(ohm)\n", + "Cp=A*epsilon0*epsilon_r/d; #parallel loss capacitance(Farad)\n", + "\n", + "#Result\n", + "print \"parallel loss resistance is\",round(Rp/10**6),\"ohm\"\n", + "print \"answer varies due to rounding off errors\"\n", + "print \"parallel loss capacitance is\",round(Cp*10**12,2),\"*10**-12 Farad\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.4, Page number 10.25" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dielectric constant of material is 1.339\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "N=3*10**28; #number of atoms(per m**3)\n", + "alphae=10**-40; \n", + "epsilon0=8.854*10**-12;\n", + "\n", + "#Calculation\n", + "epsilon_r=1+(N*alphae/epsilon0); #dielectric constant of material\n", + "\n", + "#Result\n", + "print \"dielectric constant of material is\",round(epsilon_r,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.5, Page number 10.26" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "electronic polarizability is 2.243 *10**-41 Fm**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "N=2.7*10**25; #number of atoms(per m**3)\n", + "epsilon0=8.854*10**-12;\n", + "epsilon_r=1.0000684;\n", + "\n", + "#Calculation\n", + "alphae=epsilon0*(epsilon_r-1)/N; #electronic polarizability(Fm**2)\n", + "\n", + "#Result\n", + "print \"electronic polarizability is\",round(alphae*10**41,3),\"*10**-41 Fm**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.6, Page number 10.26" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "capacitance is 8.85e-12 F\n", + "charge on plates is 8.85e-10 coulomb\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "epsilon0=8.85*10**-12;\n", + "A=100*10**-4; #area(m**2)\n", + "d=10**-2; #diameter(m)\n", + "V=100; #potential(V)\n", + "\n", + "#Calculation\n", + "C=epsilon0*A/d; #capacitance(F)\n", + "Q=C*V; #charge on plates(coulomb)\n", + "\n", + "#Result\n", + "print \"capacitance is\",C,\"F\"\n", + "print \"charge on plates is\",Q,\"coulomb\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.7, Page number 10.27" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "electronic polarizability is 3.181 *10**-40 Fm**2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "n=6.02*10**26; #avagadro number\n", + "d=2050; #density(kg/m**3)\n", + "w=32; #atomic weight\n", + "gama=1/3; #internal field constant\n", + "epsilon0=8.55*10**-12;\n", + "epsilon_r=3.75;\n", + "\n", + "#Calculation\n", + "N=n*d/w; #number of atoms(per m**3)\n", + "alphae=3*epsilon0*((epsilon_r-1)/(epsilon_r+2))/N; #electronic polarizability(Fm**2)\n", + "\n", + "#Result\n", + "print \"electronic polarizability is\",round(alphae*10**40,3),\"*10**-40 Fm**2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.8, Page number 10.28" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "resultant voltage is 39.73 Volts\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Q=2*10**-10; #charge(C)\n", + "d=4*10**-3; #seperation(m)\n", + "epsilon_r=3.5;\n", + "A=650*10**-6; #area(m**2)\n", + "epsilon0=8.85*10**-12;\n", + "\n", + "#Calculation\n", + "V=Q*d/(epsilon0*epsilon_r*A); #resultant voltage(V)\n", + "\n", + "#Result\n", + "print \"resultant voltage is\",round(V,2),\"Volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.9, Page number 10.28" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dielectric displacement is 265.5 *10**-9 C m**-2\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "d=2*10**-3; #seperation(m)\n", + "epsilon_r=6;\n", + "V=10; #voltage(V)\n", + "epsilon0=8.85*10**-12;\n", + "\n", + "#Calculation\n", + "E=V/d;\n", + "D=epsilon0*epsilon_r*E; #dielectric displacement(C m**-2)\n", + "\n", + "#Result\n", + "print \"dielectric displacement is\",round(D*10**9,1),\"*10**-9 C m**-2\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SPANDANAARROJU/Chapter4.ipynb b/sample_notebooks/SPANDANAARROJU/Chapter4.ipynb old mode 100755 new mode 100644 index f4145c55..e9783bbb --- a/sample_notebooks/SPANDANAARROJU/Chapter4.ipynb +++ b/sample_notebooks/SPANDANAARROJU/Chapter4.ipynb @@ -1,553 +1,211 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e9b50f0b4ca0520935774156fedb1fdaaf2b2fd5241b8184a650d42b25d657cd" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "4: Interference" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.1, Page number 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "i=40; #angle of incidence(degrees)\n", - "mew=1.2; #refractive index\n", - "t=0.23; #thickness of the film(micro m)\n", - "\n", - "#Calculation\n", - "i=i*math.pi/180; #angle of incidence(radian)\n", - "r=math.asin(math.sin(i)/mew); #angle of refraction(radian)\n", - "lambda1=(2*mew*t*math.cos(r))*10**3; #wavelength absent(nm) \n", - "lambda2=lambda1/2;\n", - "\n", - "#Result\n", - "print \"The wavelength absent is\",round(lambda1,1),\"nm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The wavelength absent is 466.1 nm\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.2, Page number 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "lambda1=400*10**-9; #wavelength 1(m)\n", - "lambda2=600*10**-9; #wavelength 2(m)\n", - "#2*t=n*lambda\n", - "n=150; \n", - "\n", - "#Calculation \n", - "t=((n*lambda2)/2)*10**6; #thickness of the air film(micro meter)\n", - "\n", - "#Result\n", - "print \"The thickness of the air film is\",t,\"micro m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The thickness of the air film is 45.0 micro m\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.3, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "lamda=600*10**-9; #wavelength(m)\n", - "mew=2;\n", - "theta=0.025; #wedge-angle(degrees)\n", - "\n", - "#Calculation \n", - "theta=theta*math.pi/180; #wedge-angle(radian)\n", - "x=(lamda/(2*mew*math.sin(theta)))*10**2; #bandwidth(cm)\n", - "\n", - "#Result\n", - "print \"The bandwidth is\",round(x,3),\"cm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The bandwidth is 0.034 cm\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.4, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "xair=0.15; #bandwidth of air(cm)\n", - "xliq=0.115; #bandwidth of liquid(cm)\n", - "mewair=1; #refractive index of air\n", - "\n", - "#Calculation \n", - "mewliq=(xair*mewair)/xliq; #refractive index of liquid\n", - "\n", - "#Result\n", - "print \"The refractive index of liquid is\",round(mewliq,1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The refractive index of liquid is 1.3\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.5, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "n=9;\n", - "lamda=589*10**-9; #wavelength of light used(m)\n", - "R=0.95; #radius of curvature of lens(m)\n", - "mew=1;\n", - "\n", - "#Calculation \n", - "D=(math.sqrt((4*n*lamda*R)/mew))*10**2; #diameter of the ninth dark ring(m)\n", - "\n", - "#Result\n", - "print \"The diameter of the ninth dark ring is\",round(D,2),\"cm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The diameter of the ninth dark ring is 0.45 cm\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.6, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "x=0.055; #distance in fringe shift(mm)\n", - "n=200; #number of fringes\n", - "\n", - "#Calculation \n", - "lamda=((2*x)/n)*10**6; #wavelength(nm)\n", - "\n", - "#Result\n", - "print \"The wavelength of light used is\",lamda,\"nm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The wavelength of light used is 550.0 nm\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.7, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "n=50; #number of fringes\n", - "lamda=500*10**-9; #wavelength of light used(m)\n", - "mew=1.5; #refractive index of the plate\n", - "\n", - "#Calculation \n", - "t=((n*lamda)/(2*(mew-1)))*10**6; #thickness of the plate(micro meter)\n", - "\n", - "#Result\n", - "print \"The thickness of the plate is\",t,\"micro m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The thickness of the plate is 25.0 micro m\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.8, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "lamda=550*10**-9; #wavelength(m)\n", - "mew=1.38; #refractive index\n", - "\n", - "#Calculation \n", - "t=(lamda/(4*mew))*10**9; #thickness(nm)\n", - "\n", - "#Result\n", - "print \"The minimum thickness of the plate for normal incidence of light is\",round(t,3),\"nm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The minimum thickness of the plate for normal incidence of light is 99.638 nm\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.9, Page number 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "i=35; #angle of incidence(degrees)\n", - "mew=1.4; #refractive index\n", - "n=50; \n", - "lamda=459*10**-9; #wavelength(m)\n", - "\n", - "#Calculation \n", - "i=i*math.pi/180; #angle of incidence(radian)\n", - "r=math.asin(math.sin(i)/mew); #angle of refraction(radian)\n", - "#2*mew*cos(r)=n*lambda\n", - "#n(459)=(n+1)450\n", - "t=(n*lamda/(2*mew*math.cos(r)))*10**6; #thickness of the film(micro meter)\n", - "\n", - "#Result\n", - "print \"The thickness of the film is\",round(t,3),\"micro m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The thickness of the film is 8.985 micro m\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.10, Page number 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "lamda=500*10**-9; #wavelength(m)\n", - "x=0.07; #observed band width(cm)\n", - "mew=1; #refractive index\n", - "\n", - "#Calculation \n", - "theta=(math.asin(lamda/(2*mew*x)))*10**2; #wedge angle(radian)\n", - "theta=theta*180/math.pi; #wedge angle(degrees)\n", - "\n", - "#Result\n", - "print \"The wedge angle is\",round(theta,2),\"degrees\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The wedge angle is 0.02 degrees\n" - ] - } - ], - "prompt_number": 31 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.11, Page number 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "dair=0.42; #diameter of certain rings(cm)\n", - "dliq=0.38; #diameter of rings when liquid is introduced(cm)\n", - "\n", - "#Calculation \n", - "mew=dair**2/dliq**2; #refractive index of liquid\n", - "\n", - "#Result\n", - "print \"The refravtive index of liquid is\",round(mew,2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The refravtive index of liquid is 1.22\n" - ] - } - ], - "prompt_number": 33 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.12, Page number 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "m=8; #eigth ring\n", - "n=3; #third ring\n", - "dm=0.4; #diameter of the eigth ring(cm)\n", - "dn=0.2; #diameter of the third ring(cm)\n", - "R=101; #Radius of curvature(cm)\n", - "\n", - "#Calculation \n", - "lamda=(((dm**2)-(dn**2))/(4*R*(m-n))); #wavelength of light(cm) \n", - "\n", - "#Result\n", - "print \"The wavelength of light used is\",round(lamda*10**5,4),\"*10**-5 cm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The wavelength of light used is 5.9406 *10**-5 cm\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example number 4.13, Page number 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "mew=1.38; #refractive index of magnesium floride\n", - "t=175; #thickness of coating of magnesium fluoride(nm)\n", - "\n", - "#Calculation \n", - "lamda=4*t*mew; #wavelength(nm)\n", - "\n", - "#Result\n", - "print \"The wavelength which has high transmission is\",lamda,\"nm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The wavelength which has high transmission is 966.0 nm\n" - ] - } - ], - "prompt_number": 41 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# 4: Defects in Crystals" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 1, Page number 4.14" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "equilibrium concentration of vacancy at 300K is 7.577 *10**5\n", + "equilibrium concentration of vacancy at 900K is 6.502 *10**19\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "N=6.023*10**26; #avagadro number\n", + "T1=1/float('inf'); #temperature 0K(K)\n", + "T2=300;\n", + "T3=900; #temperature(K)\n", + "k=1.38*10**-23; #boltzmann constant \n", + "deltaHv=120*10**3*10**3/N; #enthalpy(J/vacancy)\n", + "\n", + "#Calculation\n", + "#n1=N*math.exp(-deltaHv/(k*T1)); #equilibrium concentration of vacancy at 0K\n", + "#value of n1 cant be calculated in python, as the denominator is 0 and it shows float division error\n", + "n2=N*math.exp(-deltaHv/(k*T2)); #equilibrium concentration of vacancy at 300K \n", + "n3=N*math.exp(-deltaHv/(k*T3)); #equilibrium concentration of vacancy at 900K \n", + "\n", + "#Result\n", + "#print \"equilibrium concentration of vacancy at 0K is\",n1\n", + "print \"equilibrium concentration of vacancy at 300K is\",round(n2/10**5,3),\"*10**5\"\n", + "print \"equilibrium concentration of vacancy at 900K is\",round(n3/10**19,3),\"*10**19\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 2, Page number 4.15" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "fraction of vacancies at 1000 is 8.5 *10**-7\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "nbyN1=1*10**-10; #fraction of vacancies\n", + "T1=500+273;\n", + "T2=1000+273;\n", + "\n", + "#Calculation\n", + "lnx=T1*math.log(nbyN1)/T2;\n", + "x=math.exp(lnx); #fraction of vacancies at 1000\n", + "\n", + "#Result\n", + "print \"fraction of vacancies at 1000 is\",round(x*10**7,1),\"*10**-7\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 3, Page number 4.16" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "concentration of schottky defects is 6.42 *10**11 per m**3\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "d=2.82*10**-10; #interionic distance(m)\n", + "T=300; #temperature(K)\n", + "k=1.38*10**-23; #boltzmann constant \n", + "e=1.6*10**-19; #charge(coulomb)\n", + "n=4; #number of molecules\n", + "deltaHs=1.971*e; #enthalpy(J)\n", + "\n", + "#Calculation\n", + "V=(2*d)**3; #volume of unit cell(m**3)\n", + "N=n/V; #number of ion pairs\n", + "x=deltaHs/(2*k*T);\n", + "n=N*math.exp(-x); #concentration of schottky defects(per m**3)\n", + "\n", + "#Result\n", + "print \"concentration of schottky defects is\",round(n*10**-11,2),\"*10**11 per m**3\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example number 4, Page number 4.17" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "concentration of schottky defects is 9.23 *10**12 per cm**3\n", + "amount of climb down by the dislocations is 0.1846 step or 0.3692 *10**-8 cm\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "N=6.026*10**23; #avagadro number \n", + "T=500; #temperature(K)\n", + "k=1.38*10**-23; #boltzmann constant \n", + "deltaHv=1.6*10**-19; #charge(coulomb)\n", + "V=5.55; #molar volume(cm**3)\n", + "nv=5*10**7*10**6; #number of vacancies\n", + "\n", + "#Calculation\n", + "n=N*math.exp(-deltaHv/(k*T))/V; #concentration of schottky defects(per m**3)\n", + "x=round(n/nv,4); #amount of climb down by the dislocations(step)\n", + "xcm=2*x*10**-8; #amount of climb down by the dislocations(cm)\n", + "\n", + "#Result\n", + "print \"concentration of schottky defects is\",round(n/10**12,2),\"*10**12 per cm**3\"\n", + "print \"amount of climb down by the dislocations is\",x,\"step or\",xcm*10**8,\"*10**-8 cm\" " + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SPANDANAARROJU/Chapter4_J3M7PEz.ipynb b/sample_notebooks/SPANDANAARROJU/Chapter4_J3M7PEz.ipynb deleted file mode 100644 index e9783bbb..00000000 --- a/sample_notebooks/SPANDANAARROJU/Chapter4_J3M7PEz.ipynb +++ /dev/null @@ -1,211 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# 4: Defects in Crystals" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 1, Page number 4.14" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "equilibrium concentration of vacancy at 300K is 7.577 *10**5\n", - "equilibrium concentration of vacancy at 900K is 6.502 *10**19\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "N=6.023*10**26; #avagadro number\n", - "T1=1/float('inf'); #temperature 0K(K)\n", - "T2=300;\n", - "T3=900; #temperature(K)\n", - "k=1.38*10**-23; #boltzmann constant \n", - "deltaHv=120*10**3*10**3/N; #enthalpy(J/vacancy)\n", - "\n", - "#Calculation\n", - "#n1=N*math.exp(-deltaHv/(k*T1)); #equilibrium concentration of vacancy at 0K\n", - "#value of n1 cant be calculated in python, as the denominator is 0 and it shows float division error\n", - "n2=N*math.exp(-deltaHv/(k*T2)); #equilibrium concentration of vacancy at 300K \n", - "n3=N*math.exp(-deltaHv/(k*T3)); #equilibrium concentration of vacancy at 900K \n", - "\n", - "#Result\n", - "#print \"equilibrium concentration of vacancy at 0K is\",n1\n", - "print \"equilibrium concentration of vacancy at 300K is\",round(n2/10**5,3),\"*10**5\"\n", - "print \"equilibrium concentration of vacancy at 900K is\",round(n3/10**19,3),\"*10**19\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 2, Page number 4.15" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "fraction of vacancies at 1000 is 8.5 *10**-7\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "nbyN1=1*10**-10; #fraction of vacancies\n", - "T1=500+273;\n", - "T2=1000+273;\n", - "\n", - "#Calculation\n", - "lnx=T1*math.log(nbyN1)/T2;\n", - "x=math.exp(lnx); #fraction of vacancies at 1000\n", - "\n", - "#Result\n", - "print \"fraction of vacancies at 1000 is\",round(x*10**7,1),\"*10**-7\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 3, Page number 4.16" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "concentration of schottky defects is 6.42 *10**11 per m**3\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "d=2.82*10**-10; #interionic distance(m)\n", - "T=300; #temperature(K)\n", - "k=1.38*10**-23; #boltzmann constant \n", - "e=1.6*10**-19; #charge(coulomb)\n", - "n=4; #number of molecules\n", - "deltaHs=1.971*e; #enthalpy(J)\n", - "\n", - "#Calculation\n", - "V=(2*d)**3; #volume of unit cell(m**3)\n", - "N=n/V; #number of ion pairs\n", - "x=deltaHs/(2*k*T);\n", - "n=N*math.exp(-x); #concentration of schottky defects(per m**3)\n", - "\n", - "#Result\n", - "print \"concentration of schottky defects is\",round(n*10**-11,2),\"*10**11 per m**3\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example number 4, Page number 4.17" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "concentration of schottky defects is 9.23 *10**12 per cm**3\n", - "amount of climb down by the dislocations is 0.1846 step or 0.3692 *10**-8 cm\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "N=6.026*10**23; #avagadro number \n", - "T=500; #temperature(K)\n", - "k=1.38*10**-23; #boltzmann constant \n", - "deltaHv=1.6*10**-19; #charge(coulomb)\n", - "V=5.55; #molar volume(cm**3)\n", - "nv=5*10**7*10**6; #number of vacancies\n", - "\n", - "#Calculation\n", - "n=N*math.exp(-deltaHv/(k*T))/V; #concentration of schottky defects(per m**3)\n", - "x=round(n/nv,4); #amount of climb down by the dislocations(step)\n", - "xcm=2*x*10**-8; #amount of climb down by the dislocations(cm)\n", - "\n", - "#Result\n", - "print \"concentration of schottky defects is\",round(n/10**12,2),\"*10**12 per cm**3\"\n", - "print \"amount of climb down by the dislocations is\",x,\"step or\",xcm*10**8,\"*10**-8 cm\" " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Sadananda CharyArroju/Chapter10.ipynb b/sample_notebooks/Sadananda CharyArroju/Chapter10.ipynb deleted file mode 100755 index bd43d700..00000000 --- a/sample_notebooks/Sadananda CharyArroju/Chapter10.ipynb +++ /dev/null @@ -1,431 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#10: Superconductivity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.1, Page number 224" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical field is 3.365 *10**3 A/m\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "T=5; #temperature(K)\n", - "Tc=7.2; #critical temperature(K)\n", - "H0=6.5*10**3; #critical magnetic field(A/m)\n", - "\n", - "#Calculation\n", - "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", - "\n", - "#Result\n", - "print \"critical field is\",round(Hc/10**3,3),\"*10**3 A/m\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.2, Page number 225" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical field is 1.567 *10**3 A/m\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "T=2.5; #temperature(K)\n", - "Tc=3.5; #critical temperature(K)\n", - "H0=3.2*10**3; #critical magnetic field(A/m)\n", - "\n", - "#Calculation\n", - "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", - "\n", - "#Result\n", - "print \"critical field is\",round(Hc/10**3,3),\"*10**3 A/m\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.3, Page number 225" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical temperature is 6.928 K\n", - "answer given in the book is wrong\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Hc=5*10**3; #critical magnetic field(A/m)\n", - "T=6; #temperature(K)\n", - "H0=2*10**4; #critical magnetic field(A/m)\n", - "\n", - "#Calculation\n", - "Tc=T/math.sqrt(1-(Hc/H0)); #critical temperature(K)\n", - "\n", - "#Result\n", - "print \"critical temperature is\",round(Tc,3),\"K\"\n", - "print \"answer given in the book is wrong\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.4, Page number 225" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical current is 251.3 amp\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Hc=2*10**3; #critical magnetic field(A/m)\n", - "r=0.02; #radius(m)\n", - "\n", - "#Calculation\n", - "Ic=2*math.pi*r*Hc; #critical current(amp)\n", - "\n", - "#Result\n", - "print \"critical current is\",round(Ic,1),\"amp\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.5, Page number 225" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "isotopic mass is 191.75 amu\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "T1=5; #temperature(K)\n", - "T2=5.1; #temperature(K)\n", - "M1=199.5; #isotopic mass(amu)\n", - "\n", - "#Calculation\n", - "M2=M1*(T1/T2)**2; #isotopic mass(amu)\n", - "\n", - "#Result\n", - "print \"isotopic mass is\",round(M2,2),\"amu\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.6, Page number 226" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical field is 3.0469 *10**4 A/m\n", - "critical current is 287.161 amp\n", - "answer given in the book is wrong\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "T=5; #temperature(K)\n", - "Tc=8; #critical temperature(K)\n", - "H0=5*10**4; #critical magnetic field(A/m)\n", - "r=1.5*10**-3; #radius(m)\n", - "\n", - "#Calculation\n", - "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", - "Ic=2*math.pi*r*Hc; #critical current(amp)\n", - "\n", - "#Result\n", - "print \"critical field is\",round(Hc/10**4,4),\"*10**4 A/m\"\n", - "print \"critical current is\",round(Ic,3),\"amp\"\n", - "print \"answer given in the book is wrong\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.7, Page number 226" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical temperature is 4.1447 K\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Tc1=4.185; #critical temperature(K)\n", - "M1=199.5; #isotopic mass(amu)\n", - "M2=203.4; #isotopic mass(amu)\n", - "\n", - "#Calculation\n", - "Tc2=Tc1*math.sqrt(M1/M2); #critical temperature(K)\n", - "\n", - "#Result\n", - "print \"critical temperature is\",round(Tc2,4),\"K\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.8, Page number 226" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "frequency is 4.105 *10**11 Hz\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "e=1.6*10**-19; #charge(c)\n", - "h=6.626*10**-36; #plank constant\n", - "V=8.5*10**-6; #voltage(V)\n", - "\n", - "#Calculation\n", - "new=2*e*V/h; #frequency(Hz)\n", - "\n", - "#Result\n", - "print \"frequency is\",round(new/10**11,3),\"*10**11 Hz\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.9, Page number 227" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "critical temperature is 30.0 K\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Tc1=5; #critical temperature(K)\n", - "P1=1; #pressure(mm)\n", - "P2=6; #pressure(mm)\n", - "\n", - "#Calculation\n", - "Tc2=Tc1*P2/P1; #critical temperature(K)\n", - "\n", - "#Result\n", - "print \"critical temperature is\",Tc2,\"K\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example number 10.10, Page number 227" - ] - }, - { - "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "maximum critical temperature is 7.782 K\n", - "answer given in the book is wrong\n" - ] - } - ], - "source": [ - "#importing modules\n", - "import math\n", - "from __future__ import division\n", - "\n", - "#Variable declaration\n", - "Hc=6*10**5; #critical magnetic field(A/m)\n", - "Tc=8.7; #critical temperature(K)\n", - "H0=3*10**6; #critical magnetic field(A/m)\n", - "\n", - "#Calculation\n", - "T=Tc*math.sqrt(1-(Hc/H0)); #maximum critical temperature(K)\n", - "\n", - "#Result\n", - "print \"maximum critical temperature is\",round(T,3),\"K\"\n", - "print \"answer given in the book is wrong\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Sadananda CharyArroju/Sadananda CharyArroju_version_backup/Chapter10.ipynb b/sample_notebooks/Sadananda CharyArroju/Sadananda CharyArroju_version_backup/Chapter10.ipynb new file mode 100755 index 00000000..bd43d700 --- /dev/null +++ b/sample_notebooks/Sadananda CharyArroju/Sadananda CharyArroju_version_backup/Chapter10.ipynb @@ -0,0 +1,431 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#10: Superconductivity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.1, Page number 224" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical field is 3.365 *10**3 A/m\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "T=5; #temperature(K)\n", + "Tc=7.2; #critical temperature(K)\n", + "H0=6.5*10**3; #critical magnetic field(A/m)\n", + "\n", + "#Calculation\n", + "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", + "\n", + "#Result\n", + "print \"critical field is\",round(Hc/10**3,3),\"*10**3 A/m\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.2, Page number 225" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical field is 1.567 *10**3 A/m\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "T=2.5; #temperature(K)\n", + "Tc=3.5; #critical temperature(K)\n", + "H0=3.2*10**3; #critical magnetic field(A/m)\n", + "\n", + "#Calculation\n", + "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", + "\n", + "#Result\n", + "print \"critical field is\",round(Hc/10**3,3),\"*10**3 A/m\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.3, Page number 225" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical temperature is 6.928 K\n", + "answer given in the book is wrong\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Hc=5*10**3; #critical magnetic field(A/m)\n", + "T=6; #temperature(K)\n", + "H0=2*10**4; #critical magnetic field(A/m)\n", + "\n", + "#Calculation\n", + "Tc=T/math.sqrt(1-(Hc/H0)); #critical temperature(K)\n", + "\n", + "#Result\n", + "print \"critical temperature is\",round(Tc,3),\"K\"\n", + "print \"answer given in the book is wrong\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.4, Page number 225" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical current is 251.3 amp\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Hc=2*10**3; #critical magnetic field(A/m)\n", + "r=0.02; #radius(m)\n", + "\n", + "#Calculation\n", + "Ic=2*math.pi*r*Hc; #critical current(amp)\n", + "\n", + "#Result\n", + "print \"critical current is\",round(Ic,1),\"amp\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.5, Page number 225" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "isotopic mass is 191.75 amu\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "T1=5; #temperature(K)\n", + "T2=5.1; #temperature(K)\n", + "M1=199.5; #isotopic mass(amu)\n", + "\n", + "#Calculation\n", + "M2=M1*(T1/T2)**2; #isotopic mass(amu)\n", + "\n", + "#Result\n", + "print \"isotopic mass is\",round(M2,2),\"amu\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.6, Page number 226" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical field is 3.0469 *10**4 A/m\n", + "critical current is 287.161 amp\n", + "answer given in the book is wrong\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "T=5; #temperature(K)\n", + "Tc=8; #critical temperature(K)\n", + "H0=5*10**4; #critical magnetic field(A/m)\n", + "r=1.5*10**-3; #radius(m)\n", + "\n", + "#Calculation\n", + "Hc=H0*(1-(T/Tc)**2); #critical field(A/m)\n", + "Ic=2*math.pi*r*Hc; #critical current(amp)\n", + "\n", + "#Result\n", + "print \"critical field is\",round(Hc/10**4,4),\"*10**4 A/m\"\n", + "print \"critical current is\",round(Ic,3),\"amp\"\n", + "print \"answer given in the book is wrong\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.7, Page number 226" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical temperature is 4.1447 K\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Tc1=4.185; #critical temperature(K)\n", + "M1=199.5; #isotopic mass(amu)\n", + "M2=203.4; #isotopic mass(amu)\n", + "\n", + "#Calculation\n", + "Tc2=Tc1*math.sqrt(M1/M2); #critical temperature(K)\n", + "\n", + "#Result\n", + "print \"critical temperature is\",round(Tc2,4),\"K\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.8, Page number 226" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "frequency is 4.105 *10**11 Hz\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "e=1.6*10**-19; #charge(c)\n", + "h=6.626*10**-36; #plank constant\n", + "V=8.5*10**-6; #voltage(V)\n", + "\n", + "#Calculation\n", + "new=2*e*V/h; #frequency(Hz)\n", + "\n", + "#Result\n", + "print \"frequency is\",round(new/10**11,3),\"*10**11 Hz\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.9, Page number 227" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "critical temperature is 30.0 K\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Tc1=5; #critical temperature(K)\n", + "P1=1; #pressure(mm)\n", + "P2=6; #pressure(mm)\n", + "\n", + "#Calculation\n", + "Tc2=Tc1*P2/P1; #critical temperature(K)\n", + "\n", + "#Result\n", + "print \"critical temperature is\",Tc2,\"K\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example number 10.10, Page number 227" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "maximum critical temperature is 7.782 K\n", + "answer given in the book is wrong\n" + ] + } + ], + "source": [ + "#importing modules\n", + "import math\n", + "from __future__ import division\n", + "\n", + "#Variable declaration\n", + "Hc=6*10**5; #critical magnetic field(A/m)\n", + "Tc=8.7; #critical temperature(K)\n", + "H0=3*10**6; #critical magnetic field(A/m)\n", + "\n", + "#Calculation\n", + "T=Tc*math.sqrt(1-(Hc/H0)); #maximum critical temperature(K)\n", + "\n", + "#Result\n", + "print \"maximum critical temperature is\",round(T,3),\"K\"\n", + "print \"answer given in the book is wrong\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SaiRakesh/SaiRakesh_version_backup/chapter_1.ipynb b/sample_notebooks/SaiRakesh/SaiRakesh_version_backup/chapter_1.ipynb new file mode 100755 index 00000000..9474d100 --- /dev/null +++ b/sample_notebooks/SaiRakesh/SaiRakesh_version_backup/chapter_1.ipynb @@ -0,0 +1,1777 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# chapter 1:Fundemental concepts and definitions" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.1;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1, Page:22 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 1\n", + "pressure difference(p)in pa\n", + "p= 39755.7\n" + ] + } + ], + "source": [ + "#cal of pressure difference\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.1, Page:22 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 1\"\n", + "h=30*10**-2;#manometer deflection of mercury in m\n", + "g=9.78;#acceleration due to gravity in m/s^2\n", + "rho=13550;#density of mercury at room temperature in kg/m^3\n", + "print\"pressure difference(p)in pa\"\n", + "p=rho*g*h\n", + "print\"p=\",round(p,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.2;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.2, Page:22 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 2\n", + "effort required for lifting the lid(E)in N\n", + "E= 7115.48\n" + ] + } + ], + "source": [ + "#cal of effort required for lifting the lid\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.2, Page:22 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 2\"\n", + "d=30*10**-2;#diameter of cylindrical vessel in m\n", + "h=76*10**-2;#atmospheric pressure in m of mercury\n", + "g=9.78;#acceleration due to gravity in m/s^2\n", + "rho=13550;#density of mercury at room temperature in kg/m^3\n", + "print\"effort required for lifting the lid(E)in N\"\n", + "E=(rho*g*h)*(3.14*d**2)/4\n", + "print\"E=\",round(E,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.3;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.3, Page:22 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 3\n", + "pressure measured by manometer is gauge pressure(Pg)in kpa\n", + "Pg=rho*g*h/10^3\n", + "actual pressure of the air(P)in kpa\n", + "P= 140.76\n" + ] + } + ], + "source": [ + "#cal of actual pressure of the air\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.3, Page:22 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 3\"\n", + "h=30*10**-2;# pressure of compressed air in m of mercury\n", + "Patm=101*10**3;#atmospheric pressure in pa\n", + "g=9.78;#acceleration due to gravity in m/s^2\n", + "rho=13550;#density of mercury at room temperature in kg/m^3\n", + "print\"pressure measured by manometer is gauge pressure(Pg)in kpa\"\n", + "print\"Pg=rho*g*h/10^3\"\n", + "Pg=rho*g*h/10**3\n", + "print\"actual pressure of the air(P)in kpa\"\n", + "P=Pg+Patm/10**3\n", + "print\"P=\",round(P,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.4;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.4, Page:22 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 4\n", + "density of oil(RHOoil)in kg/m^3\n", + "RHOoil=sg*RHOw\n", + "gauge pressure(Pg)in kpa\n", + "Pg= 7.848\n" + ] + } + ], + "source": [ + "#cal of gauge pressure\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.4, Page:22 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 4\"\n", + "h=1;#depth of oil tank in m\n", + "sg=0.8;#specific gravity of oil\n", + "RHOw=1000;#density of water in kg/m^3\n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "print\"density of oil(RHOoil)in kg/m^3\"\n", + "print\"RHOoil=sg*RHOw\"\n", + "RHOoil=sg*RHOw\n", + "print\"gauge pressure(Pg)in kpa\"\n", + "Pg=RHOoil*g*h/10**3\n", + "print\"Pg=\",round(Pg,3)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.5;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.5, Page:22 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 5\n", + "atmospheric pressure(Patm)in kpa\n", + "Patm=rho*g*h2/10^3\n", + "pressure due to mercury column at AB(Pab)in kpa\n", + "Pab=rho*g*h1/10^3\n", + "pressure exerted by gas(Pgas)in kpa\n", + "Pgas= 154.76\n" + ] + } + ], + "source": [ + "#cal of pressure exerted by gas\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.5, Page:22 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 5\"\n", + "rho=13.6*10**3;#density of mercury in kg/m^3\n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "h1=40*10**-2;#difference of height in mercury column in m as shown in figure\n", + "h2=76*10**-2;#barometer reading of mercury in m\n", + "print\"atmospheric pressure(Patm)in kpa\"\n", + "print\"Patm=rho*g*h2/10^3\"\n", + "Patm=rho*g*h2/10**3\n", + "print\"pressure due to mercury column at AB(Pab)in kpa\"\n", + "print\"Pab=rho*g*h1/10^3\"\n", + "Pab=rho*g*h1/10**3\n", + "print\"pressure exerted by gas(Pgas)in kpa\"\n", + "Pgas=Patm+Pab\n", + "print\"Pgas=\",round(Pgas,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.6;page no:23" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.6, Page:23 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 6\n", + "by law of conservation of energy\n", + "potential energy(m*g*h)in joule = heat required for heating water(m*Cp*deltaT*1000*4.18)in joule\n", + "so m*g*h = m*Cp*deltaT*4.18*1000\n", + "change in temperature of water(deltaT) in degree celcius\n", + "deltaT= 2.35\n" + ] + } + ], + "source": [ + "#cal of change in temperature of water\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.6, Page:23 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 6\"\n", + "m=1;#mass of water in kg\n", + "h=1000;#height from which water fall in m\n", + "Cp=1;#specific heat of water in kcal/kg k\n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "print\"by law of conservation of energy\"\n", + "print\"potential energy(m*g*h)in joule = heat required for heating water(m*Cp*deltaT*1000*4.18)in joule\"\n", + "print\"so m*g*h = m*Cp*deltaT*4.18*1000\"\n", + "print\"change in temperature of water(deltaT) in degree celcius\"\n", + "deltaT=(g*h)/(4.18*1000*Cp)\n", + "print\"deltaT=\",round(deltaT,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.7;page no:23" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.7, Page:23 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 7\n", + "mass of object(m)in kg\n", + "m=w1/g1\n", + "spring balance reading=gravitational force in mass(F)in N\n", + "F= 86.65\n" + ] + } + ], + "source": [ + "#cal of spring balance reading\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.7, Page:23 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 7\"\n", + "w1=100;#weight of object at standard gravitational acceleration in N\n", + "g1=9.81;#acceleration due to gravity in m/s^2\n", + "g2=8.5;#gravitational acceleration at some location\n", + "print\"mass of object(m)in kg\"\n", + "print\"m=w1/g1\"\n", + "m=w1/g1\n", + "print\"spring balance reading=gravitational force in mass(F)in N\"\n", + "F=m*g2\n", + "print\"F=\",round(F,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.8;page no:24" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.8, Page:24 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 8\n", + "pressure measured by manometer(P) in pa\n", + "p=rho*g*h\n", + "now weight of piston(m*g) = upward thrust by gas(p*math.pi*d^2/4)\n", + "mass of piston(m)in kg\n", + "so m= 28.84\n" + ] + } + ], + "source": [ + "#cal of mass of piston\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "import math\n", + "print\"Example 1.8, Page:24 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 8\"\n", + "d=15*10**-2;#diameter of cylinder in m\n", + "h=12*10**-2;#manometer height difference in m of mercury\n", + "rho=13.6*10**3;#density of mercury in kg/m^3\n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "print\"pressure measured by manometer(P) in pa\"\n", + "print\"p=rho*g*h\"\n", + "p=rho*g*h\n", + "print\"now weight of piston(m*g) = upward thrust by gas(p*math.pi*d^2/4)\"\n", + "print\"mass of piston(m)in kg\"\n", + "m=(p*math.pi*d**2)/(4*g)\n", + "print\"so m=\",round(m,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.9;page no:24" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.9, Page:24 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 9\n", + "balancing pressure at plane BC in figure we get\n", + "Psteam+Pwater=Patm+Pmercury\n", + "now 1.atmospheric pressure(Patm)in pa\n", + "Patm= 101396.16\n", + "2.pressure due to water(Pwater)in pa\n", + "Pwater= 196.2\n", + "3.pressure due to mercury(Pmercury)in pa\n", + "Pmercury=RHOm*g*h3 13341.6\n", + "using balancing equation\n", + "Psteam=Patm+Pmercury-Pwater\n", + "so pressure of steam(Psteam)in kpa\n", + "Psteam= 114.54\n" + ] + } + ], + "source": [ + "#cal of pressure due to atmosphere,water,mercury,steam\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.9, Page:24 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 9\")\n", + "RHOm=13.6*10**3;#density of mercury in kg/m^3\n", + "RHOw=1000;#density of water in kg/m^3\n", + "h1=76*10**-2;#barometer reading in m of mercury\n", + "h2=2*10**-2;#height raised by water in manometer tube in m \n", + "h3=10*10**-2;#height raised by mercury in manometer tube in m \n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "print(\"balancing pressure at plane BC in figure we get\")\n", + "print(\"Psteam+Pwater=Patm+Pmercury\")\n", + "print(\"now 1.atmospheric pressure(Patm)in pa\")\n", + "Patm=RHOm*g*h1\n", + "print(\"Patm=\"),round(Patm,2)\n", + "print(\"2.pressure due to water(Pwater)in pa\")\n", + "Pwater=RHOw*g*h2\n", + "print(\"Pwater=\"),round(Pwater,2)\n", + "print(\"3.pressure due to mercury(Pmercury)in pa\")\n", + "Pmercury=RHOm*g*h3\n", + "print(\"Pmercury=RHOm*g*h3\"),round(Pmercury,2)\n", + "print(\"using balancing equation\")\n", + "print(\"Psteam=Patm+Pmercury-Pwater\")\n", + "print(\"so pressure of steam(Psteam)in kpa\")\n", + "Psteam=(Patm+Pmercury-Pwater)/1000\n", + "print(\"Psteam=\"),round(Psteam,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.10;page no:24" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.10, Page:24 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 10\n", + "atmospheric pressure(Patm)in kpa\n", + "absolute temperature in compartment A(Pa) in kpa\n", + "Pa= 496.06\n", + "absolute temperature in compartment B(Pb) in kpa\n", + "Pb= 246.06\n", + "absolute pressure in compartments in A & B=496.06 kpa & 246.06 kpa\n" + ] + } + ], + "source": [ + "#cal of \"absolute temperature in compartment A,B\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.10, Page:24 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 10\")\n", + "h=720*10**-3;#barometer reading in m of Hg\n", + "Pga=400;#gauge pressure in compartment A in kpa\n", + "Pgb=150;#gauge pressure in compartment B in kpa\n", + "rho=13.6*10**3;#density of mercury in kg/m^3\n", + "g=9.81;#acceleration due to gravity in m/s^2\n", + "print(\"atmospheric pressure(Patm)in kpa\")\n", + "Patm=(rho*g*h)/1000\n", + "print(\"absolute temperature in compartment A(Pa) in kpa\")\n", + "Pa=Pga+Patm\n", + "print\"Pa=\",round(Pa,2)\n", + "print\"absolute temperature in compartment B(Pb) in kpa\"\n", + "Pb=Pgb+Patm\n", + "print\"Pb=\",round(Pb,2)\n", + "print\"absolute pressure in compartments in A & B=496.06 kpa & 246.06 kpa\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.11;page no:25" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.11, Page:25 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 11\n", + "the pressure of air in air tank can be obtained by equalising pressures at some reference line\n", + "P1+RHOw*g*h1+RHOo*g*h2 = Patm+RHOm*g*h3\n", + "so P1 = Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2\n", + "air pressure(P1)in kpa 139.81\n" + ] + } + ], + "source": [ + "#cal of air pressure\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.11, Page:25 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 11\")\n", + "Patm=90*10**3;#atmospheric pressure in pa\n", + "RHOw=1000;#density of water in kg/m^3\n", + "RHOm=13600;#density of mercury in kg/m^3\n", + "RHOo=850;#density of oil in kg/m^3\n", + "g=9.81;#acceleration due to ggravity in m/s^2\n", + "h1=.15;#height difference between water column in m\n", + "h2=.25;#height difference between oil column in m\n", + "h3=.4;#height difference between mercury column in m\n", + "print\"the pressure of air in air tank can be obtained by equalising pressures at some reference line\"\n", + "print\"P1+RHOw*g*h1+RHOo*g*h2 = Patm+RHOm*g*h3\"\n", + "print\"so P1 = Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2\"\n", + "P1=(Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2)/1000\n", + "print\"air pressure(P1)in kpa\",round(P1,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.12;page no:26" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.12, Page:26 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 12\n", + "mass of object(m)in kg\n", + "m=F/g\n", + "kinetic energy(E)in J is given by\n", + "E= 140625000.0\n" + ] + } + ], + "source": [ + "#cal of kinetic energy\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.12, Page:26 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 12\"\n", + "v=750;#relative velocity of object with respect to earth in m/sec\n", + "F=4000;#gravitational force in N\n", + "g=8;#acceleration due to gravity in m/s^2\n", + "print\"mass of object(m)in kg\"\n", + "print\"m=F/g\"\n", + "m=F/g\n", + "print\"kinetic energy(E)in J is given by\"\n", + "E=m*v**2/2\n", + "print\"E=\",round(E)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.13;page no:26" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.13, Page:26 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 13\n", + "characteristics gas constant(R2)in kJ/kg k\n", + "molecular weight of gas(m)in kg/kg mol= 16.63\n", + "NOTE=>Their is some calculation mistake while calaulating gas constant in book,which is corrected above hence answer may vary.\n" + ] + } + ], + "source": [ + "#cal of molecular weight of gas\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.13, Page:26 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 13\"\n", + "Cp=2.286;#specific heat at constant pressure in kJ/kg k\n", + "Cv=1.786;#specific heat at constant volume in kJ/kg k\n", + "R1=8.3143;#universal gas constant in kJ/kg k\n", + "print\"characteristics gas constant(R2)in kJ/kg k\"\n", + "R2=Cp-Cv\n", + "m=R1/R2\n", + "print\"molecular weight of gas(m)in kg/kg mol=\",round(m,2)\n", + "print\"NOTE=>Their is some calculation mistake while calaulating gas constant in book,which is corrected above hence answer may vary.\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.14;page no:26" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.14, Page:26 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 14\n", + "using perfect gas equation\n", + "P1*V1/T1 = P2*V2/T2\n", + "=>T2=(P2*V2*T1)/(P1*V1)\n", + "so final temperature of gas(T2)in k\n", + "or final temperature of gas(T2)in degree celcius= 127.0\n" + ] + } + ], + "source": [ + "#cal of final temperature of gas\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.14, Page:26 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 14\"\n", + "P1=750*10**3;#initial pressure of gas in pa\n", + "V1=0.2;#initial volume of gas in m^3\n", + "T1=600;#initial temperature of gas in k\n", + "P2=2*10**5;#final pressure of gas i pa\n", + "V2=0.5;#final volume of gas in m^3\n", + "print\"using perfect gas equation\"\n", + "print\"P1*V1/T1 = P2*V2/T2\"\n", + "print\"=>T2=(P2*V2*T1)/(P1*V1)\"\n", + "print\"so final temperature of gas(T2)in k\"\n", + "T2=(P2*V2*T1)/(P1*V1)\n", + "T2=T2-273\n", + "print\"or final temperature of gas(T2)in degree celcius=\",round(T2,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.15;page no:27" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.15, Page:27 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 15\n", + "from perfect gas equation we get\n", + "initial mass of air(m1 in kg)=(P1*V1)/(R*T1)\n", + "m1= 5.807\n", + "final mass of air(m2 in kg)=(P2*V2)/(R*T2)\n", + "m2= 3.111\n", + "mass of air removed(m)in kg 2.696\n", + "volume of this mass of air(V) at initial states in m^3= 2.32\n" + ] + } + ], + "source": [ + "#cal of volume of this mass of air(V) at initial states\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.15, Page:27 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 15\"\n", + "P1=100*10**3;#initial pressure of air in pa\n", + "V1=5.;#initial volume of air in m^3\n", + "T1=300.;#initial temperature of gas in k\n", + "P2=50*10**3;#final pressure of air in pa\n", + "V2=5.;#final volume of air in m^3\n", + "T2=(280.);#final temperature of air in K\n", + "R=287.;#gas constant on J/kg k\n", + "print\"from perfect gas equation we get\"\n", + "print\"initial mass of air(m1 in kg)=(P1*V1)/(R*T1)\"\n", + "m1=(P1*V1)/(R*T1)\n", + "print(\"m1=\"),round(m1,3)\n", + "print\"final mass of air(m2 in kg)=(P2*V2)/(R*T2)\"\n", + "m2=(P2*V2)/(R*T2)\n", + "print(\"m2=\"),round(m2,3)\n", + "m=m1-m2\n", + "print\"mass of air removed(m)in kg\",round(m,3)\n", + "V=m*R*T1/P1\n", + "print\"volume of this mass of air(V) at initial states in m^3=\",round(V,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.16;page no:27" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.16, Page:27 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 16\n", + "here V1=V2\n", + "so P1/T1=P2/T2\n", + "final temperature of hydrogen gas(T2)in k\n", + "=>T2=P2*T1/P1\n", + "now R=(Cp-Cv) in KJ/kg k\n", + "And volume of cylinder(V1)in m^3\n", + "V1=(math.pi*d^2*l)/4\n", + "mass of hydrogen gas(m)in kg\n", + "m= 0.254\n", + "now heat supplied(Q)in KJ\n", + "Q= 193.93\n" + ] + } + ], + "source": [ + "#cal of heat supplied\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "import math\n", + "print\"Example 1.16, Page:27 \\n \\n\"\n", + "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 16\"\n", + "d=1;#diameter of cylinder in m\n", + "l=4;#length of cylinder in m\n", + "P1=100*10**3;#initial pressureof hydrogen gas in pa\n", + "T1=(27+273);#initial temperature of hydrogen gas in k\n", + "P2=125*10**3;#final pressureof hydrogen gas in pa\n", + "Cp=14.307;#specific heat at constant pressure in KJ/kg k\n", + "Cv=10.183;#specific heat at constant volume in KJ/kg k\n", + "print\"here V1=V2\"\n", + "print\"so P1/T1=P2/T2\"\n", + "print\"final temperature of hydrogen gas(T2)in k\"\n", + "print\"=>T2=P2*T1/P1\"\n", + "T2=P2*T1/P1\n", + "print\"now R=(Cp-Cv) in KJ/kg k\"\n", + "R=Cp-Cv\n", + "print\"And volume of cylinder(V1)in m^3\"\n", + "print\"V1=(math.pi*d^2*l)/4\"\n", + "V1=(math.pi*d**2*l)/4\n", + "print\"mass of hydrogen gas(m)in kg\"\n", + "m=(P1*V1)/(1000*R*T1)\n", + "print\"m=\",round(m,3)\n", + "print\"now heat supplied(Q)in KJ\"\n", + "Q=m*Cv*(T2-T1)\n", + "print\"Q=\",round(Q,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.17;page no:28" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.17, Page:28 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 17\n", + "final total volume(V)in m^3\n", + "V=V1*V2\n", + "total mass of air(m)in kg\n", + "m=m1+m2\n", + "final pressure of air(P)in kpa\n", + "using perfect gas equation\n", + "P= 516.6\n" + ] + } + ], + "source": [ + "#cal of final pressure\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.17, Page:28 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 17\")\n", + "V1=2.;#volume of first cylinder in m^3\n", + "V2=2.;#volume of second cylinder in m^3\n", + "T=(27+273);#temperature of system in k\n", + "m1=20.;#mass of air in first vessel in kg\n", + "m2=4.;#mass of air in second vessel in kg\n", + "R=287.;#gas constant J/kg k\n", + "print(\"final total volume(V)in m^3\")\n", + "print(\"V=V1*V2\")\n", + "V=V1*V2\n", + "print(\"total mass of air(m)in kg\")\n", + "print(\"m=m1+m2\")\n", + "m=m1+m2\n", + "print(\"final pressure of air(P)in kpa\")\n", + "print(\"using perfect gas equation\")\n", + "P=(m*R*T)/(1000*V)\n", + "print\"P=\",round(P,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.18;page no:28" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.18, Page:28 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 18\n", + "1.By considering it as a PERFECT GAS\n", + "gas constant for CO2(Rco2)\n", + "Rco2=(J/Kg.k) 188.9\n", + "Also P*V=M*Rco2*T\n", + "pressure of CO2 as perfect gas(P)in N/m^2\n", + "P=(m*Rco2*T)/V 141683.71\n", + "2.By considering as a REAL GAS\n", + "values of vanderwaal constants a,b can be seen from the table which are\n", + "a=(N m^4/(kg mol)^2) 362850.0\n", + "b=(m^3/kg mol) 0.03\n", + "now specific volume(v)in m^3/kg mol\n", + "v= 17.604\n", + "now substituting the value of all variables in vanderwaal equation\n", + "(P+(a/v^2))*(v-b)=R*T\n", + "pressure of CO2 as real gas(P)in N/m^2\n", + "P= 140766.02\n" + ] + } + ], + "source": [ + "#cal of pressure of CO2 as perfect,real gas\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.18, Page:28 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 18\")\n", + "m=5;#mass of CO2 in kg\n", + "V=2;#volume of vesssel in m^3\n", + "T=(27+273);#temperature of vessel in k\n", + "R=8.314*10**3;#universal gas constant in J/kg k\n", + "M=44.01;#molecular weight of CO2 \n", + "print(\"1.By considering it as a PERFECT GAS\")\n", + "print(\"gas constant for CO2(Rco2)\")\n", + "Rco2=R/M\n", + "print(\"Rco2=(J/Kg.k)\"),round(Rco2,1)\n", + "print(\"Also P*V=M*Rco2*T\")\n", + "print(\"pressure of CO2 as perfect gas(P)in N/m^2\")\n", + "P=(m*Rco2*T)/V\n", + "print(\"P=(m*Rco2*T)/V \"),round(P,2)\n", + "print(\"2.By considering as a REAL GAS\")\n", + "print(\"values of vanderwaal constants a,b can be seen from the table which are\")\n", + "a=3628.5*10**2#vanderwall constant in N m^4/(kg mol)^2\n", + "b=3.14*10**-2# vanderwall constant in m^3/kg mol\n", + "print(\"a=(N m^4/(kg mol)^2) \"),round(a,2)\n", + "print(\"b=(m^3/kg mol)\"),round(b,2)\n", + "print(\"now specific volume(v)in m^3/kg mol\")\n", + "v=V*M/m\n", + "print(\"v=\"),round(v,3)\n", + "print(\"now substituting the value of all variables in vanderwaal equation\")\n", + "print(\"(P+(a/v^2))*(v-b)=R*T\")\n", + "print(\"pressure of CO2 as real gas(P)in N/m^2\")\n", + "P=((R*T)/(v-b))-(a/v**2)\n", + "print(\"P=\"),round(P,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.19;page no:29" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.19, Page:29 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 19\n", + "1.considering as perfect gas\n", + "specific volume(V)in m^3/kg\n", + "V= 0.0186\n", + "2.considering compressibility effects\n", + "reduced pressure(P)in pa\n", + "p= 0.8\n", + "reduced temperature(t)in k\n", + "t= 1.1\n", + "from generalised compressibility chart,compressibility factor(Z)can be seen for reduced pressure and reduced temperatures of 0.8 and 1.1\n", + "we get Z=0.785\n", + "now actual specific volume(v)in m^3/kg\n", + "v= 0.0146\n" + ] + } + ], + "source": [ + "#cal of specific volume of steam\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.19, Page:29 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 19\")\n", + "P=17672;#pressure of steam on kpa\n", + "T=712;#temperature of steam in k\n", + "Pc=22.09;#critical pressure of steam in Mpa\n", + "Tc=647.3;#critical temperature of steam in k\n", + "R=0.4615;#gas constant for steam in KJ/kg k\n", + "print(\"1.considering as perfect gas\")\n", + "print(\"specific volume(V)in m^3/kg\")\n", + "V=R*T/P\n", + "print(\"V=\"),round(V,4)\n", + "print(\"2.considering compressibility effects\")\n", + "print(\"reduced pressure(P)in pa\")\n", + "p=P/(Pc*1000)\n", + "print(\"p=\"),round(p,2)\n", + "print(\"reduced temperature(t)in k\")\n", + "t=T/Tc\n", + "print(\"t=\"),round(t,2)\n", + "print(\"from generalised compressibility chart,compressibility factor(Z)can be seen for reduced pressure and reduced temperatures of 0.8 and 1.1\")\n", + "print(\"we get Z=0.785\")\n", + "Z=0.785;#compressibility factor\n", + "print(\"now actual specific volume(v)in m^3/kg\")\n", + "v=Z*V\n", + "print(\"v=\"),round(v,4)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.20;page no:30" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.20, Page:30 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 20\n", + "volume of ballon(V1)in m^3\n", + "V1= 65.45\n", + "molecular mass of hydrogen(M)\n", + "M=2\n", + "gas constant for H2(R1)in J/kg k\n", + "R1= 4157.0\n", + "mass of H2 in ballon(m1)in kg\n", + "m1= 5.316\n", + "volume of air printlaced(V2)=volume of ballon(V1)\n", + "mass of air printlaced(m2)in kg\n", + "m2= 79.66\n", + "gas constant for air(R2)=0.287 KJ/kg k\n", + "load lifting capacity due to buoyant force(m)in kg\n", + "m= 74.343\n" + ] + } + ], + "source": [ + "#estimation of maximum load that can be lifted \n", + "#intiation of all variables\n", + "# Chapter 1\n", + "import math\n", + "print\"Example 1.20, Page:30 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 20\")\n", + "d=5.;#diameter of ballon in m\n", + "T1=(27.+273.);#temperature of hydrogen in k\n", + "P=1.013*10**5;#atmospheric pressure in pa\n", + "T2=(17.+273.);#temperature of surrounding air in k\n", + "R=8.314*10**3;#gas constant in J/kg k\n", + "print(\"volume of ballon(V1)in m^3\")\n", + "V1=(4./3.)*math.pi*((d/2)**3)\n", + "print(\"V1=\"),round(V1,2)\n", + "print(\"molecular mass of hydrogen(M)\")\n", + "print(\"M=2\")\n", + "M=2;#molecular mass of hydrogen\n", + "print(\"gas constant for H2(R1)in J/kg k\")\n", + "R1=R/M\n", + "print(\"R1=\"),round(R1,2)\n", + "print(\"mass of H2 in ballon(m1)in kg\")\n", + "m1=(P*V1)/(R1*T1)\n", + "print(\"m1=\"),round(m1,3)\n", + "print(\"volume of air printlaced(V2)=volume of ballon(V1)\")\n", + "print(\"mass of air printlaced(m2)in kg\")\n", + "R2=0.287*1000;#gas constant for air in J/kg k\n", + "m2=(P*V1)/(R2*T2)\n", + "print(\"m2=\"),round(m2,2)\n", + "print(\"gas constant for air(R2)=0.287 KJ/kg k\")\n", + "print(\"load lifting capacity due to buoyant force(m)in kg\")\n", + "m=m2-m1\n", + "print(\"m=\"),round(m,3)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.21;page no:31" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.21, Page:31 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 21\n", + "let initial receiver pressure(p1)=1 in pa\n", + "so final receiver pressure(p2)=in pa 0.25\n", + "perfect gas equation,p*V*m=m*R*T\n", + "differentiating and then integrating equation w.r.t to time(t) \n", + "we get t=-(V/v)*log(p2/p1)\n", + "so time(t)in min 110.9\n" + ] + } + ], + "source": [ + "#cal of time required\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "import math\n", + "print\"Example 1.21, Page:31 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 21\")\n", + "v=0.25;#volume sucking rate of pump in m^3/min\n", + "V=20.;#volume of air vessel in m^3\n", + "p1=1.;#initial receiver pressure in pa\n", + "print(\"let initial receiver pressure(p1)=1 in pa\")\n", + "p2=p1/4.\n", + "print(\"so final receiver pressure(p2)=in pa\"),round(p2,2)\n", + "print(\"perfect gas equation,p*V*m=m*R*T\")\n", + "print(\"differentiating and then integrating equation w.r.t to time(t) \")\n", + "print(\"we get t=-(V/v)*log(p2/p1)\")\n", + "t=-(V/v)*math.log(p2/p1)\n", + "print(\"so time(t)in min\"),round(t,2)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.22;page no:32" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.22, Page:32 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 22\n", + "first calculate gas constants for different gases in j/kg k\n", + "for nitrogen,R1= 296.9\n", + "for oxygen,R2= 259.8\n", + "for carbon dioxide,R3= 188.95\n", + "so the gas constant for mixture(Rm)in j/kg k\n", + "Rm= 288.09\n", + "now the specific heat at constant pressure for constituent gases in KJ/kg k\n", + "for nitrogen,Cp1= 1.039\n", + "for oxygen,Cp2= 0.909\n", + "for carbon dioxide,Cp3= 0.819\n", + "so the specific heat at constant pressure for mixture(Cpm)in KJ/kg k\n", + "Cpm= 1.0115\n", + "now no. of moles of constituents gases\n", + "for nitrogen,n1=m1/M1 in mol,where m1=f1*m in kg 0.143\n", + "for oxygen,n2=m2/M2 in mol,where m2=f2*m in kg 0.028\n", + "for carbon dioxide,n3=m3/M3 in mol,where m3=f3*m in kg 0.0023\n", + "total no. of moles in mixture in mol\n", + "n= 0.1733\n", + "now mole fraction of constituent gases\n", + "for nitrogen,x1= 0.825\n", + "for oxygen,x2= 0.162\n", + "for carbon dioxide,x3= 0.0131\n", + "now the molecular weight of mixture(Mm)in kg/kmol\n", + "Mm= 28.86\n" + ] + } + ], + "source": [ + "#cal of specific heat at constant pressure for constituent gases \n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.22, Page:32 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 22\")\n", + "m=5;#mass of mixture of gas in kg\n", + "P=1.013*10**5;#pressure of mixture in pa\n", + "T=300;#temperature of mixture in k\n", + "M1=28.;#molecular weight of nitrogen(N2)\n", + "M2=32.;#molecular weight of oxygen(O2)\n", + "M3=44.;#molecular weight of carbon dioxide(CO2)\n", + "f1=0.80;#fraction of N2 in mixture\n", + "f2=0.18;#fraction of O2 in mixture\n", + "f3=0.02;#fraction of CO2 in mixture\n", + "k1=1.4;#ratio of specific heat capacities for N2\n", + "k2=1.4;#ratio of specific heat capacities for O2\n", + "k3=1.3;#ratio of specific heat capacities for CO2\n", + "R=8314;#universal gas constant in J/kg k\n", + "print(\"first calculate gas constants for different gases in j/kg k\")\n", + "R1=R/M1\n", + "print(\"for nitrogen,R1=\"),round(R1,1)\n", + "R2=R/M2\n", + "print(\"for oxygen,R2=\"),round(R2,1)\n", + "R3=R/M3\n", + "print(\"for carbon dioxide,R3=\"),round(R3,2)\n", + "print(\"so the gas constant for mixture(Rm)in j/kg k\")\n", + "Rm=f1*R1+f2*R2+f3*R3\n", + "print(\"Rm=\"),round(Rm,2)\n", + "print(\"now the specific heat at constant pressure for constituent gases in KJ/kg k\")\n", + "Cp1=((k1/(k1-1))*R1)/1000\n", + "print(\"for nitrogen,Cp1=\"),round(Cp1,3)\n", + "Cp2=((k2/(k2-1))*R2)/1000\n", + "print(\"for oxygen,Cp2=\"),round(Cp2,3)\n", + "Cp3=((k3/(k3-1))*R3)/1000\n", + "print(\"for carbon dioxide,Cp3=\"),round(Cp3,3)\n", + "print(\"so the specific heat at constant pressure for mixture(Cpm)in KJ/kg k\")\n", + "Cpm=f1*Cp1+f2*Cp2+f3*Cp3\n", + "print(\"Cpm=\"),round(Cpm,4)\n", + "print(\"now no. of moles of constituents gases\")\n", + "m1=f1*m\n", + "n1=m1/M1\n", + "print(\"for nitrogen,n1=m1/M1 in mol,where m1=f1*m in kg\"),round(n1,3)\n", + "m2=f2*m\n", + "n2=m2/M2\n", + "print(\"for oxygen,n2=m2/M2 in mol,where m2=f2*m in kg\"),round(n2,3)\n", + "m3=f3*m\n", + "n3=m3/M3\n", + "print(\"for carbon dioxide,n3=m3/M3 in mol,where m3=f3*m in kg\"),round(n3,4)\n", + "print(\"total no. of moles in mixture in mol\")\n", + "n=n1+n2+n3\n", + "print(\"n=\"),round(n,4)\n", + "print(\"now mole fraction of constituent gases\")\n", + "x1=n1/n\n", + "print(\"for nitrogen,x1=\"),round(x1,3)\n", + "x2=n2/n\n", + "print(\"for oxygen,x2=\"),round(x2,3)\n", + "x3=n3/n\n", + "print(\"for carbon dioxide,x3=\"),round(x3,4)\n", + "print(\"now the molecular weight of mixture(Mm)in kg/kmol\")\n", + "Mm=M1*x1+M2*x2+M3*x3\n", + "print(\"Mm=\"),round(Mm,2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.23;page no:33" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.23, Page:33 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 23\n", + "mole fraction of constituent gases\n", + "x=(ni/n)=(Vi/V)\n", + "take volume of mixture(V)=1 m^3\n", + "mole fraction of O2(x1)\n", + "x1= 0.18\n", + "mole fraction of N2(x2)\n", + "x2= 0.75\n", + "mole fraction of CO2(x3)\n", + "x3= 0.07\n", + "now molecular weight of mixture = molar mass(m)\n", + "m= 29.84\n", + "now gravimetric analysis refers to the mass fraction analysis\n", + "mass fraction of constituents\n", + "y=xi*Mi/m\n", + "mole fraction of O2\n", + "y1= 0.193\n", + "mole fraction of N2\n", + "y2= 0.704\n", + "mole fraction of CO2\n", + "y3= 0.103\n", + "now partial pressure of constituents = volume fraction * pressure of mixture\n", + "Pi=xi*P\n", + "partial pressure of O2(P1)in Mpa\n", + "P1= 0.09\n", + "partial pressure of N2(P2)in Mpa\n", + "P2= 0.375\n", + "partial pressure of CO2(P3)in Mpa\n", + "P3= 0.04\n", + "NOTE=>Their is some calculation mistake for partial pressure of CO2(i.e 0.35Mpa)which is given wrong in book so it is corrected above hence answers may vary.\n" + ] + } + ], + "source": [ + "#cal of pressure difference\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.23, Page:33 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 23\")\n", + "V1=0.18;#volume fraction of O2 in m^3\n", + "V2=0.75;#volume fraction of N2 in m^3\n", + "V3=0.07;#volume fraction of CO2 in m^3\n", + "P=0.5;#pressure of mixture in Mpa\n", + "T=(107+273);#temperature of mixture in k\n", + "M1=32;#molar mass of O2\n", + "M2=28;#molar mass of N2\n", + "M3=44;#molar mass of CO2\n", + "print(\"mole fraction of constituent gases\")\n", + "print(\"x=(ni/n)=(Vi/V)\")\n", + "V=1;# volume of mixture in m^3\n", + "print(\"take volume of mixture(V)=1 m^3\")\n", + "print(\"mole fraction of O2(x1)\")\n", + "x1=V1/V\n", + "print(\"x1=\"),round(x1,2)\n", + "print(\"mole fraction of N2(x2)\")\n", + "x2=V2/V\n", + "print(\"x2=\"),round(x2,2)\n", + "print(\"mole fraction of CO2(x3)\")\n", + "x3=V3/V\n", + "print(\"x3=\"),round(x3,2)\n", + "print(\"now molecular weight of mixture = molar mass(m)\")\n", + "m=x1*M1+x2*M2+x3*M3\n", + "print(\"m=\"),round(m,2)\n", + "print(\"now gravimetric analysis refers to the mass fraction analysis\")\n", + "print(\"mass fraction of constituents\")\n", + "print(\"y=xi*Mi/m\")\n", + "print(\"mole fraction of O2\")\n", + "y1=x1*M1/m\n", + "print(\"y1=\"),round(y1,3)\n", + "print(\"mole fraction of N2\")\n", + "y2=x2*M2/m\n", + "print(\"y2=\"),round(y2,3)\n", + "print(\"mole fraction of CO2\")\n", + "y3=x3*M3/m\n", + "print(\"y3=\"),round(y3,3)\n", + "print(\"now partial pressure of constituents = volume fraction * pressure of mixture\")\n", + "print(\"Pi=xi*P\")\n", + "print(\"partial pressure of O2(P1)in Mpa\")\n", + "p1=x1*P\n", + "print(\"P1=\"),round(p1,2)\n", + "print(\"partial pressure of N2(P2)in Mpa\")\n", + "P2=x2*P\n", + "print(\"P2=\"),round(P2,3)\n", + "P3=x3*P\n", + "print(\"partial pressure of CO2(P3)in Mpa\")\n", + "print(\"P3=\"),round(P3,2)\n", + "print(\"NOTE=>Their is some calculation mistake for partial pressure of CO2(i.e 0.35Mpa)which is given wrong in book so it is corrected above hence answers may vary.\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.24;page no:34" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.24, Page:34 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 24\n", + "volume of tank of N2(V1) in m^3= 3.0\n", + "volume of tank of CO2(V2) in m^3= 3.0\n", + "taking the adiabatic condition\n", + "no. of moles of N2(n1)\n", + "n1= 0.6\n", + "no. of moles of CO2(n2)\n", + "n2= 0.37\n", + "total no. of moles of mixture(n)in mol\n", + "n= 0.97\n", + "gas constant for N2(R1)in J/kg k\n", + "R1= 296.93\n", + "gas constant for CO2(R2)in J/kg k\n", + "R2=R/M2 188.95\n", + "specific heat of N2 at constant volume (Cv1) in J/kg k\n", + "Cv1= 742.32\n", + "specific heat of CO2 at constant volume (Cv2) in J/kg k\n", + "Cv2= 629.85\n", + "mass of N2(m1)in kg\n", + "m1= 16.84\n", + "mass of CO2(m2)in kg\n", + "m2= 16.28\n", + "let us consider the equilibrium temperature of mixture after adiabatic mixing at T\n", + "applying energy conservation principle\n", + "m1*Cv1*(T-T1) = m2*Cv2*(T-T2)\n", + "equlibrium temperature(T)in k\n", + "=>T= 439.44\n", + "so the equlibrium pressure(P)in kpa\n", + "P= 591.55\n" + ] + } + ], + "source": [ + "#cal of equilibrium temperature,pressure of mixture\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.24, Page:34 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 24\")\n", + "V=6;#volume of tank in m^3\n", + "P1=800*10**3;#pressure of N2 gas tank in pa\n", + "T1=480.;#temperature of N2 gas tank in k\n", + "P2=400*10**3;#pressure of CO2 gas tank in pa\n", + "T2=390.;#temperature of CO2 gas tank in k\n", + "k1=1.4;#ratio of specific heat capacity for N2\n", + "k2=1.3;#ratio of specific heat capacity for CO2\n", + "R=8314.;#universal gas constant in J/kg k\n", + "M1=28.;#molecular weight of N2\n", + "M2=44.;#molecular weight of CO2\n", + "V1=V/2\n", + "print(\"volume of tank of N2(V1) in m^3=\"),round(V1,2)\n", + "V2=V/2\n", + "print(\"volume of tank of CO2(V2) in m^3=\"),round(V2,2)\n", + "print(\"taking the adiabatic condition\")\n", + "print(\"no. of moles of N2(n1)\")\n", + "n1=(P1*V1)/(R*T1)\n", + "print(\"n1=\"),round(n1,2)\n", + "print(\"no. of moles of CO2(n2)\")\n", + "n2=(P2*V2)/(R*T2)\n", + "print(\"n2=\"),round(n2,2)\n", + "print(\"total no. of moles of mixture(n)in mol\")\n", + "n=n1+n2\n", + "print(\"n=\"),round(n,2)\n", + "print(\"gas constant for N2(R1)in J/kg k\")\n", + "R1=R/M1\n", + "print(\"R1=\"),round(R1,2)\n", + "print(\"gas constant for CO2(R2)in J/kg k\")\n", + "R2=R/M2\n", + "print(\"R2=R/M2\"),round(R2,2)\n", + "print(\"specific heat of N2 at constant volume (Cv1) in J/kg k\")\n", + "Cv1=R1/(k1-1)\n", + "print(\"Cv1=\"),round(Cv1,2)\n", + "print(\"specific heat of CO2 at constant volume (Cv2) in J/kg k\")\n", + "Cv2=R2/(k2-1)\n", + "print(\"Cv2=\"),round(Cv2,2)\n", + "print(\"mass of N2(m1)in kg\")\n", + "m1=n1*M1\n", + "print(\"m1=\"),round(m1,2)\n", + "print(\"mass of CO2(m2)in kg\")\n", + "m2=n2*M2\n", + "print(\"m2=\"),round(m2,2)\n", + "print(\"let us consider the equilibrium temperature of mixture after adiabatic mixing at T\")\n", + "print(\"applying energy conservation principle\")\n", + "print(\"m1*Cv1*(T-T1) = m2*Cv2*(T-T2)\")\n", + "print(\"equlibrium temperature(T)in k\")\n", + "T=((m1*Cv1*T1)+(m2*Cv2*T2))/((m1*Cv1)+(m2*Cv2))\n", + "print(\"=>T=\"),round(T,2)\n", + "print(\"so the equlibrium pressure(P)in kpa\")\n", + "P=(n*R*T)/(1000*V)\n", + "print(\"P=\"),round(P,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.25;page no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.25, Page:35 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 25\n", + "since two gases are non reacting therefore specific heat of final mixture(Cp)in KJ/kg k can be obtained by following for adiabatic mixing\n", + "so the specific heat at constant pressure(Cp)in KJ/kg k\n", + "Cp= 7.608\n" + ] + } + ], + "source": [ + "#cal of specific heat of final mixture\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.25, Page:35 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 25\")\n", + "m1=2;#mass of H2 in kg\n", + "m2=3;#mass of He in kg\n", + "T=100;#temperature of container in k\n", + "Cp1=11.23;#specific heat at constant pressure for H2 in KJ/kg k\n", + "Cp2=5.193;#specific heat at constant pressure for He in KJ/kg k\n", + "print(\"since two gases are non reacting therefore specific heat of final mixture(Cp)in KJ/kg k can be obtained by following for adiabatic mixing\")\n", + "print(\"so the specific heat at constant pressure(Cp)in KJ/kg k\")\n", + "Cp=((Cp1*m1)+Cp2*m2)/(m1+m2)\n", + "print(\"Cp=\"),round(Cp,3)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.26;page no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.26, Page:35 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 26\n", + "gas constant for H2(R1)in KJ/kg k\n", + "R1= 4.157\n", + "gas constant for N2(R2)in KJ/kg k\n", + "R2= 0.297\n", + "gas constant for CO2(R3)in KJ/kg k\n", + "R3= 0.189\n", + "so now gas constant for mixture(Rm)in KJ/kg k\n", + "Rm= 2.606\n", + "considering gas to be perfect gas\n", + "total mass of mixture(m)in kg\n", + "m= 30.0\n", + "capacity of vessel(V)in m^3\n", + "V= 231.57\n", + "now final temperature(Tf) is twice of initial temperature(Ti)\n", + "so take k=Tf/Ti=2\n", + "for constant volume heating,final pressure(Pf)in kpa shall be\n", + "Pf= 202.65\n" + ] + } + ], + "source": [ + "#cal of capacity and pressure in the vessel\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.26, Page:35 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 26\")\n", + "m1=18.;#mass of hydrogen(H2) in kg\n", + "m2=10.;#mass of nitrogen(N2) in kg\n", + "m3=2.;#mass of carbon dioxide(CO2) in kg\n", + "R=8.314;#universal gas constant in KJ/kg k\n", + "Pi=101.325;#atmospheric pressure in kpa\n", + "T=(27+273.15);#ambient temperature in k\n", + "M1=2;#molar mass of H2\n", + "M2=28;#molar mass of N2\n", + "M3=44;#molar mass of CO2\n", + "print(\"gas constant for H2(R1)in KJ/kg k\")\n", + "R1=R/M1\n", + "print(\"R1=\"),round(R1,3)\n", + "print(\"gas constant for N2(R2)in KJ/kg k\")\n", + "R2=R/M2\n", + "print(\"R2=\"),round(R2,3)\n", + "print(\"gas constant for CO2(R3)in KJ/kg k\")\n", + "R3=R/M3\n", + "print(\"R3=\"),round(R3,3)\n", + "print(\"so now gas constant for mixture(Rm)in KJ/kg k\")\n", + "Rm=(m1*R1+m2*R2+m3*R3)/(m1+m2+m3)\n", + "print(\"Rm=\"),round(Rm,3)\n", + "print(\"considering gas to be perfect gas\")\n", + "print(\"total mass of mixture(m)in kg\")\n", + "m=m1+m2+m3\n", + "print(\"m=\"),round(m,2)\n", + "print(\"capacity of vessel(V)in m^3\")\n", + "V=(m*Rm*T)/Pi\n", + "print(\"V=\"),round(V,2)\n", + "print(\"now final temperature(Tf) is twice of initial temperature(Ti)\")\n", + "k=2;#ratio of initial to final temperature\n", + "print(\"so take k=Tf/Ti=2\") \n", + "print(\"for constant volume heating,final pressure(Pf)in kpa shall be\")\n", + "Pf=Pi*k\n", + "print(\"Pf=\"),round(Pf,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.27;page no:36" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.27, Page:36 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 27\n", + "let inlet state be 1 and exit state be 2\n", + "by charles law volume and temperature can be related as\n", + "(V1/T1)=(V2/T2)\n", + "(V2/V1)=(T2/T1)\n", + "or (((math.pi*D2^2)/4)*V2)/(((math.pi*D1^2)/4)*V1)=T2/T1\n", + "since change in K.E=0\n", + "so (D2^2/D1^2)=T2/T1\n", + "D2/D1=sqrt(T2/T1)\n", + "say(D2/D1)=k\n", + "so exit to inlet diameter ratio(k) 1.29\n" + ] + } + ], + "source": [ + "#cal of exit to inlet diameter ratio\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "import math\n", + "print\"Example 1.27, Page:36 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 27\")\n", + "T1=(27.+273.);#initial temperature of air in k\n", + "T2=500.;#final temperature of air in k\n", + "print(\"let inlet state be 1 and exit state be 2\")\n", + "print(\"by charles law volume and temperature can be related as\")\n", + "print(\"(V1/T1)=(V2/T2)\")\n", + "print(\"(V2/V1)=(T2/T1)\")\n", + "print(\"or (((math.pi*D2^2)/4)*V2)/(((math.pi*D1^2)/4)*V1)=T2/T1\")\n", + "print(\"since change in K.E=0\")\n", + "print(\"so (D2^2/D1^2)=T2/T1\")\n", + "print(\"D2/D1=sqrt(T2/T1)\")\n", + "print(\"say(D2/D1)=k\")\n", + "k=math.sqrt(T2/T1)\n", + "print(\"so exit to inlet diameter ratio(k)\"),round(k,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.28;page no:37" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.28, Page:37 \n", + " \n", + "\n", + "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 28\n", + "gas constant for H2(R1)in KJ/kg k\n", + "R1= 4.157\n", + "say initial and final ststes are given by 1 and 2\n", + "mass of hydrogen pumped out shall be difference of initial and final mass inside vessel\n", + "final pressure of hydrogen(P2)in cm of Hg\n", + "P2= 6.0\n", + "therefore pressure difference(P)in kpa\n", + "P= 93.33\n", + "mass pumped out(m)in kg\n", + "m=((P1*V1)/(R1*T1))-((P2*V2)/(R1*T2))\n", + "here V1=V2=V and T1=T2=T\n", + "so m= 0.15\n", + "now during cooling upto 10 degree celcius,the process may be consider as constant volume process\n", + "say state before and after cooling are denoted by suffix 2 and 3\n", + "final pressure after cooling(P3)in kpa\n", + "P3= 7.546\n" + ] + } + ], + "source": [ + "#cal of final pressure\n", + "#intiation of all variables\n", + "# Chapter 1\n", + "print\"Example 1.28, Page:37 \\n \\n\"\n", + "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 28\")\n", + "V=2;#volume of vessel in m^3\n", + "P1=76;#initial pressure or atmospheric pressure in cm of Hg\n", + "T=(27+273.15);#temperature of vessel in k\n", + "p=70;#final pressure in cm of Hg vaccum\n", + "R=8.314;#universal gas constant in KJ/kg k\n", + "M=2;#molecular weight of H2\n", + "print(\"gas constant for H2(R1)in KJ/kg k\")\n", + "R1=R/M\n", + "print(\"R1=\"),round(R1,3)\n", + "print(\"say initial and final ststes are given by 1 and 2\")\n", + "print(\"mass of hydrogen pumped out shall be difference of initial and final mass inside vessel\")\n", + "print(\"final pressure of hydrogen(P2)in cm of Hg\")\n", + "P2=P1-p\n", + "print(\"P2=\"),round(P2,2)\n", + "print(\"therefore pressure difference(P)in kpa\")\n", + "P=((P1-P2)*101.325)/76\n", + "print(\"P=\"),round(P,2)\n", + "print(\"mass pumped out(m)in kg\")\n", + "print(\"m=((P1*V1)/(R1*T1))-((P2*V2)/(R1*T2))\")\n", + "print(\"here V1=V2=V and T1=T2=T\")\n", + "m=(V*P)/(R1*T)\n", + "print(\"so m=\"),round(m,2)\n", + "print(\"now during cooling upto 10 degree celcius,the process may be consider as constant volume process\")\n", + "print(\"say state before and after cooling are denoted by suffix 2 and 3\")\n", + "T3=(10+273.15);#final temperature after cooling in k\n", + "print(\"final pressure after cooling(P3)in kpa\")\n", + "P3=(T3/T)*P2*(101.325/76)\n", + "print(\"P3=\"),round(P3,3)\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SaiRakesh/chapter_1.ipynb b/sample_notebooks/SaiRakesh/chapter_1.ipynb deleted file mode 100755 index 9474d100..00000000 --- a/sample_notebooks/SaiRakesh/chapter_1.ipynb +++ /dev/null @@ -1,1777 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# chapter 1:Fundemental concepts and definitions" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.1;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1, Page:22 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 1\n", - "pressure difference(p)in pa\n", - "p= 39755.7\n" - ] - } - ], - "source": [ - "#cal of pressure difference\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.1, Page:22 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 1\"\n", - "h=30*10**-2;#manometer deflection of mercury in m\n", - "g=9.78;#acceleration due to gravity in m/s^2\n", - "rho=13550;#density of mercury at room temperature in kg/m^3\n", - "print\"pressure difference(p)in pa\"\n", - "p=rho*g*h\n", - "print\"p=\",round(p,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.2;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.2, Page:22 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 2\n", - "effort required for lifting the lid(E)in N\n", - "E= 7115.48\n" - ] - } - ], - "source": [ - "#cal of effort required for lifting the lid\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.2, Page:22 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 2\"\n", - "d=30*10**-2;#diameter of cylindrical vessel in m\n", - "h=76*10**-2;#atmospheric pressure in m of mercury\n", - "g=9.78;#acceleration due to gravity in m/s^2\n", - "rho=13550;#density of mercury at room temperature in kg/m^3\n", - "print\"effort required for lifting the lid(E)in N\"\n", - "E=(rho*g*h)*(3.14*d**2)/4\n", - "print\"E=\",round(E,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.3;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.3, Page:22 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 3\n", - "pressure measured by manometer is gauge pressure(Pg)in kpa\n", - "Pg=rho*g*h/10^3\n", - "actual pressure of the air(P)in kpa\n", - "P= 140.76\n" - ] - } - ], - "source": [ - "#cal of actual pressure of the air\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.3, Page:22 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 3\"\n", - "h=30*10**-2;# pressure of compressed air in m of mercury\n", - "Patm=101*10**3;#atmospheric pressure in pa\n", - "g=9.78;#acceleration due to gravity in m/s^2\n", - "rho=13550;#density of mercury at room temperature in kg/m^3\n", - "print\"pressure measured by manometer is gauge pressure(Pg)in kpa\"\n", - "print\"Pg=rho*g*h/10^3\"\n", - "Pg=rho*g*h/10**3\n", - "print\"actual pressure of the air(P)in kpa\"\n", - "P=Pg+Patm/10**3\n", - "print\"P=\",round(P,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.4;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.4, Page:22 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 4\n", - "density of oil(RHOoil)in kg/m^3\n", - "RHOoil=sg*RHOw\n", - "gauge pressure(Pg)in kpa\n", - "Pg= 7.848\n" - ] - } - ], - "source": [ - "#cal of gauge pressure\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.4, Page:22 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 4\"\n", - "h=1;#depth of oil tank in m\n", - "sg=0.8;#specific gravity of oil\n", - "RHOw=1000;#density of water in kg/m^3\n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "print\"density of oil(RHOoil)in kg/m^3\"\n", - "print\"RHOoil=sg*RHOw\"\n", - "RHOoil=sg*RHOw\n", - "print\"gauge pressure(Pg)in kpa\"\n", - "Pg=RHOoil*g*h/10**3\n", - "print\"Pg=\",round(Pg,3)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.5;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.5, Page:22 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 5\n", - "atmospheric pressure(Patm)in kpa\n", - "Patm=rho*g*h2/10^3\n", - "pressure due to mercury column at AB(Pab)in kpa\n", - "Pab=rho*g*h1/10^3\n", - "pressure exerted by gas(Pgas)in kpa\n", - "Pgas= 154.76\n" - ] - } - ], - "source": [ - "#cal of pressure exerted by gas\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.5, Page:22 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 5\"\n", - "rho=13.6*10**3;#density of mercury in kg/m^3\n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "h1=40*10**-2;#difference of height in mercury column in m as shown in figure\n", - "h2=76*10**-2;#barometer reading of mercury in m\n", - "print\"atmospheric pressure(Patm)in kpa\"\n", - "print\"Patm=rho*g*h2/10^3\"\n", - "Patm=rho*g*h2/10**3\n", - "print\"pressure due to mercury column at AB(Pab)in kpa\"\n", - "print\"Pab=rho*g*h1/10^3\"\n", - "Pab=rho*g*h1/10**3\n", - "print\"pressure exerted by gas(Pgas)in kpa\"\n", - "Pgas=Patm+Pab\n", - "print\"Pgas=\",round(Pgas,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.6;page no:23" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.6, Page:23 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 6\n", - "by law of conservation of energy\n", - "potential energy(m*g*h)in joule = heat required for heating water(m*Cp*deltaT*1000*4.18)in joule\n", - "so m*g*h = m*Cp*deltaT*4.18*1000\n", - "change in temperature of water(deltaT) in degree celcius\n", - "deltaT= 2.35\n" - ] - } - ], - "source": [ - "#cal of change in temperature of water\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.6, Page:23 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 6\"\n", - "m=1;#mass of water in kg\n", - "h=1000;#height from which water fall in m\n", - "Cp=1;#specific heat of water in kcal/kg k\n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "print\"by law of conservation of energy\"\n", - "print\"potential energy(m*g*h)in joule = heat required for heating water(m*Cp*deltaT*1000*4.18)in joule\"\n", - "print\"so m*g*h = m*Cp*deltaT*4.18*1000\"\n", - "print\"change in temperature of water(deltaT) in degree celcius\"\n", - "deltaT=(g*h)/(4.18*1000*Cp)\n", - "print\"deltaT=\",round(deltaT,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.7;page no:23" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.7, Page:23 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 7\n", - "mass of object(m)in kg\n", - "m=w1/g1\n", - "spring balance reading=gravitational force in mass(F)in N\n", - "F= 86.65\n" - ] - } - ], - "source": [ - "#cal of spring balance reading\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.7, Page:23 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 7\"\n", - "w1=100;#weight of object at standard gravitational acceleration in N\n", - "g1=9.81;#acceleration due to gravity in m/s^2\n", - "g2=8.5;#gravitational acceleration at some location\n", - "print\"mass of object(m)in kg\"\n", - "print\"m=w1/g1\"\n", - "m=w1/g1\n", - "print\"spring balance reading=gravitational force in mass(F)in N\"\n", - "F=m*g2\n", - "print\"F=\",round(F,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.8;page no:24" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.8, Page:24 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 8\n", - "pressure measured by manometer(P) in pa\n", - "p=rho*g*h\n", - "now weight of piston(m*g) = upward thrust by gas(p*math.pi*d^2/4)\n", - "mass of piston(m)in kg\n", - "so m= 28.84\n" - ] - } - ], - "source": [ - "#cal of mass of piston\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "import math\n", - "print\"Example 1.8, Page:24 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 8\"\n", - "d=15*10**-2;#diameter of cylinder in m\n", - "h=12*10**-2;#manometer height difference in m of mercury\n", - "rho=13.6*10**3;#density of mercury in kg/m^3\n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "print\"pressure measured by manometer(P) in pa\"\n", - "print\"p=rho*g*h\"\n", - "p=rho*g*h\n", - "print\"now weight of piston(m*g) = upward thrust by gas(p*math.pi*d^2/4)\"\n", - "print\"mass of piston(m)in kg\"\n", - "m=(p*math.pi*d**2)/(4*g)\n", - "print\"so m=\",round(m,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.9;page no:24" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.9, Page:24 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 9\n", - "balancing pressure at plane BC in figure we get\n", - "Psteam+Pwater=Patm+Pmercury\n", - "now 1.atmospheric pressure(Patm)in pa\n", - "Patm= 101396.16\n", - "2.pressure due to water(Pwater)in pa\n", - "Pwater= 196.2\n", - "3.pressure due to mercury(Pmercury)in pa\n", - "Pmercury=RHOm*g*h3 13341.6\n", - "using balancing equation\n", - "Psteam=Patm+Pmercury-Pwater\n", - "so pressure of steam(Psteam)in kpa\n", - "Psteam= 114.54\n" - ] - } - ], - "source": [ - "#cal of pressure due to atmosphere,water,mercury,steam\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.9, Page:24 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 9\")\n", - "RHOm=13.6*10**3;#density of mercury in kg/m^3\n", - "RHOw=1000;#density of water in kg/m^3\n", - "h1=76*10**-2;#barometer reading in m of mercury\n", - "h2=2*10**-2;#height raised by water in manometer tube in m \n", - "h3=10*10**-2;#height raised by mercury in manometer tube in m \n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "print(\"balancing pressure at plane BC in figure we get\")\n", - "print(\"Psteam+Pwater=Patm+Pmercury\")\n", - "print(\"now 1.atmospheric pressure(Patm)in pa\")\n", - "Patm=RHOm*g*h1\n", - "print(\"Patm=\"),round(Patm,2)\n", - "print(\"2.pressure due to water(Pwater)in pa\")\n", - "Pwater=RHOw*g*h2\n", - "print(\"Pwater=\"),round(Pwater,2)\n", - "print(\"3.pressure due to mercury(Pmercury)in pa\")\n", - "Pmercury=RHOm*g*h3\n", - "print(\"Pmercury=RHOm*g*h3\"),round(Pmercury,2)\n", - "print(\"using balancing equation\")\n", - "print(\"Psteam=Patm+Pmercury-Pwater\")\n", - "print(\"so pressure of steam(Psteam)in kpa\")\n", - "Psteam=(Patm+Pmercury-Pwater)/1000\n", - "print(\"Psteam=\"),round(Psteam,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.10;page no:24" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.10, Page:24 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 10\n", - "atmospheric pressure(Patm)in kpa\n", - "absolute temperature in compartment A(Pa) in kpa\n", - "Pa= 496.06\n", - "absolute temperature in compartment B(Pb) in kpa\n", - "Pb= 246.06\n", - "absolute pressure in compartments in A & B=496.06 kpa & 246.06 kpa\n" - ] - } - ], - "source": [ - "#cal of \"absolute temperature in compartment A,B\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.10, Page:24 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 10\")\n", - "h=720*10**-3;#barometer reading in m of Hg\n", - "Pga=400;#gauge pressure in compartment A in kpa\n", - "Pgb=150;#gauge pressure in compartment B in kpa\n", - "rho=13.6*10**3;#density of mercury in kg/m^3\n", - "g=9.81;#acceleration due to gravity in m/s^2\n", - "print(\"atmospheric pressure(Patm)in kpa\")\n", - "Patm=(rho*g*h)/1000\n", - "print(\"absolute temperature in compartment A(Pa) in kpa\")\n", - "Pa=Pga+Patm\n", - "print\"Pa=\",round(Pa,2)\n", - "print\"absolute temperature in compartment B(Pb) in kpa\"\n", - "Pb=Pgb+Patm\n", - "print\"Pb=\",round(Pb,2)\n", - "print\"absolute pressure in compartments in A & B=496.06 kpa & 246.06 kpa\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.11;page no:25" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.11, Page:25 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 11\n", - "the pressure of air in air tank can be obtained by equalising pressures at some reference line\n", - "P1+RHOw*g*h1+RHOo*g*h2 = Patm+RHOm*g*h3\n", - "so P1 = Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2\n", - "air pressure(P1)in kpa 139.81\n" - ] - } - ], - "source": [ - "#cal of air pressure\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.11, Page:25 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 11\")\n", - "Patm=90*10**3;#atmospheric pressure in pa\n", - "RHOw=1000;#density of water in kg/m^3\n", - "RHOm=13600;#density of mercury in kg/m^3\n", - "RHOo=850;#density of oil in kg/m^3\n", - "g=9.81;#acceleration due to ggravity in m/s^2\n", - "h1=.15;#height difference between water column in m\n", - "h2=.25;#height difference between oil column in m\n", - "h3=.4;#height difference between mercury column in m\n", - "print\"the pressure of air in air tank can be obtained by equalising pressures at some reference line\"\n", - "print\"P1+RHOw*g*h1+RHOo*g*h2 = Patm+RHOm*g*h3\"\n", - "print\"so P1 = Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2\"\n", - "P1=(Patm+RHOm*g*h3-RHOw*g*h1-RHOo*g*h2)/1000\n", - "print\"air pressure(P1)in kpa\",round(P1,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.12;page no:26" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.12, Page:26 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 12\n", - "mass of object(m)in kg\n", - "m=F/g\n", - "kinetic energy(E)in J is given by\n", - "E= 140625000.0\n" - ] - } - ], - "source": [ - "#cal of kinetic energy\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.12, Page:26 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 12\"\n", - "v=750;#relative velocity of object with respect to earth in m/sec\n", - "F=4000;#gravitational force in N\n", - "g=8;#acceleration due to gravity in m/s^2\n", - "print\"mass of object(m)in kg\"\n", - "print\"m=F/g\"\n", - "m=F/g\n", - "print\"kinetic energy(E)in J is given by\"\n", - "E=m*v**2/2\n", - "print\"E=\",round(E)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.13;page no:26" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.13, Page:26 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 13\n", - "characteristics gas constant(R2)in kJ/kg k\n", - "molecular weight of gas(m)in kg/kg mol= 16.63\n", - "NOTE=>Their is some calculation mistake while calaulating gas constant in book,which is corrected above hence answer may vary.\n" - ] - } - ], - "source": [ - "#cal of molecular weight of gas\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.13, Page:26 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 13\"\n", - "Cp=2.286;#specific heat at constant pressure in kJ/kg k\n", - "Cv=1.786;#specific heat at constant volume in kJ/kg k\n", - "R1=8.3143;#universal gas constant in kJ/kg k\n", - "print\"characteristics gas constant(R2)in kJ/kg k\"\n", - "R2=Cp-Cv\n", - "m=R1/R2\n", - "print\"molecular weight of gas(m)in kg/kg mol=\",round(m,2)\n", - "print\"NOTE=>Their is some calculation mistake while calaulating gas constant in book,which is corrected above hence answer may vary.\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.14;page no:26" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.14, Page:26 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 14\n", - "using perfect gas equation\n", - "P1*V1/T1 = P2*V2/T2\n", - "=>T2=(P2*V2*T1)/(P1*V1)\n", - "so final temperature of gas(T2)in k\n", - "or final temperature of gas(T2)in degree celcius= 127.0\n" - ] - } - ], - "source": [ - "#cal of final temperature of gas\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.14, Page:26 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 14\"\n", - "P1=750*10**3;#initial pressure of gas in pa\n", - "V1=0.2;#initial volume of gas in m^3\n", - "T1=600;#initial temperature of gas in k\n", - "P2=2*10**5;#final pressure of gas i pa\n", - "V2=0.5;#final volume of gas in m^3\n", - "print\"using perfect gas equation\"\n", - "print\"P1*V1/T1 = P2*V2/T2\"\n", - "print\"=>T2=(P2*V2*T1)/(P1*V1)\"\n", - "print\"so final temperature of gas(T2)in k\"\n", - "T2=(P2*V2*T1)/(P1*V1)\n", - "T2=T2-273\n", - "print\"or final temperature of gas(T2)in degree celcius=\",round(T2,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.15;page no:27" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.15, Page:27 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 15\n", - "from perfect gas equation we get\n", - "initial mass of air(m1 in kg)=(P1*V1)/(R*T1)\n", - "m1= 5.807\n", - "final mass of air(m2 in kg)=(P2*V2)/(R*T2)\n", - "m2= 3.111\n", - "mass of air removed(m)in kg 2.696\n", - "volume of this mass of air(V) at initial states in m^3= 2.32\n" - ] - } - ], - "source": [ - "#cal of volume of this mass of air(V) at initial states\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.15, Page:27 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 15\"\n", - "P1=100*10**3;#initial pressure of air in pa\n", - "V1=5.;#initial volume of air in m^3\n", - "T1=300.;#initial temperature of gas in k\n", - "P2=50*10**3;#final pressure of air in pa\n", - "V2=5.;#final volume of air in m^3\n", - "T2=(280.);#final temperature of air in K\n", - "R=287.;#gas constant on J/kg k\n", - "print\"from perfect gas equation we get\"\n", - "print\"initial mass of air(m1 in kg)=(P1*V1)/(R*T1)\"\n", - "m1=(P1*V1)/(R*T1)\n", - "print(\"m1=\"),round(m1,3)\n", - "print\"final mass of air(m2 in kg)=(P2*V2)/(R*T2)\"\n", - "m2=(P2*V2)/(R*T2)\n", - "print(\"m2=\"),round(m2,3)\n", - "m=m1-m2\n", - "print\"mass of air removed(m)in kg\",round(m,3)\n", - "V=m*R*T1/P1\n", - "print\"volume of this mass of air(V) at initial states in m^3=\",round(V,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.16;page no:27" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.16, Page:27 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 16\n", - "here V1=V2\n", - "so P1/T1=P2/T2\n", - "final temperature of hydrogen gas(T2)in k\n", - "=>T2=P2*T1/P1\n", - "now R=(Cp-Cv) in KJ/kg k\n", - "And volume of cylinder(V1)in m^3\n", - "V1=(math.pi*d^2*l)/4\n", - "mass of hydrogen gas(m)in kg\n", - "m= 0.254\n", - "now heat supplied(Q)in KJ\n", - "Q= 193.93\n" - ] - } - ], - "source": [ - "#cal of heat supplied\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "import math\n", - "print\"Example 1.16, Page:27 \\n \\n\"\n", - "print\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 16\"\n", - "d=1;#diameter of cylinder in m\n", - "l=4;#length of cylinder in m\n", - "P1=100*10**3;#initial pressureof hydrogen gas in pa\n", - "T1=(27+273);#initial temperature of hydrogen gas in k\n", - "P2=125*10**3;#final pressureof hydrogen gas in pa\n", - "Cp=14.307;#specific heat at constant pressure in KJ/kg k\n", - "Cv=10.183;#specific heat at constant volume in KJ/kg k\n", - "print\"here V1=V2\"\n", - "print\"so P1/T1=P2/T2\"\n", - "print\"final temperature of hydrogen gas(T2)in k\"\n", - "print\"=>T2=P2*T1/P1\"\n", - "T2=P2*T1/P1\n", - "print\"now R=(Cp-Cv) in KJ/kg k\"\n", - "R=Cp-Cv\n", - "print\"And volume of cylinder(V1)in m^3\"\n", - "print\"V1=(math.pi*d^2*l)/4\"\n", - "V1=(math.pi*d**2*l)/4\n", - "print\"mass of hydrogen gas(m)in kg\"\n", - "m=(P1*V1)/(1000*R*T1)\n", - "print\"m=\",round(m,3)\n", - "print\"now heat supplied(Q)in KJ\"\n", - "Q=m*Cv*(T2-T1)\n", - "print\"Q=\",round(Q,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.17;page no:28" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.17, Page:28 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 17\n", - "final total volume(V)in m^3\n", - "V=V1*V2\n", - "total mass of air(m)in kg\n", - "m=m1+m2\n", - "final pressure of air(P)in kpa\n", - "using perfect gas equation\n", - "P= 516.6\n" - ] - } - ], - "source": [ - "#cal of final pressure\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.17, Page:28 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 17\")\n", - "V1=2.;#volume of first cylinder in m^3\n", - "V2=2.;#volume of second cylinder in m^3\n", - "T=(27+273);#temperature of system in k\n", - "m1=20.;#mass of air in first vessel in kg\n", - "m2=4.;#mass of air in second vessel in kg\n", - "R=287.;#gas constant J/kg k\n", - "print(\"final total volume(V)in m^3\")\n", - "print(\"V=V1*V2\")\n", - "V=V1*V2\n", - "print(\"total mass of air(m)in kg\")\n", - "print(\"m=m1+m2\")\n", - "m=m1+m2\n", - "print(\"final pressure of air(P)in kpa\")\n", - "print(\"using perfect gas equation\")\n", - "P=(m*R*T)/(1000*V)\n", - "print\"P=\",round(P,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.18;page no:28" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.18, Page:28 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 18\n", - "1.By considering it as a PERFECT GAS\n", - "gas constant for CO2(Rco2)\n", - "Rco2=(J/Kg.k) 188.9\n", - "Also P*V=M*Rco2*T\n", - "pressure of CO2 as perfect gas(P)in N/m^2\n", - "P=(m*Rco2*T)/V 141683.71\n", - "2.By considering as a REAL GAS\n", - "values of vanderwaal constants a,b can be seen from the table which are\n", - "a=(N m^4/(kg mol)^2) 362850.0\n", - "b=(m^3/kg mol) 0.03\n", - "now specific volume(v)in m^3/kg mol\n", - "v= 17.604\n", - "now substituting the value of all variables in vanderwaal equation\n", - "(P+(a/v^2))*(v-b)=R*T\n", - "pressure of CO2 as real gas(P)in N/m^2\n", - "P= 140766.02\n" - ] - } - ], - "source": [ - "#cal of pressure of CO2 as perfect,real gas\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.18, Page:28 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 18\")\n", - "m=5;#mass of CO2 in kg\n", - "V=2;#volume of vesssel in m^3\n", - "T=(27+273);#temperature of vessel in k\n", - "R=8.314*10**3;#universal gas constant in J/kg k\n", - "M=44.01;#molecular weight of CO2 \n", - "print(\"1.By considering it as a PERFECT GAS\")\n", - "print(\"gas constant for CO2(Rco2)\")\n", - "Rco2=R/M\n", - "print(\"Rco2=(J/Kg.k)\"),round(Rco2,1)\n", - "print(\"Also P*V=M*Rco2*T\")\n", - "print(\"pressure of CO2 as perfect gas(P)in N/m^2\")\n", - "P=(m*Rco2*T)/V\n", - "print(\"P=(m*Rco2*T)/V \"),round(P,2)\n", - "print(\"2.By considering as a REAL GAS\")\n", - "print(\"values of vanderwaal constants a,b can be seen from the table which are\")\n", - "a=3628.5*10**2#vanderwall constant in N m^4/(kg mol)^2\n", - "b=3.14*10**-2# vanderwall constant in m^3/kg mol\n", - "print(\"a=(N m^4/(kg mol)^2) \"),round(a,2)\n", - "print(\"b=(m^3/kg mol)\"),round(b,2)\n", - "print(\"now specific volume(v)in m^3/kg mol\")\n", - "v=V*M/m\n", - "print(\"v=\"),round(v,3)\n", - "print(\"now substituting the value of all variables in vanderwaal equation\")\n", - "print(\"(P+(a/v^2))*(v-b)=R*T\")\n", - "print(\"pressure of CO2 as real gas(P)in N/m^2\")\n", - "P=((R*T)/(v-b))-(a/v**2)\n", - "print(\"P=\"),round(P,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.19;page no:29" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.19, Page:29 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 19\n", - "1.considering as perfect gas\n", - "specific volume(V)in m^3/kg\n", - "V= 0.0186\n", - "2.considering compressibility effects\n", - "reduced pressure(P)in pa\n", - "p= 0.8\n", - "reduced temperature(t)in k\n", - "t= 1.1\n", - "from generalised compressibility chart,compressibility factor(Z)can be seen for reduced pressure and reduced temperatures of 0.8 and 1.1\n", - "we get Z=0.785\n", - "now actual specific volume(v)in m^3/kg\n", - "v= 0.0146\n" - ] - } - ], - "source": [ - "#cal of specific volume of steam\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.19, Page:29 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 19\")\n", - "P=17672;#pressure of steam on kpa\n", - "T=712;#temperature of steam in k\n", - "Pc=22.09;#critical pressure of steam in Mpa\n", - "Tc=647.3;#critical temperature of steam in k\n", - "R=0.4615;#gas constant for steam in KJ/kg k\n", - "print(\"1.considering as perfect gas\")\n", - "print(\"specific volume(V)in m^3/kg\")\n", - "V=R*T/P\n", - "print(\"V=\"),round(V,4)\n", - "print(\"2.considering compressibility effects\")\n", - "print(\"reduced pressure(P)in pa\")\n", - "p=P/(Pc*1000)\n", - "print(\"p=\"),round(p,2)\n", - "print(\"reduced temperature(t)in k\")\n", - "t=T/Tc\n", - "print(\"t=\"),round(t,2)\n", - "print(\"from generalised compressibility chart,compressibility factor(Z)can be seen for reduced pressure and reduced temperatures of 0.8 and 1.1\")\n", - "print(\"we get Z=0.785\")\n", - "Z=0.785;#compressibility factor\n", - "print(\"now actual specific volume(v)in m^3/kg\")\n", - "v=Z*V\n", - "print(\"v=\"),round(v,4)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.20;page no:30" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.20, Page:30 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 20\n", - "volume of ballon(V1)in m^3\n", - "V1= 65.45\n", - "molecular mass of hydrogen(M)\n", - "M=2\n", - "gas constant for H2(R1)in J/kg k\n", - "R1= 4157.0\n", - "mass of H2 in ballon(m1)in kg\n", - "m1= 5.316\n", - "volume of air printlaced(V2)=volume of ballon(V1)\n", - "mass of air printlaced(m2)in kg\n", - "m2= 79.66\n", - "gas constant for air(R2)=0.287 KJ/kg k\n", - "load lifting capacity due to buoyant force(m)in kg\n", - "m= 74.343\n" - ] - } - ], - "source": [ - "#estimation of maximum load that can be lifted \n", - "#intiation of all variables\n", - "# Chapter 1\n", - "import math\n", - "print\"Example 1.20, Page:30 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 20\")\n", - "d=5.;#diameter of ballon in m\n", - "T1=(27.+273.);#temperature of hydrogen in k\n", - "P=1.013*10**5;#atmospheric pressure in pa\n", - "T2=(17.+273.);#temperature of surrounding air in k\n", - "R=8.314*10**3;#gas constant in J/kg k\n", - "print(\"volume of ballon(V1)in m^3\")\n", - "V1=(4./3.)*math.pi*((d/2)**3)\n", - "print(\"V1=\"),round(V1,2)\n", - "print(\"molecular mass of hydrogen(M)\")\n", - "print(\"M=2\")\n", - "M=2;#molecular mass of hydrogen\n", - "print(\"gas constant for H2(R1)in J/kg k\")\n", - "R1=R/M\n", - "print(\"R1=\"),round(R1,2)\n", - "print(\"mass of H2 in ballon(m1)in kg\")\n", - "m1=(P*V1)/(R1*T1)\n", - "print(\"m1=\"),round(m1,3)\n", - "print(\"volume of air printlaced(V2)=volume of ballon(V1)\")\n", - "print(\"mass of air printlaced(m2)in kg\")\n", - "R2=0.287*1000;#gas constant for air in J/kg k\n", - "m2=(P*V1)/(R2*T2)\n", - "print(\"m2=\"),round(m2,2)\n", - "print(\"gas constant for air(R2)=0.287 KJ/kg k\")\n", - "print(\"load lifting capacity due to buoyant force(m)in kg\")\n", - "m=m2-m1\n", - "print(\"m=\"),round(m,3)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.21;page no:31" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.21, Page:31 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 21\n", - "let initial receiver pressure(p1)=1 in pa\n", - "so final receiver pressure(p2)=in pa 0.25\n", - "perfect gas equation,p*V*m=m*R*T\n", - "differentiating and then integrating equation w.r.t to time(t) \n", - "we get t=-(V/v)*log(p2/p1)\n", - "so time(t)in min 110.9\n" - ] - } - ], - "source": [ - "#cal of time required\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "import math\n", - "print\"Example 1.21, Page:31 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 21\")\n", - "v=0.25;#volume sucking rate of pump in m^3/min\n", - "V=20.;#volume of air vessel in m^3\n", - "p1=1.;#initial receiver pressure in pa\n", - "print(\"let initial receiver pressure(p1)=1 in pa\")\n", - "p2=p1/4.\n", - "print(\"so final receiver pressure(p2)=in pa\"),round(p2,2)\n", - "print(\"perfect gas equation,p*V*m=m*R*T\")\n", - "print(\"differentiating and then integrating equation w.r.t to time(t) \")\n", - "print(\"we get t=-(V/v)*log(p2/p1)\")\n", - "t=-(V/v)*math.log(p2/p1)\n", - "print(\"so time(t)in min\"),round(t,2)\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.22;page no:32" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.22, Page:32 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 22\n", - "first calculate gas constants for different gases in j/kg k\n", - "for nitrogen,R1= 296.9\n", - "for oxygen,R2= 259.8\n", - "for carbon dioxide,R3= 188.95\n", - "so the gas constant for mixture(Rm)in j/kg k\n", - "Rm= 288.09\n", - "now the specific heat at constant pressure for constituent gases in KJ/kg k\n", - "for nitrogen,Cp1= 1.039\n", - "for oxygen,Cp2= 0.909\n", - "for carbon dioxide,Cp3= 0.819\n", - "so the specific heat at constant pressure for mixture(Cpm)in KJ/kg k\n", - "Cpm= 1.0115\n", - "now no. of moles of constituents gases\n", - "for nitrogen,n1=m1/M1 in mol,where m1=f1*m in kg 0.143\n", - "for oxygen,n2=m2/M2 in mol,where m2=f2*m in kg 0.028\n", - "for carbon dioxide,n3=m3/M3 in mol,where m3=f3*m in kg 0.0023\n", - "total no. of moles in mixture in mol\n", - "n= 0.1733\n", - "now mole fraction of constituent gases\n", - "for nitrogen,x1= 0.825\n", - "for oxygen,x2= 0.162\n", - "for carbon dioxide,x3= 0.0131\n", - "now the molecular weight of mixture(Mm)in kg/kmol\n", - "Mm= 28.86\n" - ] - } - ], - "source": [ - "#cal of specific heat at constant pressure for constituent gases \n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.22, Page:32 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 22\")\n", - "m=5;#mass of mixture of gas in kg\n", - "P=1.013*10**5;#pressure of mixture in pa\n", - "T=300;#temperature of mixture in k\n", - "M1=28.;#molecular weight of nitrogen(N2)\n", - "M2=32.;#molecular weight of oxygen(O2)\n", - "M3=44.;#molecular weight of carbon dioxide(CO2)\n", - "f1=0.80;#fraction of N2 in mixture\n", - "f2=0.18;#fraction of O2 in mixture\n", - "f3=0.02;#fraction of CO2 in mixture\n", - "k1=1.4;#ratio of specific heat capacities for N2\n", - "k2=1.4;#ratio of specific heat capacities for O2\n", - "k3=1.3;#ratio of specific heat capacities for CO2\n", - "R=8314;#universal gas constant in J/kg k\n", - "print(\"first calculate gas constants for different gases in j/kg k\")\n", - "R1=R/M1\n", - "print(\"for nitrogen,R1=\"),round(R1,1)\n", - "R2=R/M2\n", - "print(\"for oxygen,R2=\"),round(R2,1)\n", - "R3=R/M3\n", - "print(\"for carbon dioxide,R3=\"),round(R3,2)\n", - "print(\"so the gas constant for mixture(Rm)in j/kg k\")\n", - "Rm=f1*R1+f2*R2+f3*R3\n", - "print(\"Rm=\"),round(Rm,2)\n", - "print(\"now the specific heat at constant pressure for constituent gases in KJ/kg k\")\n", - "Cp1=((k1/(k1-1))*R1)/1000\n", - "print(\"for nitrogen,Cp1=\"),round(Cp1,3)\n", - "Cp2=((k2/(k2-1))*R2)/1000\n", - "print(\"for oxygen,Cp2=\"),round(Cp2,3)\n", - "Cp3=((k3/(k3-1))*R3)/1000\n", - "print(\"for carbon dioxide,Cp3=\"),round(Cp3,3)\n", - "print(\"so the specific heat at constant pressure for mixture(Cpm)in KJ/kg k\")\n", - "Cpm=f1*Cp1+f2*Cp2+f3*Cp3\n", - "print(\"Cpm=\"),round(Cpm,4)\n", - "print(\"now no. of moles of constituents gases\")\n", - "m1=f1*m\n", - "n1=m1/M1\n", - "print(\"for nitrogen,n1=m1/M1 in mol,where m1=f1*m in kg\"),round(n1,3)\n", - "m2=f2*m\n", - "n2=m2/M2\n", - "print(\"for oxygen,n2=m2/M2 in mol,where m2=f2*m in kg\"),round(n2,3)\n", - "m3=f3*m\n", - "n3=m3/M3\n", - "print(\"for carbon dioxide,n3=m3/M3 in mol,where m3=f3*m in kg\"),round(n3,4)\n", - "print(\"total no. of moles in mixture in mol\")\n", - "n=n1+n2+n3\n", - "print(\"n=\"),round(n,4)\n", - "print(\"now mole fraction of constituent gases\")\n", - "x1=n1/n\n", - "print(\"for nitrogen,x1=\"),round(x1,3)\n", - "x2=n2/n\n", - "print(\"for oxygen,x2=\"),round(x2,3)\n", - "x3=n3/n\n", - "print(\"for carbon dioxide,x3=\"),round(x3,4)\n", - "print(\"now the molecular weight of mixture(Mm)in kg/kmol\")\n", - "Mm=M1*x1+M2*x2+M3*x3\n", - "print(\"Mm=\"),round(Mm,2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.23;page no:33" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.23, Page:33 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 23\n", - "mole fraction of constituent gases\n", - "x=(ni/n)=(Vi/V)\n", - "take volume of mixture(V)=1 m^3\n", - "mole fraction of O2(x1)\n", - "x1= 0.18\n", - "mole fraction of N2(x2)\n", - "x2= 0.75\n", - "mole fraction of CO2(x3)\n", - "x3= 0.07\n", - "now molecular weight of mixture = molar mass(m)\n", - "m= 29.84\n", - "now gravimetric analysis refers to the mass fraction analysis\n", - "mass fraction of constituents\n", - "y=xi*Mi/m\n", - "mole fraction of O2\n", - "y1= 0.193\n", - "mole fraction of N2\n", - "y2= 0.704\n", - "mole fraction of CO2\n", - "y3= 0.103\n", - "now partial pressure of constituents = volume fraction * pressure of mixture\n", - "Pi=xi*P\n", - "partial pressure of O2(P1)in Mpa\n", - "P1= 0.09\n", - "partial pressure of N2(P2)in Mpa\n", - "P2= 0.375\n", - "partial pressure of CO2(P3)in Mpa\n", - "P3= 0.04\n", - "NOTE=>Their is some calculation mistake for partial pressure of CO2(i.e 0.35Mpa)which is given wrong in book so it is corrected above hence answers may vary.\n" - ] - } - ], - "source": [ - "#cal of pressure difference\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.23, Page:33 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 23\")\n", - "V1=0.18;#volume fraction of O2 in m^3\n", - "V2=0.75;#volume fraction of N2 in m^3\n", - "V3=0.07;#volume fraction of CO2 in m^3\n", - "P=0.5;#pressure of mixture in Mpa\n", - "T=(107+273);#temperature of mixture in k\n", - "M1=32;#molar mass of O2\n", - "M2=28;#molar mass of N2\n", - "M3=44;#molar mass of CO2\n", - "print(\"mole fraction of constituent gases\")\n", - "print(\"x=(ni/n)=(Vi/V)\")\n", - "V=1;# volume of mixture in m^3\n", - "print(\"take volume of mixture(V)=1 m^3\")\n", - "print(\"mole fraction of O2(x1)\")\n", - "x1=V1/V\n", - "print(\"x1=\"),round(x1,2)\n", - "print(\"mole fraction of N2(x2)\")\n", - "x2=V2/V\n", - "print(\"x2=\"),round(x2,2)\n", - "print(\"mole fraction of CO2(x3)\")\n", - "x3=V3/V\n", - "print(\"x3=\"),round(x3,2)\n", - "print(\"now molecular weight of mixture = molar mass(m)\")\n", - "m=x1*M1+x2*M2+x3*M3\n", - "print(\"m=\"),round(m,2)\n", - "print(\"now gravimetric analysis refers to the mass fraction analysis\")\n", - "print(\"mass fraction of constituents\")\n", - "print(\"y=xi*Mi/m\")\n", - "print(\"mole fraction of O2\")\n", - "y1=x1*M1/m\n", - "print(\"y1=\"),round(y1,3)\n", - "print(\"mole fraction of N2\")\n", - "y2=x2*M2/m\n", - "print(\"y2=\"),round(y2,3)\n", - "print(\"mole fraction of CO2\")\n", - "y3=x3*M3/m\n", - "print(\"y3=\"),round(y3,3)\n", - "print(\"now partial pressure of constituents = volume fraction * pressure of mixture\")\n", - "print(\"Pi=xi*P\")\n", - "print(\"partial pressure of O2(P1)in Mpa\")\n", - "p1=x1*P\n", - "print(\"P1=\"),round(p1,2)\n", - "print(\"partial pressure of N2(P2)in Mpa\")\n", - "P2=x2*P\n", - "print(\"P2=\"),round(P2,3)\n", - "P3=x3*P\n", - "print(\"partial pressure of CO2(P3)in Mpa\")\n", - "print(\"P3=\"),round(P3,2)\n", - "print(\"NOTE=>Their is some calculation mistake for partial pressure of CO2(i.e 0.35Mpa)which is given wrong in book so it is corrected above hence answers may vary.\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.24;page no:34" - ] - }, - { - "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.24, Page:34 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 24\n", - "volume of tank of N2(V1) in m^3= 3.0\n", - "volume of tank of CO2(V2) in m^3= 3.0\n", - "taking the adiabatic condition\n", - "no. of moles of N2(n1)\n", - "n1= 0.6\n", - "no. of moles of CO2(n2)\n", - "n2= 0.37\n", - "total no. of moles of mixture(n)in mol\n", - "n= 0.97\n", - "gas constant for N2(R1)in J/kg k\n", - "R1= 296.93\n", - "gas constant for CO2(R2)in J/kg k\n", - "R2=R/M2 188.95\n", - "specific heat of N2 at constant volume (Cv1) in J/kg k\n", - "Cv1= 742.32\n", - "specific heat of CO2 at constant volume (Cv2) in J/kg k\n", - "Cv2= 629.85\n", - "mass of N2(m1)in kg\n", - "m1= 16.84\n", - "mass of CO2(m2)in kg\n", - "m2= 16.28\n", - "let us consider the equilibrium temperature of mixture after adiabatic mixing at T\n", - "applying energy conservation principle\n", - "m1*Cv1*(T-T1) = m2*Cv2*(T-T2)\n", - "equlibrium temperature(T)in k\n", - "=>T= 439.44\n", - "so the equlibrium pressure(P)in kpa\n", - "P= 591.55\n" - ] - } - ], - "source": [ - "#cal of equilibrium temperature,pressure of mixture\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.24, Page:34 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 24\")\n", - "V=6;#volume of tank in m^3\n", - "P1=800*10**3;#pressure of N2 gas tank in pa\n", - "T1=480.;#temperature of N2 gas tank in k\n", - "P2=400*10**3;#pressure of CO2 gas tank in pa\n", - "T2=390.;#temperature of CO2 gas tank in k\n", - "k1=1.4;#ratio of specific heat capacity for N2\n", - "k2=1.3;#ratio of specific heat capacity for CO2\n", - "R=8314.;#universal gas constant in J/kg k\n", - "M1=28.;#molecular weight of N2\n", - "M2=44.;#molecular weight of CO2\n", - "V1=V/2\n", - "print(\"volume of tank of N2(V1) in m^3=\"),round(V1,2)\n", - "V2=V/2\n", - "print(\"volume of tank of CO2(V2) in m^3=\"),round(V2,2)\n", - "print(\"taking the adiabatic condition\")\n", - "print(\"no. of moles of N2(n1)\")\n", - "n1=(P1*V1)/(R*T1)\n", - "print(\"n1=\"),round(n1,2)\n", - "print(\"no. of moles of CO2(n2)\")\n", - "n2=(P2*V2)/(R*T2)\n", - "print(\"n2=\"),round(n2,2)\n", - "print(\"total no. of moles of mixture(n)in mol\")\n", - "n=n1+n2\n", - "print(\"n=\"),round(n,2)\n", - "print(\"gas constant for N2(R1)in J/kg k\")\n", - "R1=R/M1\n", - "print(\"R1=\"),round(R1,2)\n", - "print(\"gas constant for CO2(R2)in J/kg k\")\n", - "R2=R/M2\n", - "print(\"R2=R/M2\"),round(R2,2)\n", - "print(\"specific heat of N2 at constant volume (Cv1) in J/kg k\")\n", - "Cv1=R1/(k1-1)\n", - "print(\"Cv1=\"),round(Cv1,2)\n", - "print(\"specific heat of CO2 at constant volume (Cv2) in J/kg k\")\n", - "Cv2=R2/(k2-1)\n", - "print(\"Cv2=\"),round(Cv2,2)\n", - "print(\"mass of N2(m1)in kg\")\n", - "m1=n1*M1\n", - "print(\"m1=\"),round(m1,2)\n", - "print(\"mass of CO2(m2)in kg\")\n", - "m2=n2*M2\n", - "print(\"m2=\"),round(m2,2)\n", - "print(\"let us consider the equilibrium temperature of mixture after adiabatic mixing at T\")\n", - "print(\"applying energy conservation principle\")\n", - "print(\"m1*Cv1*(T-T1) = m2*Cv2*(T-T2)\")\n", - "print(\"equlibrium temperature(T)in k\")\n", - "T=((m1*Cv1*T1)+(m2*Cv2*T2))/((m1*Cv1)+(m2*Cv2))\n", - "print(\"=>T=\"),round(T,2)\n", - "print(\"so the equlibrium pressure(P)in kpa\")\n", - "P=(n*R*T)/(1000*V)\n", - "print(\"P=\"),round(P,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.25;page no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.25, Page:35 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 25\n", - "since two gases are non reacting therefore specific heat of final mixture(Cp)in KJ/kg k can be obtained by following for adiabatic mixing\n", - "so the specific heat at constant pressure(Cp)in KJ/kg k\n", - "Cp= 7.608\n" - ] - } - ], - "source": [ - "#cal of specific heat of final mixture\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.25, Page:35 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 25\")\n", - "m1=2;#mass of H2 in kg\n", - "m2=3;#mass of He in kg\n", - "T=100;#temperature of container in k\n", - "Cp1=11.23;#specific heat at constant pressure for H2 in KJ/kg k\n", - "Cp2=5.193;#specific heat at constant pressure for He in KJ/kg k\n", - "print(\"since two gases are non reacting therefore specific heat of final mixture(Cp)in KJ/kg k can be obtained by following for adiabatic mixing\")\n", - "print(\"so the specific heat at constant pressure(Cp)in KJ/kg k\")\n", - "Cp=((Cp1*m1)+Cp2*m2)/(m1+m2)\n", - "print(\"Cp=\"),round(Cp,3)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.26;page no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.26, Page:35 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 26\n", - "gas constant for H2(R1)in KJ/kg k\n", - "R1= 4.157\n", - "gas constant for N2(R2)in KJ/kg k\n", - "R2= 0.297\n", - "gas constant for CO2(R3)in KJ/kg k\n", - "R3= 0.189\n", - "so now gas constant for mixture(Rm)in KJ/kg k\n", - "Rm= 2.606\n", - "considering gas to be perfect gas\n", - "total mass of mixture(m)in kg\n", - "m= 30.0\n", - "capacity of vessel(V)in m^3\n", - "V= 231.57\n", - "now final temperature(Tf) is twice of initial temperature(Ti)\n", - "so take k=Tf/Ti=2\n", - "for constant volume heating,final pressure(Pf)in kpa shall be\n", - "Pf= 202.65\n" - ] - } - ], - "source": [ - "#cal of capacity and pressure in the vessel\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.26, Page:35 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 26\")\n", - "m1=18.;#mass of hydrogen(H2) in kg\n", - "m2=10.;#mass of nitrogen(N2) in kg\n", - "m3=2.;#mass of carbon dioxide(CO2) in kg\n", - "R=8.314;#universal gas constant in KJ/kg k\n", - "Pi=101.325;#atmospheric pressure in kpa\n", - "T=(27+273.15);#ambient temperature in k\n", - "M1=2;#molar mass of H2\n", - "M2=28;#molar mass of N2\n", - "M3=44;#molar mass of CO2\n", - "print(\"gas constant for H2(R1)in KJ/kg k\")\n", - "R1=R/M1\n", - "print(\"R1=\"),round(R1,3)\n", - "print(\"gas constant for N2(R2)in KJ/kg k\")\n", - "R2=R/M2\n", - "print(\"R2=\"),round(R2,3)\n", - "print(\"gas constant for CO2(R3)in KJ/kg k\")\n", - "R3=R/M3\n", - "print(\"R3=\"),round(R3,3)\n", - "print(\"so now gas constant for mixture(Rm)in KJ/kg k\")\n", - "Rm=(m1*R1+m2*R2+m3*R3)/(m1+m2+m3)\n", - "print(\"Rm=\"),round(Rm,3)\n", - "print(\"considering gas to be perfect gas\")\n", - "print(\"total mass of mixture(m)in kg\")\n", - "m=m1+m2+m3\n", - "print(\"m=\"),round(m,2)\n", - "print(\"capacity of vessel(V)in m^3\")\n", - "V=(m*Rm*T)/Pi\n", - "print(\"V=\"),round(V,2)\n", - "print(\"now final temperature(Tf) is twice of initial temperature(Ti)\")\n", - "k=2;#ratio of initial to final temperature\n", - "print(\"so take k=Tf/Ti=2\") \n", - "print(\"for constant volume heating,final pressure(Pf)in kpa shall be\")\n", - "Pf=Pi*k\n", - "print(\"Pf=\"),round(Pf,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.27;page no:36" - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.27, Page:36 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 27\n", - "let inlet state be 1 and exit state be 2\n", - "by charles law volume and temperature can be related as\n", - "(V1/T1)=(V2/T2)\n", - "(V2/V1)=(T2/T1)\n", - "or (((math.pi*D2^2)/4)*V2)/(((math.pi*D1^2)/4)*V1)=T2/T1\n", - "since change in K.E=0\n", - "so (D2^2/D1^2)=T2/T1\n", - "D2/D1=sqrt(T2/T1)\n", - "say(D2/D1)=k\n", - "so exit to inlet diameter ratio(k) 1.29\n" - ] - } - ], - "source": [ - "#cal of exit to inlet diameter ratio\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "import math\n", - "print\"Example 1.27, Page:36 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 27\")\n", - "T1=(27.+273.);#initial temperature of air in k\n", - "T2=500.;#final temperature of air in k\n", - "print(\"let inlet state be 1 and exit state be 2\")\n", - "print(\"by charles law volume and temperature can be related as\")\n", - "print(\"(V1/T1)=(V2/T2)\")\n", - "print(\"(V2/V1)=(T2/T1)\")\n", - "print(\"or (((math.pi*D2^2)/4)*V2)/(((math.pi*D1^2)/4)*V1)=T2/T1\")\n", - "print(\"since change in K.E=0\")\n", - "print(\"so (D2^2/D1^2)=T2/T1\")\n", - "print(\"D2/D1=sqrt(T2/T1)\")\n", - "print(\"say(D2/D1)=k\")\n", - "k=math.sqrt(T2/T1)\n", - "print(\"so exit to inlet diameter ratio(k)\"),round(k,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.28;page no:37" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.28, Page:37 \n", - " \n", - "\n", - "Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 28\n", - "gas constant for H2(R1)in KJ/kg k\n", - "R1= 4.157\n", - "say initial and final ststes are given by 1 and 2\n", - "mass of hydrogen pumped out shall be difference of initial and final mass inside vessel\n", - "final pressure of hydrogen(P2)in cm of Hg\n", - "P2= 6.0\n", - "therefore pressure difference(P)in kpa\n", - "P= 93.33\n", - "mass pumped out(m)in kg\n", - "m=((P1*V1)/(R1*T1))-((P2*V2)/(R1*T2))\n", - "here V1=V2=V and T1=T2=T\n", - "so m= 0.15\n", - "now during cooling upto 10 degree celcius,the process may be consider as constant volume process\n", - "say state before and after cooling are denoted by suffix 2 and 3\n", - "final pressure after cooling(P3)in kpa\n", - "P3= 7.546\n" - ] - } - ], - "source": [ - "#cal of final pressure\n", - "#intiation of all variables\n", - "# Chapter 1\n", - "print\"Example 1.28, Page:37 \\n \\n\"\n", - "print(\"Engineering Thermodynamics by Onkar Singh,Chapter 1,Example 28\")\n", - "V=2;#volume of vessel in m^3\n", - "P1=76;#initial pressure or atmospheric pressure in cm of Hg\n", - "T=(27+273.15);#temperature of vessel in k\n", - "p=70;#final pressure in cm of Hg vaccum\n", - "R=8.314;#universal gas constant in KJ/kg k\n", - "M=2;#molecular weight of H2\n", - "print(\"gas constant for H2(R1)in KJ/kg k\")\n", - "R1=R/M\n", - "print(\"R1=\"),round(R1,3)\n", - "print(\"say initial and final ststes are given by 1 and 2\")\n", - "print(\"mass of hydrogen pumped out shall be difference of initial and final mass inside vessel\")\n", - "print(\"final pressure of hydrogen(P2)in cm of Hg\")\n", - "P2=P1-p\n", - "print(\"P2=\"),round(P2,2)\n", - "print(\"therefore pressure difference(P)in kpa\")\n", - "P=((P1-P2)*101.325)/76\n", - "print(\"P=\"),round(P,2)\n", - "print(\"mass pumped out(m)in kg\")\n", - "print(\"m=((P1*V1)/(R1*T1))-((P2*V2)/(R1*T2))\")\n", - "print(\"here V1=V2=V and T1=T2=T\")\n", - "m=(V*P)/(R1*T)\n", - "print(\"so m=\"),round(m,2)\n", - "print(\"now during cooling upto 10 degree celcius,the process may be consider as constant volume process\")\n", - "print(\"say state before and after cooling are denoted by suffix 2 and 3\")\n", - "T3=(10+273.15);#final temperature after cooling in k\n", - "print(\"final pressure after cooling(P3)in kpa\")\n", - "P3=(T3/T)*P2*(101.325/76)\n", - "print(\"P3=\"),round(P3,3)\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SakshiGoplani/SakshiGoplani_version_backup/Sample.ipynb b/sample_notebooks/SakshiGoplani/SakshiGoplani_version_backup/Sample.ipynb new file mode 100755 index 00000000..108f20cf --- /dev/null +++ b/sample_notebooks/SakshiGoplani/SakshiGoplani_version_backup/Sample.ipynb @@ -0,0 +1,662 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:b8d3bc6c59d0efdfca4aa426416ba1f24e3078d69f0411d3e3ed7b293bd81c78" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "ELEMENTS OF MECHANICAL ENGINEERING by R.K. RAJPUT" + ] + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 2 : FUELS AND COMBUSTION" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " #DATA GIVEN\n", + "c=88; #% of carbon in coal\n", + "h=4.2; #% of hydrogen in coal\n", + "Wf=0.848; #weight of coal in g\n", + "Wfw=0.027; #weight of fuse wire in calorimeter in g\n", + "W=1950; #weight of water in calorimeter in g\n", + "We=380; #water equivalent of calorimeter\n", + "Dt=3.06; #observed temperature rise (t2-t1) in deg celsius\n", + "tc=0.017; #cooling correction in deg celsius\n", + "cfw=6700; #calorific value of fuse wire in J/g\n", + "\n", + " #CALCULATIONS\n", + "ctr=(Dt)+tc; #corrected temp. rise\n", + "Hw=(W+We)*4.18*(ctr); #heat recieved by water in J\n", + "Hfw=Wfw*cfw; #heat given out by fuse wire in J\n", + "Hcf=Hw-Hfw; #heat produced due to combustion of fuel in J\n", + "HCV=Hcf/Wf; #higher calorific value of fuel in kJ/kg\n", + "Ms=9*h/100; #steam produced per kg of coal\n", + "LCV=HCV-2465*Ms; #lower calorific value of fuel in kJ/kg\n", + "\n", + "print \"The Higher calorific value of fuel, H.C.V. is: \",round(HCV,4),\" kJ/kg.\"\n", + "print \"The Lower calorific value of fuel, L.C.V. is: \",round(LCV,4),\" kJ/kg.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The Higher calorific value of fuel, H.C.V. is: 35126.455 kJ/kg.\n", + "The Lower calorific value of fuel, L.C.V. is: 34194.685 kJ/kg.\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 2.2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "V1=0.08; #gas burnt in calorimeter in m^3\n", + "Pg=5.2; #pressure of gas supply in cm of water\n", + "Pb=75.5; #barometer reading in cm of Hg\n", + "Ww=28; #weight of water heated by gas in kg\n", + "Tg=13; #temperature of gas in deg celsius\n", + "Twi=10; #temperature of water at inlet in deg celsius\n", + "Two=23.5; #temperature of water at outlet in deg celsius\n", + "Ms=0.06; #steam condensed in kg\n", + "\n", + " #CALCULATIONS\n", + " #by using general gas equation, reducing the volume to S.T.P.\n", + " #p1*V1/T1=p2*V2/T2\n", + "p1=Pb+(Pg/13.6); #in cm of Hg\n", + "T1=Tg+273; #in K\n", + "p2=76; #in cm of Hg\n", + "T2=15+273; #in K\n", + "V2=p1*V1*T2/T1/p2; #in m^3\n", + "Hw=Ww*4.18*(Two-Twi); #heat recieved by water in kJ\n", + "HCV=Hw/V1; #higher calorific value of fuel in kJ/m^3\n", + "LCV=HCV-2465*Ms/V1; #lower calorific value of fuel in kJ/m^3\n", + "\n", + "print \" The Calorific values of fuel per m^3 of gas at 15 deg celsius and 76 cm of Hg pressure are:\"\n", + "print \" The Higher calorific value of fuel, H.C.V. is: \",HCV,\" kJ/m^3.\"\n", + "print \" The Lower calorific value of fuel, L.C.V. is: \",LCV,\" kJ/m^3.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The Calorific values of fuel per m^3 of gas at 15 deg celsius and 76 cm of Hg pressure are:\n", + " The Higher calorific value of fuel, H.C.V. is: 19750.5 kJ/m^3.\n", + " The Lower calorific value of fuel, L.C.V. is: 17901.75 kJ/m^3.\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER NUMBER 3 : PROPERTIES OF GASES" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 3.1" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "Q=-50; #heat rejected to cooling water in kJ/kg\n", + "W=-100; #work input in kJ/kg\n", + "\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + "Du=Q-W; #(u2-u1) change in internal energy in kJ/kg\n", + " #since Du is +ve, there is gain in internal energy\n", + "\n", + "print \"The GAIN in internal energy is: \",Du,\" kJ/kg.\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The GAIN in internal energy is: 50 kJ/kg.\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 3.2" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "u1=450; #internal energy at beginning of the expansion in kJ/kg\n", + "u2=220; #internal energy after expansion in kJ/kg\n", + "W=120; #work done by the air during expansion in kJ/kg\n", + "\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + "Q=(u2-u1)+W; #heat flow in kJ/kg\n", + " #since Q is -ve, there is rejection of heat\n", + "\n", + "print \"The heat REJECTED by air is: \",(-Q),\" kJ/kg.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The heat REJECTED by air is: 110 kJ/kg.\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 3.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "m=0.3; #mass of nitrogen in kg\n", + "p1=0.1; #pressure in MPa\n", + "T1=40+273; #temperature before compression in K\n", + "p2=1; #pressure in MPa\n", + "T2=160+273; #temperature after compression in K\n", + "W=-30; #work done during the compression in kJ/kg\n", + "Cv=0.75 #in kJ/kgK\n", + "\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + " #(u2-u1)=m*Cv*(T2-T1)\n", + "Du=m*Cv*(T2-T1);\n", + "Q=Du+W; #heat flow in kJ/kg\n", + " #since Q is -ve, there is rejection of heat\n", + "\n", + "print \"The heat REJECTED by air is: \",(-Q),\" kJ. \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The heat REJECTED by air is: 3.0 kJ. \n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER 3.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + " #initial state\n", + "p1=0.105; #pressure of gas in MPa\n", + "V1=0.4; #volume of gas in m^3\n", + " #final state\n", + "p2=0.105; #pressure of gas in MPa\n", + "V2=0.20; #volume of gas in m^3\n", + "\n", + "Q=-42.5; #heat transferred in kJ\n", + "p=p1;\n", + "\n", + " #process used- ISOBARIC (Constant pressure)\n", + "W12=p*(V2-V1)*1000; #work in kJ\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + "Du=Q-W12; #(u2-u1) change in internal energy in kJ\n", + " #since Du is -ve, there is decrease in internal energy\n", + "\n", + "print \"The DECREASE in internal energy is: \",(-Du),\" kJ.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The DECREASE in internal energy is: 21.5 kJ.\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + " #part-1\n", + " #pressure=p1,temperature=T1\n", + " #part-2\n", + " #pressure=p2,temperature=T2\n", + "\n", + " #Acc. First Law of Thermodynamics, Q=(u2-u1)+W\n", + " #when partition moved\n", + "DQ=0;\n", + "DW=0;\n", + "DU=DQ-DW;\n", + " #DU=0\n", + "\n", + "print \" CONCLUSION: \"\n", + "print \" Acc. to First Law of Thermodynamics, \"\n", + "print \" When partion moved, there is conservation of internal energy. \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " CONCLUSION: \n", + " Acc. to First Law of Thermodynamics, \n", + " When partion moved, there is conservation of internal energy. \n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + " #initial state\n", + "p1=10**5; #initial pressure of air in Pa\n", + "v1=1.8; #volume of air in m^3/kg\n", + "T1=25+273; #initial temperature of air in K\n", + " #final state\n", + "p2=5*10**5; #final pressure of air in Pa\n", + "T2=25+273; #final temperature of air in K\n", + "\n", + " #process used- ISOTHERMAL (Constant temperature)\n", + "W12=(p1*v1*float(math.log(float(p1)/float(p2))/1000)); #work in kJ/kg\n", + " #since W is -ve, work is supplied to the air\n", + "\n", + " #since temperature is constant\n", + "Du=0; #(u2-u1) change in internal energy in kJ/kg\n", + "\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + "Q=Du+W12;\n", + " #since Q is -ve, there is rejection of heat from system to surroundings\n", + "\n", + "print \" (i) The Work done on the air is: \",round(-W12,4),\" kJ/kg. \"\n", + "print \" (ii) The change in internal energy is: \",(Du),\" kJ/kg. \"\n", + "print \" (iii) The Heat REJECTED is: \",round(-Q,4),\" kJ/kg. \"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " (i) The Work done on the air is: 289.6988 kJ/kg. \n", + " (ii) The change in internal energy is: 0 kJ/kg. \n", + " (iii) The Heat REJECTED is: 289.6988 kJ/kg. \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "p1=4*10**5; #initial pressure in N/m^2\n", + "V1=0.2; #initial volume in m^3\n", + "T1=130+273; #initial temperature in K\n", + "p2=1.02*10**5; #final pressure after adiabatic expansion in N/m^2\n", + "Q23=72.5; #increase in enthalpy during constant pressure process in kJ\n", + "Cp=1; #in kJ/kgK\n", + "Cv=0.714; #in kJ/khK\n", + "\n", + " #gamma for air, g\n", + "g=Cp/Cv;\n", + "R=(Cp-Cv)*1000;\n", + "\n", + " #for reversible adiabatic process 1-2\n", + " #p1*(V1**g)=p2*(V2**g)\n", + "V2=V1*(p1/p2)**(1/g); #final volume in m^3\n", + " #(T2/T1)=(p2/p1)**((g-1)/g);\n", + "T2=T1*(p2/p1)**((g-1)/g); #final temp. T2 in K\n", + "\n", + "m=p1*V1/R/T1; #mass in kg\n", + "\n", + " #for constant pressure process 2-3\n", + " #Q23=m*Cp*(T3-T2);\n", + "T3=Q23/m/Cp+T2;\n", + " #V2/T2=V3/T3\n", + "V3=V2/T2*T3;\n", + "\n", + " #Work done by the path 1-2-3, W123=W12+W23\n", + "W12=(p1*V1-p2*V2)/(g-1);\n", + "W23=p2*(V3-V2);\n", + "W123=W12+W23;\n", + "\n", + " #if the above processes are replaced by a single reversible polytropic process giving the same work between initial and final states,\n", + " #W13=W123=(p1V1-p3V3)/(n-1)\n", + "p3=p2;\n", + "n=1+(p1*V1-p3*V3)/W123; #index of expansion, n\n", + "\n", + "print \" (i) The Total Work done is: \",round(W123,4),\" Nm or J.\"\n", + "print \" (ii) The value of index of expansion, n is: \",round(n,4),\".\"\n", + "\n", + " #NOTE:\n", + " #there is slight variation in answers of the book due to rounding off of the values " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " (i) The Total Work done is: 85343.6734 Nm or J.\n", + " (ii) The value of index of expansion, n is: 1.0603 .\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + " #initial state\n", + "p1=10**5; #initial pressure of gas in Pa\n", + "V1=0.45; #initial volume of gas in m^3\n", + "T1=80+273; #initial temperature of gas in K\n", + " #final state\n", + "p2=5*10**5; #final pressure of gas in Pa\n", + "V2=0.13; #final volume of gas in m^3\n", + "\n", + " #gamma for air, g\n", + "g=1.4;\n", + "R=294.2 #J/kgK\n", + "\n", + "m=p1*V1/R/T1; #mass in kg\n", + "\n", + " #p1*(V1^n)=p2*(V2^n)\n", + "n=math.log(p2/p1)/math.log(V2/V1); #index n\n", + "\n", + " #In a polytropic process\n", + " #(T2/T1)=(V1/V2)^(n-1);\n", + "T2=T1*(V1/V2)**(n-1); #temp. T2 in K\n", + "\n", + "Cv=R/(g-1);\n", + "Du=m*Cv*(T2-T1)/1000; #increase in internal energy in kJ\n", + "\n", + " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", + " #W12=(p1*V1-p2*V2)/(n-1)=mR(T2-T1)/(n-1)\n", + "W12=m*R*(T1-T2)/(n-1)/1000;\n", + "Q=Du+W12;\n", + " #since Q is -ve, there is rejection of heat from system to surroundings\n", + "\n", + "print \" (i) The Mass of the gas is: \",round(m,4),\" kg.\"\n", + "print \" (ii) The index n is: \",round(n,4),\".\"\n", + "print \"(iii) The change in internal energy is: \",(Du),\" kJ.\"\n", + "print \" (iv) The Heat REJECTED is: \",round(-Q,4),\"kJ.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " (i) The Mass of the gas is: 0.4333 kg.\n", + " (ii) The index n is: -1.2961 .\n", + "(iii) The change in internal energy is: -106.0 kJ.\n", + " (iv) The Heat REJECTED is: 124.4657 kJ.\n" + ] + } + ], + "prompt_number": 70 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + " #initial state\n", + "p1=1.02; #initial pressure of air in bar\n", + "V1=0.015; #initial volume of air in m^3\n", + "T1=22+273; #initial temperature of air in K\n", + " #final state\n", + "p2=6.8; #final pressure of air in bar\n", + " #Law of adiabatic compression, pV^g=C\n", + "\n", + " #gamma for air, g\n", + "g=1.4\n", + "R=0.287;\n", + "\n", + " #In a adiabatic process\n", + " #(T2/T1)=(p2/p1)**((g-1)/g);\n", + "T2=T1*(p2/p1)**((g-1)/g); #final temp. T2 in K\n", + "\n", + " #p1*(V1**g)=p2*(V2**g)\n", + "V2=V1*(p1/p2)**(1/g); #final volume in m^3\n", + "\n", + "m=p1*10**5*V1/10**3/R/T1; #mass in kg\n", + "\n", + " #W=(p1*V1-p2*V2)/(g-1)=mR(T2-T1)/(g-1)\n", + "W=m*R*(T1-T2)/(g-1);\n", + " #since W is -ve, the work is done on the air\n", + "\n", + "print \" (i) The Final temperature is: \",(T2-273),\" deg. celsius.\"\n", + "print \" (ii) The Final Volume is: \",V2,\" m**3. \"\n", + "print \"(iii) The Work done on the air is: \",(-W),\" kJ.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " (i) The Final temperature is: 234.252870551 deg. celsius.\n", + " (ii) The Final Volume is: 0.00386887782624 m**3. \n", + "(iii) The Work done on the air is: 2.7520923046 kJ.\n" + ] + } + ], + "prompt_number": 66 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE NUMBER: 3.13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + " \n", + " #DATA GIVEN\n", + "m=1; #mass of etahne gas in kg\n", + "M=30; #molecular weight of ethane\n", + "p1=1.1; #initial pressure in bar\n", + "T1=27+273; #initial temperature in K\n", + "p2=6.6; #final pressure in bar\n", + "Cp=1.75; #in kJ/kgK\n", + "\n", + " #Law of compression, pV**1.3=C\n", + "n=1.3;\n", + "\n", + " #Characteristic gas constant, R = Universal gas constant (Ro)/Molecular weight(M)\n", + "Ro=8314;\n", + "R=Ro/(M); #kJ/kgK\n", + "R1 = float(R)/1000;\n", + " #R=Cp-Cv\n", + "Cv=Cp-float(R1);\n", + "g=Cp/Cv; #gamma g\n", + "\n", + " #In a polytropic process\n", + " #(T2/T1)=(p2/p1)**((n-1)/n);\n", + "T2=T1*(p2/p1)**((n-1)/n); #final temp. T2 in K\n", + "\n", + " #W=(p1*V1-p2*V2)/(n-1)=mR(T2-T1)/(g-1)\n", + "W=m*R*(T1-T2)/(n-1);\n", + "\n", + "Q=(g-n)*W/(g-1); #heat flow in kJ/kg\n", + "\n", + "print \" The Heat SUPPLIED is: \",float(Q),\" kJ/kg.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " The Heat SUPPLIED is: 84441.1861346 kJ/kg.\n" + ] + } + ], + "prompt_number": 102 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/SakshiGoplani/Sample.ipynb b/sample_notebooks/SakshiGoplani/Sample.ipynb deleted file mode 100755 index 108f20cf..00000000 --- a/sample_notebooks/SakshiGoplani/Sample.ipynb +++ /dev/null @@ -1,662 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:b8d3bc6c59d0efdfca4aa426416ba1f24e3078d69f0411d3e3ed7b293bd81c78" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "ELEMENTS OF MECHANICAL ENGINEERING by R.K. RAJPUT" - ] - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 2 : FUELS AND COMBUSTION" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " #DATA GIVEN\n", - "c=88; #% of carbon in coal\n", - "h=4.2; #% of hydrogen in coal\n", - "Wf=0.848; #weight of coal in g\n", - "Wfw=0.027; #weight of fuse wire in calorimeter in g\n", - "W=1950; #weight of water in calorimeter in g\n", - "We=380; #water equivalent of calorimeter\n", - "Dt=3.06; #observed temperature rise (t2-t1) in deg celsius\n", - "tc=0.017; #cooling correction in deg celsius\n", - "cfw=6700; #calorific value of fuse wire in J/g\n", - "\n", - " #CALCULATIONS\n", - "ctr=(Dt)+tc; #corrected temp. rise\n", - "Hw=(W+We)*4.18*(ctr); #heat recieved by water in J\n", - "Hfw=Wfw*cfw; #heat given out by fuse wire in J\n", - "Hcf=Hw-Hfw; #heat produced due to combustion of fuel in J\n", - "HCV=Hcf/Wf; #higher calorific value of fuel in kJ/kg\n", - "Ms=9*h/100; #steam produced per kg of coal\n", - "LCV=HCV-2465*Ms; #lower calorific value of fuel in kJ/kg\n", - "\n", - "print \"The Higher calorific value of fuel, H.C.V. is: \",round(HCV,4),\" kJ/kg.\"\n", - "print \"The Lower calorific value of fuel, L.C.V. is: \",round(LCV,4),\" kJ/kg.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Higher calorific value of fuel, H.C.V. is: 35126.455 kJ/kg.\n", - "The Lower calorific value of fuel, L.C.V. is: 34194.685 kJ/kg.\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 2.2" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "V1=0.08; #gas burnt in calorimeter in m^3\n", - "Pg=5.2; #pressure of gas supply in cm of water\n", - "Pb=75.5; #barometer reading in cm of Hg\n", - "Ww=28; #weight of water heated by gas in kg\n", - "Tg=13; #temperature of gas in deg celsius\n", - "Twi=10; #temperature of water at inlet in deg celsius\n", - "Two=23.5; #temperature of water at outlet in deg celsius\n", - "Ms=0.06; #steam condensed in kg\n", - "\n", - " #CALCULATIONS\n", - " #by using general gas equation, reducing the volume to S.T.P.\n", - " #p1*V1/T1=p2*V2/T2\n", - "p1=Pb+(Pg/13.6); #in cm of Hg\n", - "T1=Tg+273; #in K\n", - "p2=76; #in cm of Hg\n", - "T2=15+273; #in K\n", - "V2=p1*V1*T2/T1/p2; #in m^3\n", - "Hw=Ww*4.18*(Two-Twi); #heat recieved by water in kJ\n", - "HCV=Hw/V1; #higher calorific value of fuel in kJ/m^3\n", - "LCV=HCV-2465*Ms/V1; #lower calorific value of fuel in kJ/m^3\n", - "\n", - "print \" The Calorific values of fuel per m^3 of gas at 15 deg celsius and 76 cm of Hg pressure are:\"\n", - "print \" The Higher calorific value of fuel, H.C.V. is: \",HCV,\" kJ/m^3.\"\n", - "print \" The Lower calorific value of fuel, L.C.V. is: \",LCV,\" kJ/m^3.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The Calorific values of fuel per m^3 of gas at 15 deg celsius and 76 cm of Hg pressure are:\n", - " The Higher calorific value of fuel, H.C.V. is: 19750.5 kJ/m^3.\n", - " The Lower calorific value of fuel, L.C.V. is: 17901.75 kJ/m^3.\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER NUMBER 3 : PROPERTIES OF GASES" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 3.1" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "Q=-50; #heat rejected to cooling water in kJ/kg\n", - "W=-100; #work input in kJ/kg\n", - "\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - "Du=Q-W; #(u2-u1) change in internal energy in kJ/kg\n", - " #since Du is +ve, there is gain in internal energy\n", - "\n", - "print \"The GAIN in internal energy is: \",Du,\" kJ/kg.\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The GAIN in internal energy is: 50 kJ/kg.\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 3.2" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "u1=450; #internal energy at beginning of the expansion in kJ/kg\n", - "u2=220; #internal energy after expansion in kJ/kg\n", - "W=120; #work done by the air during expansion in kJ/kg\n", - "\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - "Q=(u2-u1)+W; #heat flow in kJ/kg\n", - " #since Q is -ve, there is rejection of heat\n", - "\n", - "print \"The heat REJECTED by air is: \",(-Q),\" kJ/kg.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The heat REJECTED by air is: 110 kJ/kg.\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 3.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "m=0.3; #mass of nitrogen in kg\n", - "p1=0.1; #pressure in MPa\n", - "T1=40+273; #temperature before compression in K\n", - "p2=1; #pressure in MPa\n", - "T2=160+273; #temperature after compression in K\n", - "W=-30; #work done during the compression in kJ/kg\n", - "Cv=0.75 #in kJ/kgK\n", - "\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - " #(u2-u1)=m*Cv*(T2-T1)\n", - "Du=m*Cv*(T2-T1);\n", - "Q=Du+W; #heat flow in kJ/kg\n", - " #since Q is -ve, there is rejection of heat\n", - "\n", - "print \"The heat REJECTED by air is: \",(-Q),\" kJ. \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The heat REJECTED by air is: 3.0 kJ. \n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER 3.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - " #initial state\n", - "p1=0.105; #pressure of gas in MPa\n", - "V1=0.4; #volume of gas in m^3\n", - " #final state\n", - "p2=0.105; #pressure of gas in MPa\n", - "V2=0.20; #volume of gas in m^3\n", - "\n", - "Q=-42.5; #heat transferred in kJ\n", - "p=p1;\n", - "\n", - " #process used- ISOBARIC (Constant pressure)\n", - "W12=p*(V2-V1)*1000; #work in kJ\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - "Du=Q-W12; #(u2-u1) change in internal energy in kJ\n", - " #since Du is -ve, there is decrease in internal energy\n", - "\n", - "print \"The DECREASE in internal energy is: \",(-Du),\" kJ.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The DECREASE in internal energy is: 21.5 kJ.\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.5" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - " #part-1\n", - " #pressure=p1,temperature=T1\n", - " #part-2\n", - " #pressure=p2,temperature=T2\n", - "\n", - " #Acc. First Law of Thermodynamics, Q=(u2-u1)+W\n", - " #when partition moved\n", - "DQ=0;\n", - "DW=0;\n", - "DU=DQ-DW;\n", - " #DU=0\n", - "\n", - "print \" CONCLUSION: \"\n", - "print \" Acc. to First Law of Thermodynamics, \"\n", - "print \" When partion moved, there is conservation of internal energy. \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " CONCLUSION: \n", - " Acc. to First Law of Thermodynamics, \n", - " When partion moved, there is conservation of internal energy. \n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.6" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - " #initial state\n", - "p1=10**5; #initial pressure of air in Pa\n", - "v1=1.8; #volume of air in m^3/kg\n", - "T1=25+273; #initial temperature of air in K\n", - " #final state\n", - "p2=5*10**5; #final pressure of air in Pa\n", - "T2=25+273; #final temperature of air in K\n", - "\n", - " #process used- ISOTHERMAL (Constant temperature)\n", - "W12=(p1*v1*float(math.log(float(p1)/float(p2))/1000)); #work in kJ/kg\n", - " #since W is -ve, work is supplied to the air\n", - "\n", - " #since temperature is constant\n", - "Du=0; #(u2-u1) change in internal energy in kJ/kg\n", - "\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - "Q=Du+W12;\n", - " #since Q is -ve, there is rejection of heat from system to surroundings\n", - "\n", - "print \" (i) The Work done on the air is: \",round(-W12,4),\" kJ/kg. \"\n", - "print \" (ii) The change in internal energy is: \",(Du),\" kJ/kg. \"\n", - "print \" (iii) The Heat REJECTED is: \",round(-Q,4),\" kJ/kg. \"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " (i) The Work done on the air is: 289.6988 kJ/kg. \n", - " (ii) The change in internal energy is: 0 kJ/kg. \n", - " (iii) The Heat REJECTED is: 289.6988 kJ/kg. \n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "p1=4*10**5; #initial pressure in N/m^2\n", - "V1=0.2; #initial volume in m^3\n", - "T1=130+273; #initial temperature in K\n", - "p2=1.02*10**5; #final pressure after adiabatic expansion in N/m^2\n", - "Q23=72.5; #increase in enthalpy during constant pressure process in kJ\n", - "Cp=1; #in kJ/kgK\n", - "Cv=0.714; #in kJ/khK\n", - "\n", - " #gamma for air, g\n", - "g=Cp/Cv;\n", - "R=(Cp-Cv)*1000;\n", - "\n", - " #for reversible adiabatic process 1-2\n", - " #p1*(V1**g)=p2*(V2**g)\n", - "V2=V1*(p1/p2)**(1/g); #final volume in m^3\n", - " #(T2/T1)=(p2/p1)**((g-1)/g);\n", - "T2=T1*(p2/p1)**((g-1)/g); #final temp. T2 in K\n", - "\n", - "m=p1*V1/R/T1; #mass in kg\n", - "\n", - " #for constant pressure process 2-3\n", - " #Q23=m*Cp*(T3-T2);\n", - "T3=Q23/m/Cp+T2;\n", - " #V2/T2=V3/T3\n", - "V3=V2/T2*T3;\n", - "\n", - " #Work done by the path 1-2-3, W123=W12+W23\n", - "W12=(p1*V1-p2*V2)/(g-1);\n", - "W23=p2*(V3-V2);\n", - "W123=W12+W23;\n", - "\n", - " #if the above processes are replaced by a single reversible polytropic process giving the same work between initial and final states,\n", - " #W13=W123=(p1V1-p3V3)/(n-1)\n", - "p3=p2;\n", - "n=1+(p1*V1-p3*V3)/W123; #index of expansion, n\n", - "\n", - "print \" (i) The Total Work done is: \",round(W123,4),\" Nm or J.\"\n", - "print \" (ii) The value of index of expansion, n is: \",round(n,4),\".\"\n", - "\n", - " #NOTE:\n", - " #there is slight variation in answers of the book due to rounding off of the values " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " (i) The Total Work done is: 85343.6734 Nm or J.\n", - " (ii) The value of index of expansion, n is: 1.0603 .\n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - " #initial state\n", - "p1=10**5; #initial pressure of gas in Pa\n", - "V1=0.45; #initial volume of gas in m^3\n", - "T1=80+273; #initial temperature of gas in K\n", - " #final state\n", - "p2=5*10**5; #final pressure of gas in Pa\n", - "V2=0.13; #final volume of gas in m^3\n", - "\n", - " #gamma for air, g\n", - "g=1.4;\n", - "R=294.2 #J/kgK\n", - "\n", - "m=p1*V1/R/T1; #mass in kg\n", - "\n", - " #p1*(V1^n)=p2*(V2^n)\n", - "n=math.log(p2/p1)/math.log(V2/V1); #index n\n", - "\n", - " #In a polytropic process\n", - " #(T2/T1)=(V1/V2)^(n-1);\n", - "T2=T1*(V1/V2)**(n-1); #temp. T2 in K\n", - "\n", - "Cv=R/(g-1);\n", - "Du=m*Cv*(T2-T1)/1000; #increase in internal energy in kJ\n", - "\n", - " #using First Law of Thermodynamics, Q=(u2-u1)+W\n", - " #W12=(p1*V1-p2*V2)/(n-1)=mR(T2-T1)/(n-1)\n", - "W12=m*R*(T1-T2)/(n-1)/1000;\n", - "Q=Du+W12;\n", - " #since Q is -ve, there is rejection of heat from system to surroundings\n", - "\n", - "print \" (i) The Mass of the gas is: \",round(m,4),\" kg.\"\n", - "print \" (ii) The index n is: \",round(n,4),\".\"\n", - "print \"(iii) The change in internal energy is: \",(Du),\" kJ.\"\n", - "print \" (iv) The Heat REJECTED is: \",round(-Q,4),\"kJ.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " (i) The Mass of the gas is: 0.4333 kg.\n", - " (ii) The index n is: -1.2961 .\n", - "(iii) The change in internal energy is: -106.0 kJ.\n", - " (iv) The Heat REJECTED is: 124.4657 kJ.\n" - ] - } - ], - "prompt_number": 70 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - " #initial state\n", - "p1=1.02; #initial pressure of air in bar\n", - "V1=0.015; #initial volume of air in m^3\n", - "T1=22+273; #initial temperature of air in K\n", - " #final state\n", - "p2=6.8; #final pressure of air in bar\n", - " #Law of adiabatic compression, pV^g=C\n", - "\n", - " #gamma for air, g\n", - "g=1.4\n", - "R=0.287;\n", - "\n", - " #In a adiabatic process\n", - " #(T2/T1)=(p2/p1)**((g-1)/g);\n", - "T2=T1*(p2/p1)**((g-1)/g); #final temp. T2 in K\n", - "\n", - " #p1*(V1**g)=p2*(V2**g)\n", - "V2=V1*(p1/p2)**(1/g); #final volume in m^3\n", - "\n", - "m=p1*10**5*V1/10**3/R/T1; #mass in kg\n", - "\n", - " #W=(p1*V1-p2*V2)/(g-1)=mR(T2-T1)/(g-1)\n", - "W=m*R*(T1-T2)/(g-1);\n", - " #since W is -ve, the work is done on the air\n", - "\n", - "print \" (i) The Final temperature is: \",(T2-273),\" deg. celsius.\"\n", - "print \" (ii) The Final Volume is: \",V2,\" m**3. \"\n", - "print \"(iii) The Work done on the air is: \",(-W),\" kJ.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " (i) The Final temperature is: 234.252870551 deg. celsius.\n", - " (ii) The Final Volume is: 0.00386887782624 m**3. \n", - "(iii) The Work done on the air is: 2.7520923046 kJ.\n" - ] - } - ], - "prompt_number": 66 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE NUMBER: 3.13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - " \n", - " #DATA GIVEN\n", - "m=1; #mass of etahne gas in kg\n", - "M=30; #molecular weight of ethane\n", - "p1=1.1; #initial pressure in bar\n", - "T1=27+273; #initial temperature in K\n", - "p2=6.6; #final pressure in bar\n", - "Cp=1.75; #in kJ/kgK\n", - "\n", - " #Law of compression, pV**1.3=C\n", - "n=1.3;\n", - "\n", - " #Characteristic gas constant, R = Universal gas constant (Ro)/Molecular weight(M)\n", - "Ro=8314;\n", - "R=Ro/(M); #kJ/kgK\n", - "R1 = float(R)/1000;\n", - " #R=Cp-Cv\n", - "Cv=Cp-float(R1);\n", - "g=Cp/Cv; #gamma g\n", - "\n", - " #In a polytropic process\n", - " #(T2/T1)=(p2/p1)**((n-1)/n);\n", - "T2=T1*(p2/p1)**((n-1)/n); #final temp. T2 in K\n", - "\n", - " #W=(p1*V1-p2*V2)/(n-1)=mR(T2-T1)/(g-1)\n", - "W=m*R*(T1-T2)/(n-1);\n", - "\n", - "Q=(g-n)*W/(g-1); #heat flow in kJ/kg\n", - "\n", - "print \" The Heat SUPPLIED is: \",float(Q),\" kJ/kg.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " The Heat SUPPLIED is: 84441.1861346 kJ/kg.\n" - ] - } - ], - "prompt_number": 102 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SaleemAhmed/Chapter10.ipynb b/sample_notebooks/SaleemAhmed/Chapter10.ipynb deleted file mode 100755 index fbb36289..00000000 --- a/sample_notebooks/SaleemAhmed/Chapter10.ipynb +++ /dev/null @@ -1,439 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter10 - Optical Fiber Systems" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.1 Page No: 349" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The voltage required to have a pi radian phase change = 4.56 volt\n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "r=30.8*10**-12## electro optice coefficient in m/V\n", - "L=3*10**-2## length in m\n", - "y=1.3*10**-6## wavelength in m\n", - "n=2.1#\n", - "d=30*10**-6## distance between the electrodes in m\n", - "V=(y*d)/((n)**3*r*L)## voltage required to have a pi radian phase change in volt\n", - "print \"The voltage required to have a pi radian phase change = %0.2f volt\"%( V)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.2 Page No: 350" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The total channel loss =31 dB\n" - ] - } - ], - "source": [ - "a_fc=4## fider cable loss in dB/km\n", - "aj=0.7## splice loss in db/km\n", - "L=5## length in km\n", - "a_cr1=4## connector losses\n", - "a_cr2=3.5## connector losses\n", - "CL=(a_fc+aj)*L+(a_cr1+a_cr2)## total channel loss in dB\n", - "print \"The total channel loss =%d dB\"%( CL)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.3 Page No: 350" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "with mode coupling, the total rms broadening = 1.73 ns\n", - "\n", - " The dispersion equalization penalty = 1.84 dB\n", - "\n", - " without mode coupling, the total rms broadening = 6.00 dB\n", - "\n", - " without mode coupling, equalization penalty = 0.03 dB\n", - "\n", - " without mode coupling,dispersion equalization penalty with 125 Mb/s = 83.98 dB\n", - "\n", - " with mode coupling,dispersion equalization penalty with 125 Mb/s = 0.28 dB\n", - "\n", - " The answer is wrong in the textbook\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "p=0.5*10**-9## pulse broadening in s/km\n", - "L=12## length in km\n", - "Pt=p*sqrt(L)## with mode coupling, the total rms broadening in s\n", - "BT=20*10**6##\n", - "DL=2*(2*Pt*BT*sqrt(2))**4## dispersion equalization penalty in dB\n", - "Pt1=p*L## without mode coupling, the total rms broadening in s\n", - "DL1=2*(2*Pt1*BT*sqrt(2))**4## without mode coupling, equalization penalty in dB\n", - "DL2=2*(2*Pt1*150*10**6*sqrt(2))**4## without mode coupling,dispersion equalization penalty with 125 Mb/s\n", - "DL3=2*(2*Pt*125*10**6*sqrt(2))**4## with mode coupling,dispersion equalization penalty with 125 Mb/s\n", - "print \"with mode coupling, the total rms broadening = %0.2f ns\"%( Pt*10**9)#\n", - "print \"\\n The dispersion equalization penalty = %0.2f dB\"%( DL*10**4)#\n", - "print \"\\n without mode coupling, the total rms broadening = %0.2f dB\"%( Pt1*10**9)#\n", - "print \"\\n without mode coupling, equalization penalty = %0.2f dB\"%( DL1)#\n", - "print \"\\n without mode coupling,dispersion equalization penalty with 125 Mb/s = %0.2f dB\"%( DL2)#\n", - "print \"\\n with mode coupling,dispersion equalization penalty with 125 Mb/s = %0.2f dB\"%( DL3)#\n", - "print \"\\n The answer is wrong in the textbook\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.4 Page No: 351" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The length when system operating at 25 Mbps = 78.89 km\n", - "\n", - " The length when system operating at 350 Mbps = 56.67 km\n" - ] - } - ], - "source": [ - "Pi=-2.5## mean optical power launched into the fiber in dBm\n", - "Po=-45## mean output optical power available at the receiver in dBm\n", - "a_fc=0.35## fider cable loss in dB/km\n", - "aj=0.1## splice loss in db/km\n", - "a_cr=1## connector losses\n", - "Ma=6## safety margin in dB\n", - "L=(Pi-Po-a_cr-Ma)/(a_fc+aj)## length in km when system operating at 25 Mbps\n", - "Po1=-35## mean output optical power available at the receiver in dBm\n", - "L1=(Pi-Po1-a_cr-Ma)/(a_fc+aj)## length in km when system operating at 350 Mbps\n", - "print \"The length when system operating at 25 Mbps = %0.2f km\"%( L)#\n", - "print \"\\n The length when system operating at 350 Mbps = %0.2f km\"%( L1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.5 Page No: 351" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The fider loss = 20.00 dB\n", - "\n", - " The total splicing loss = 3.20 dB\n", - "\n", - " The fangle effects & future splice = 5.00 dB\n", - "\n", - " The total attenuation = 29.20 dB\n", - "\n", - " The excess power margin = 2.80 dB\n", - "\n", - " hence the system can operate with small excess power margin\n" - ] - } - ], - "source": [ - "Tx=-80## transmitter output in dBm\n", - "Rx=-40## receiver sensitivity in dBm\n", - "sm=32## system margin in dB\n", - "L=10## in km\n", - "fl=2*L## fider loss in dB\n", - "cl=1## detector coupling loss in dB\n", - "tl=0.4*8## total splicing loss in dB\n", - "ae=5## angle effects & future splice in dB\n", - "ta=29.2## total attenuation in dB\n", - "Ep=2.8## excess power margin in dB\n", - "print \"The fider loss = %0.2f dB\"%( fl)#\n", - "print \"\\n The total splicing loss = %0.2f dB\"%( tl)#\n", - "print \"\\n The fangle effects & future splice = %0.2f dB\"%( ae)#\n", - "print \"\\n The total attenuation = %0.2f dB\"%( ta)#\n", - "print \"\\n The excess power margin = %0.2f dB\"%( Ep)#\n", - "print \"\\n hence the system can operate with small excess power margin\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.6 Page No: 352" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The max transmission length when transmission star coupler is used = 1.99 km\n", - "\n", - " The max transmission length when reflection star coupler is used = 1.24 km\n" - ] - } - ], - "source": [ - "from math import log\n", - "Lc=1## connector loss in db\n", - "Ls=5## star coupler insertion loss in dB\n", - "af=2## fider loss in dB\n", - "Ps=-14## transmitted power in dBm\n", - "Pr=-49## receiver sensitivity in dBm\n", - "sm=6## system margin in dB\n", - "N=16#\n", - "L=(Ps-Pr-Ls-4*Lc-(10*log(N))/log(10)-sm)/(2*af)## max transmission length in km when transmission star coupler is used\n", - "N1=32#\n", - "L1=(Ps-Pr-Ls-4*Lc-(10*log(N1))/log(10)-sm)/(2*af)## max transmission length in km when reflection star coupler is used\n", - "print \"The max transmission length when transmission star coupler is used = %0.2f km\"%( L)#\n", - "print \"\\n The max transmission length when reflection star coupler is used = %0.2f km\"%( L1)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.7 Page No: 353" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The system rise time = 18.51 ns\n", - "\n", - " The max bit rate for NRZ coding = 37.81 Mbit/s\n", - "\n", - " The max bit rate for RZ coding = 18.90 Mbit/s\n" - ] - } - ], - "source": [ - "y=860*10**-9## wavelength in m\n", - "L=5000## length in m\n", - "X=0.024#\n", - "dy=20*10**-9## spectral width in m\n", - "dts=6*10**-9## silica optical link rise time in s\n", - "dtr=8*10**-9## detector rise in s\n", - "c=3*10**8## speed of light in m/s\n", - "dtm=-(L*dy*X)/(c*y)## material dispersion delay time in s\n", - "id=2.5*10**-12## intermodel dispersion in s/m\n", - "dti=id*L## intermodel dispersion delay time\n", - "dtsy=sqrt((dts**2)+(dtr**2)+(dtm**2)+(dti**2))## system rise time in s\n", - "Br_max=0.7/dtsy## max bit rate for NRZ coding in bit/s\n", - "Br_max1=0.35/dtsy## max bit rate for RZ coding in bit/s\n", - "print \"The system rise time = %0.2f ns\"%( dtsy*10**9)#\n", - "print \"\\n The max bit rate for NRZ coding = %0.2f Mbit/s\"%( Br_max/10**6)#\n", - "print \"\\n The max bit rate for RZ coding = %0.2f Mbit/s\"%( Br_max1/10**6)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.8 Page No: 353" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The transmission distance for Si fiber = 71.43 m\n", - "\n", - " The transmission distance for GRIN fiber = 420.00 m\n" - ] - } - ], - "source": [ - "Br=50*10**6## data rate in b/s\n", - "c=3*10**8## speed of light in m/s\n", - "n1=1.47## \n", - "dl=0.02## \n", - "n12=n1*dl## the difference b/w n1 and n2\n", - "L_si=(0.35*c)/(n12*Br)## transmission distance for Si fiber\n", - "L_GI=(2.8*c*n1**2)/(2*n1*n12*Br)## transmission distance for GRIN fiber\n", - "print \"The transmission distance for Si fiber = %0.2f m\"%( L_si)#\n", - "print \"\\n The transmission distance for GRIN fiber = %0.2f m\"%( L_GI)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.9 Page No: 353" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The material dispersion limited transmission distance =627 m\n" - ] - } - ], - "source": [ - "Br=20.0*10**6## data rate in b/s\n", - "c=3*10**8## speed of light in m/s\n", - "y=86*10**-9## wavelength in m\n", - "dy=30*10**-9## spectral width in m\n", - "X=0.024#\n", - "Tb=1/Br#\n", - "Lmax=(0.35*Tb*c*y)/(dy*X)## material dispersion limited transmission distance for RZ coding in m\n", - "print \"The material dispersion limited transmission distance =%d m\"%( Lmax)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex:10.10 Page No: 354" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "ename": "ZeroDivisionError", - "evalue": "integer division or modulo by zero", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mLmax\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0.35\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdy\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## material dispersion limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[0mL_GI\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1.4\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mn1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn12\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## model dispersion limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[0mL_At\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mPt\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mPr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mLa\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## attenuation limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"The material dispersion limited distance = %0.2f*10**10*1/Br m\"\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0mLmax\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\n The model dispersion limited distance = %0.2f*10**10*1/Br m\"\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0mL_GI\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" - ] - } - ], - "source": [ - "y=860*10**-9## wavelength in m\n", - "c=3*10**8## speed of light in m/s\n", - "n1=1.47## \n", - "dl=0.02## \n", - "n12=n1*dl## the difference b/w n1 and n2\n", - "La=1/1000## loss a in dB/m\n", - "Pr=-65## receiver power in dB\n", - "Pt=-5## transmitted power in dB\n", - "dy=30*10**-9## line width in m\n", - "X=0.024#\n", - "Lmax=(0.35*c*y)/(dy*X)## material dispersion limited distance for RZ coding in m\n", - "L_GI=(1.4*c*n1)/(n12)## model dispersion limited distance for RZ coding in m\n", - "L_At=(Pt-Pr)/(La)## attenuation limited distance for RZ coding in m \n", - "print \"The material dispersion limited distance = %0.2f*10**10*1/Br m\"%( Lmax/10**10)#\n", - "print \"\\n The model dispersion limited distance = %0.2f*10**10*1/Br m\"%( L_GI/10**10)#\n", - "print \"\\n The attenuation limited distance =%d-20log(Br) km\"%( L_At/10**3)" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SaleemAhmed/SaleemAhmed_version_backup/Chapter10.ipynb b/sample_notebooks/SaleemAhmed/SaleemAhmed_version_backup/Chapter10.ipynb new file mode 100755 index 00000000..fbb36289 --- /dev/null +++ b/sample_notebooks/SaleemAhmed/SaleemAhmed_version_backup/Chapter10.ipynb @@ -0,0 +1,439 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter10 - Optical Fiber Systems" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.1 Page No: 349" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The voltage required to have a pi radian phase change = 4.56 volt\n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "r=30.8*10**-12## electro optice coefficient in m/V\n", + "L=3*10**-2## length in m\n", + "y=1.3*10**-6## wavelength in m\n", + "n=2.1#\n", + "d=30*10**-6## distance between the electrodes in m\n", + "V=(y*d)/((n)**3*r*L)## voltage required to have a pi radian phase change in volt\n", + "print \"The voltage required to have a pi radian phase change = %0.2f volt\"%( V)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.2 Page No: 350" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The total channel loss =31 dB\n" + ] + } + ], + "source": [ + "a_fc=4## fider cable loss in dB/km\n", + "aj=0.7## splice loss in db/km\n", + "L=5## length in km\n", + "a_cr1=4## connector losses\n", + "a_cr2=3.5## connector losses\n", + "CL=(a_fc+aj)*L+(a_cr1+a_cr2)## total channel loss in dB\n", + "print \"The total channel loss =%d dB\"%( CL)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.3 Page No: 350" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "with mode coupling, the total rms broadening = 1.73 ns\n", + "\n", + " The dispersion equalization penalty = 1.84 dB\n", + "\n", + " without mode coupling, the total rms broadening = 6.00 dB\n", + "\n", + " without mode coupling, equalization penalty = 0.03 dB\n", + "\n", + " without mode coupling,dispersion equalization penalty with 125 Mb/s = 83.98 dB\n", + "\n", + " with mode coupling,dispersion equalization penalty with 125 Mb/s = 0.28 dB\n", + "\n", + " The answer is wrong in the textbook\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "p=0.5*10**-9## pulse broadening in s/km\n", + "L=12## length in km\n", + "Pt=p*sqrt(L)## with mode coupling, the total rms broadening in s\n", + "BT=20*10**6##\n", + "DL=2*(2*Pt*BT*sqrt(2))**4## dispersion equalization penalty in dB\n", + "Pt1=p*L## without mode coupling, the total rms broadening in s\n", + "DL1=2*(2*Pt1*BT*sqrt(2))**4## without mode coupling, equalization penalty in dB\n", + "DL2=2*(2*Pt1*150*10**6*sqrt(2))**4## without mode coupling,dispersion equalization penalty with 125 Mb/s\n", + "DL3=2*(2*Pt*125*10**6*sqrt(2))**4## with mode coupling,dispersion equalization penalty with 125 Mb/s\n", + "print \"with mode coupling, the total rms broadening = %0.2f ns\"%( Pt*10**9)#\n", + "print \"\\n The dispersion equalization penalty = %0.2f dB\"%( DL*10**4)#\n", + "print \"\\n without mode coupling, the total rms broadening = %0.2f dB\"%( Pt1*10**9)#\n", + "print \"\\n without mode coupling, equalization penalty = %0.2f dB\"%( DL1)#\n", + "print \"\\n without mode coupling,dispersion equalization penalty with 125 Mb/s = %0.2f dB\"%( DL2)#\n", + "print \"\\n with mode coupling,dispersion equalization penalty with 125 Mb/s = %0.2f dB\"%( DL3)#\n", + "print \"\\n The answer is wrong in the textbook\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.4 Page No: 351" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The length when system operating at 25 Mbps = 78.89 km\n", + "\n", + " The length when system operating at 350 Mbps = 56.67 km\n" + ] + } + ], + "source": [ + "Pi=-2.5## mean optical power launched into the fiber in dBm\n", + "Po=-45## mean output optical power available at the receiver in dBm\n", + "a_fc=0.35## fider cable loss in dB/km\n", + "aj=0.1## splice loss in db/km\n", + "a_cr=1## connector losses\n", + "Ma=6## safety margin in dB\n", + "L=(Pi-Po-a_cr-Ma)/(a_fc+aj)## length in km when system operating at 25 Mbps\n", + "Po1=-35## mean output optical power available at the receiver in dBm\n", + "L1=(Pi-Po1-a_cr-Ma)/(a_fc+aj)## length in km when system operating at 350 Mbps\n", + "print \"The length when system operating at 25 Mbps = %0.2f km\"%( L)#\n", + "print \"\\n The length when system operating at 350 Mbps = %0.2f km\"%( L1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.5 Page No: 351" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The fider loss = 20.00 dB\n", + "\n", + " The total splicing loss = 3.20 dB\n", + "\n", + " The fangle effects & future splice = 5.00 dB\n", + "\n", + " The total attenuation = 29.20 dB\n", + "\n", + " The excess power margin = 2.80 dB\n", + "\n", + " hence the system can operate with small excess power margin\n" + ] + } + ], + "source": [ + "Tx=-80## transmitter output in dBm\n", + "Rx=-40## receiver sensitivity in dBm\n", + "sm=32## system margin in dB\n", + "L=10## in km\n", + "fl=2*L## fider loss in dB\n", + "cl=1## detector coupling loss in dB\n", + "tl=0.4*8## total splicing loss in dB\n", + "ae=5## angle effects & future splice in dB\n", + "ta=29.2## total attenuation in dB\n", + "Ep=2.8## excess power margin in dB\n", + "print \"The fider loss = %0.2f dB\"%( fl)#\n", + "print \"\\n The total splicing loss = %0.2f dB\"%( tl)#\n", + "print \"\\n The fangle effects & future splice = %0.2f dB\"%( ae)#\n", + "print \"\\n The total attenuation = %0.2f dB\"%( ta)#\n", + "print \"\\n The excess power margin = %0.2f dB\"%( Ep)#\n", + "print \"\\n hence the system can operate with small excess power margin\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.6 Page No: 352" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The max transmission length when transmission star coupler is used = 1.99 km\n", + "\n", + " The max transmission length when reflection star coupler is used = 1.24 km\n" + ] + } + ], + "source": [ + "from math import log\n", + "Lc=1## connector loss in db\n", + "Ls=5## star coupler insertion loss in dB\n", + "af=2## fider loss in dB\n", + "Ps=-14## transmitted power in dBm\n", + "Pr=-49## receiver sensitivity in dBm\n", + "sm=6## system margin in dB\n", + "N=16#\n", + "L=(Ps-Pr-Ls-4*Lc-(10*log(N))/log(10)-sm)/(2*af)## max transmission length in km when transmission star coupler is used\n", + "N1=32#\n", + "L1=(Ps-Pr-Ls-4*Lc-(10*log(N1))/log(10)-sm)/(2*af)## max transmission length in km when reflection star coupler is used\n", + "print \"The max transmission length when transmission star coupler is used = %0.2f km\"%( L)#\n", + "print \"\\n The max transmission length when reflection star coupler is used = %0.2f km\"%( L1)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.7 Page No: 353" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The system rise time = 18.51 ns\n", + "\n", + " The max bit rate for NRZ coding = 37.81 Mbit/s\n", + "\n", + " The max bit rate for RZ coding = 18.90 Mbit/s\n" + ] + } + ], + "source": [ + "y=860*10**-9## wavelength in m\n", + "L=5000## length in m\n", + "X=0.024#\n", + "dy=20*10**-9## spectral width in m\n", + "dts=6*10**-9## silica optical link rise time in s\n", + "dtr=8*10**-9## detector rise in s\n", + "c=3*10**8## speed of light in m/s\n", + "dtm=-(L*dy*X)/(c*y)## material dispersion delay time in s\n", + "id=2.5*10**-12## intermodel dispersion in s/m\n", + "dti=id*L## intermodel dispersion delay time\n", + "dtsy=sqrt((dts**2)+(dtr**2)+(dtm**2)+(dti**2))## system rise time in s\n", + "Br_max=0.7/dtsy## max bit rate for NRZ coding in bit/s\n", + "Br_max1=0.35/dtsy## max bit rate for RZ coding in bit/s\n", + "print \"The system rise time = %0.2f ns\"%( dtsy*10**9)#\n", + "print \"\\n The max bit rate for NRZ coding = %0.2f Mbit/s\"%( Br_max/10**6)#\n", + "print \"\\n The max bit rate for RZ coding = %0.2f Mbit/s\"%( Br_max1/10**6)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.8 Page No: 353" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The transmission distance for Si fiber = 71.43 m\n", + "\n", + " The transmission distance for GRIN fiber = 420.00 m\n" + ] + } + ], + "source": [ + "Br=50*10**6## data rate in b/s\n", + "c=3*10**8## speed of light in m/s\n", + "n1=1.47## \n", + "dl=0.02## \n", + "n12=n1*dl## the difference b/w n1 and n2\n", + "L_si=(0.35*c)/(n12*Br)## transmission distance for Si fiber\n", + "L_GI=(2.8*c*n1**2)/(2*n1*n12*Br)## transmission distance for GRIN fiber\n", + "print \"The transmission distance for Si fiber = %0.2f m\"%( L_si)#\n", + "print \"\\n The transmission distance for GRIN fiber = %0.2f m\"%( L_GI)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.9 Page No: 353" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The material dispersion limited transmission distance =627 m\n" + ] + } + ], + "source": [ + "Br=20.0*10**6## data rate in b/s\n", + "c=3*10**8## speed of light in m/s\n", + "y=86*10**-9## wavelength in m\n", + "dy=30*10**-9## spectral width in m\n", + "X=0.024#\n", + "Tb=1/Br#\n", + "Lmax=(0.35*Tb*c*y)/(dy*X)## material dispersion limited transmission distance for RZ coding in m\n", + "print \"The material dispersion limited transmission distance =%d m\"%( Lmax)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex:10.10 Page No: 354" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "integer division or modulo by zero", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[0mLmax\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0.35\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0my\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdy\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mX\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## material dispersion limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 12\u001b[0m \u001b[0mL_GI\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m1.4\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mc\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mn1\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mn12\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## model dispersion limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 13\u001b[1;33m \u001b[0mL_At\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mPt\u001b[0m\u001b[1;33m-\u001b[0m\u001b[0mPr\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mLa\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m## attenuation limited distance for RZ coding in m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 14\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"The material dispersion limited distance = %0.2f*10**10*1/Br m\"\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0mLmax\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 15\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"\\n The model dispersion limited distance = %0.2f*10**10*1/Br m\"\u001b[0m\u001b[1;33m%\u001b[0m\u001b[1;33m(\u001b[0m \u001b[0mL_GI\u001b[0m\u001b[1;33m/\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m**\u001b[0m\u001b[1;36m10\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;31m#\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mZeroDivisionError\u001b[0m: integer division or modulo by zero" + ] + } + ], + "source": [ + "y=860*10**-9## wavelength in m\n", + "c=3*10**8## speed of light in m/s\n", + "n1=1.47## \n", + "dl=0.02## \n", + "n12=n1*dl## the difference b/w n1 and n2\n", + "La=1/1000## loss a in dB/m\n", + "Pr=-65## receiver power in dB\n", + "Pt=-5## transmitted power in dB\n", + "dy=30*10**-9## line width in m\n", + "X=0.024#\n", + "Lmax=(0.35*c*y)/(dy*X)## material dispersion limited distance for RZ coding in m\n", + "L_GI=(1.4*c*n1)/(n12)## model dispersion limited distance for RZ coding in m\n", + "L_At=(Pt-Pr)/(La)## attenuation limited distance for RZ coding in m \n", + "print \"The material dispersion limited distance = %0.2f*10**10*1/Br m\"%( Lmax/10**10)#\n", + "print \"\\n The model dispersion limited distance = %0.2f*10**10*1/Br m\"%( L_GI/10**10)#\n", + "print \"\\n The attenuation limited distance =%d-20log(Br) km\"%( L_At/10**3)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SalilKapur/IntroductionConcept_of.ipynb b/sample_notebooks/SalilKapur/IntroductionConcept_of.ipynb new file mode 100755 index 00000000..050d69c7 --- /dev/null +++ b/sample_notebooks/SalilKapur/IntroductionConcept_of.ipynb @@ -0,0 +1,282 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1: Introduction—Concept of Stress\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.1, Page number 18 " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Case(a): Shearing Stress in Pin A = 6790.6 psi\n", + "Case(b): Shearing Stress in Pin C = 7639 psi\n", + "Case(c): Largest Normal Stress in Link ABC = 2286 psi\n", + "Case(d): Average Shearing Stress at B = 171 psi\n", + "Case(e): Bearing Stress in Link at C = 6000 psi\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "Fac = 750 #Force on rod AC(lb)\n", + "D = 0.375 #Diameter at the upper junction of rod ABC(in)\n", + "\n", + "\n", + "#Calculation \n", + "#Case(a)\n", + "A=(1/4)*((math.pi)*pow(D,2)) #Area at the upper junction of rod ABC(in^2) \n", + "tA=(Fac/A) #Shearing Stress in Pin A(psi) \n", + "#Case(b) \n", + "Ab=(1/4)*((math.pi)*pow(0.25,2)) #Area at the lower junction of rod ABC(in^2)\n", + "tC=(((1/2)*Fac)/Ab) #Shearing Stress in Pin C(psi)\n", + "#Case(c)\n", + "Anet=(3/8)*(1.25-0.375) #Area of cross section at A(in^2)\n", + "sA=(Fac/Anet) #Largest Normal Stress in Link ABC(psi)\n", + "#Case(d)\n", + "F1=750/2 #Force on each side(lb)\n", + "Ad=(1.25*1.75) #Area at junction B(in^2)\n", + "tB=(F1/Ad) #Average Shearing Stress at B\n", + "#Case(e)\n", + "Ae=0.25*0.25 #Area at point C(in^2)\n", + "sB=(F1/Ae) #Bearing Stress in Link at C\n", + "\n", + "\n", + "#Result\n", + "print('Case(a): Shearing Stress in Pin A = %.1f psi' %tA)\n", + "print('Case(b): Shearing Stress in Pin C = %.f psi' %tC)\n", + "print('Case(c): Largest Normal Stress in Link ABC = %.f psi' %sA)\n", + "print('Case(d): Average Shearing Stress at B = %.f psi' %tB)\n", + "print('Case(e): Bearing Stress in Link at C = %.f psi' %sB)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.2, Page number 19" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Case(a): Diameter of the bolt = 28 mm\n", + "Case(a): Dimension b at Each End of the Bar = 62 mm\n", + "Case(a): Dimension h of the Bar = 34.300000 mm\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "P = 120 #Maximum allowable tension force \n", + "s = 175 #Maximum allowable stress\n", + "t = 100 #Maximum allowable stress\n", + "Sb = 350 #Maximum allowable stress\n", + "\n", + "\n", + "#Calculation\n", + "#Case(a)\n", + "F1=P/2 #Current(A)\n", + "d=math.sqrt(((P/2)*1000)/((22/(4*7))*(100000000))) #Diameter of bolt(m)\n", + "d=d*1000 #Diameter of bolt(mm)\n", + "d=round(d,0) #Rounding of the value of diameter of bolt(mm)\n", + "Ad=(0.020*0.028) #Area of cross section of plate \n", + "tb=((P*1000)/Ad)/(1000000) #Stress between between the 20-mm-thick plate and the 28-mm-diameter bolt\n", + "tb=round(tb,0) #Rounding of the above calculated stress to check if it is less than 350\n", + "a=(P/2)/((0.02)*(175)) #Dimension of cross section of ring \n", + "a=round(a,2) #Rounding dimension of cross section of ring to two decimal places\n", + "b=28 + (2*(a)) #Dimension b at Each End of the Bar\n", + "b=round(b,2) #Rounding the dimension b to two decimal places \n", + "h=(P)/((0.020)*(175)) #Dimension h of the Bar\n", + "h=round(h,1) #Rounding dimension h of bar to 1 decimal place\n", + "\n", + "\n", + "#Result\n", + "print ('Case(a): Diameter of the bolt = %.f mm' %d)\n", + "print ('Case(a): Dimension b at Each End of the Bar = %.f mm' %b)\n", + "print ('Case(a): Dimension h of the Bar = %f mm' %h)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.3, Page number 34" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Case(a): Diameter of the bolt = 16.730000 mm\n", + "Case(a): Dimension b at Each End of the Bar = 22.000000 mm\n", + "Case(a): Dimension h of the Bar = 6.000000 mm\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "Su = 600 #ultimate normal stress(MPa) \n", + "FS = 3.3 #Factor of safety with respect to failure\n", + "tU=350 #Ultimate shearing stress(MPa)\n", + "Cx=40 #X Component of reaction at C(kN)\n", + "Cy=65 #Y Component of reaction at C(kN)\n", + "Smax=300 #Allowable bearing stress of the steel \n", + "\n", + "#Calculation\n", + "C=math.sqrt((math.pow(40,2))+(math.pow(65,2)))\n", + "\n", + "#Case(a)\n", + "P=(15*0.6 + 50*0.3)/(0.6) #Allowable bearing stress of the steel(MPa)\n", + "Sall=(Su/FS) #Allowable Stress(MPa)\n", + "Sall=round(Sall,1) #Rounding Allowable stress to 1 decimal place(MPa)\n", + "Areqa=(P/(Sall*(1000))) #Cross Sectional area(m^2)\n", + "Areqa=round(Areqa,5) #Rounding cross sectional area to 5 decimal places(m^2)\n", + "dAB=math.sqrt(((Areqa)*(4))/(22/7)) #Diameter of AB(m)\n", + "dAB=dAB*1000 #Diameter of AB(mm)\n", + "dAB=round(dAB,2) #Rounding Diameter of AB(mm)\n", + "\n", + "#Case(b)\n", + "tALL=tU/FS #Stress(MPa)\n", + "tALL=round(tALL,1) #Rounding of Stress\n", + "AreqC=((C/2)/tALL) #Cross sectional area(m^2)\n", + "AreqC=AreqC*1000 \n", + "AreqC=round(AreqC,0) #Rounding the cross sectional area\n", + "dC=math.sqrt((4*AreqC)/(22/7)) #Diameter at point C\n", + "dC=round((dC+1),0) #Rounding of the diameter at C\n", + "\n", + "#Case(c)\n", + "\n", + "Areq=((C/2)/Smax) \n", + "Areq=Areq*1000 #Cross sectional area(mm^2)\n", + "t=(Areq/22) #Thickness of the bracket\n", + "t=round(t,0)\n", + "\n", + "#Result\n", + "print ('Case(a): Diameter of the bolt = % f mm' %dAB)\n", + "print ('Case(a): Dimension b at Each End of the Bar = % f mm' %dC)\n", + "print ('Case(a): Dimension h of the Bar = % f mm' %t)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 1.4, Page number 35" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Case(a): Control Rod = 5.263672 kips\n", + "Case(b): Bolt at B = 5.156250 kips\n", + "Case(c): Bolt at D = 6.865179 kips\n", + "Case(d): Bolt at C = 5.238095 kips\n", + "Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:= 5.156250 kips\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#Variable declaration\n", + "tU=40 #ultimate tensile stress\n", + "sU=60 #ultimate shearing stress\n", + "FS=3 #Mimnimum factor of safety\n", + "dA=(7/16) #Diameter of bolt at A(in)\n", + "dB=3/8 #Diameter of bolt at B(in) \n", + "dD=3/8 #Diameter of bolt at D(in)\n", + "dC=1/2 #Diameter of bolt at C(in)\n", + "\n", + "\n", + "#Calculation\n", + "Sall=(sU/FS) #Total tensile stress(kips)\n", + "B=Sall*((1/4)*(22/7)*(pow((7/16),2))) #Allowable force in the control rod(kips)\n", + "C1=1.75*(B) #Control Rod(kips)\n", + "tall=(tU/FS) #Total shearing stress\n", + "B=2*(tall*(1/4)*(22/7)*(3/8)*(3/8)) #Allowable magnitude of the force B exerted on the bolt\n", + "C2=1.75*B #Bolt at B(kips) \n", + "D=B #Bolt at D. Since this bolt is the same as bolt B, the allowable force is same(kips) \n", + "C3=2.33*D #Bolt at D(kips)\n", + "C4=2*(tall*(1/4)*(22/7)*(1/2)*(1/2)) #Bolt at C(kips) \n", + "list1=[C1,C2,C3,C4] #Adding all the maximum allowable forces on C(kips) \n", + "\n", + "\n", + "#Result\n", + "print ('Case(a): Control Rod = % f kips' %C1)\n", + "print ('Case(b): Bolt at B = % f kips' %C2)\n", + "print ('Case(c): Bolt at D = % f kips' %C3)\n", + "print ('Case(d): Bolt at C = % f kips' %C4)\n", + "print ('Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:= % f kips' %min(list1));" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SalilKapur/IntroductionConcept_of_Stress.ipynb b/sample_notebooks/SalilKapur/IntroductionConcept_of_Stress.ipynb deleted file mode 100755 index 050d69c7..00000000 --- a/sample_notebooks/SalilKapur/IntroductionConcept_of_Stress.ipynb +++ /dev/null @@ -1,282 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1: Introduction—Concept of Stress\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.1, Page number 18 " - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Case(a): Shearing Stress in Pin A = 6790.6 psi\n", - "Case(b): Shearing Stress in Pin C = 7639 psi\n", - "Case(c): Largest Normal Stress in Link ABC = 2286 psi\n", - "Case(d): Average Shearing Stress at B = 171 psi\n", - "Case(e): Bearing Stress in Link at C = 6000 psi\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "Fac = 750 #Force on rod AC(lb)\n", - "D = 0.375 #Diameter at the upper junction of rod ABC(in)\n", - "\n", - "\n", - "#Calculation \n", - "#Case(a)\n", - "A=(1/4)*((math.pi)*pow(D,2)) #Area at the upper junction of rod ABC(in^2) \n", - "tA=(Fac/A) #Shearing Stress in Pin A(psi) \n", - "#Case(b) \n", - "Ab=(1/4)*((math.pi)*pow(0.25,2)) #Area at the lower junction of rod ABC(in^2)\n", - "tC=(((1/2)*Fac)/Ab) #Shearing Stress in Pin C(psi)\n", - "#Case(c)\n", - "Anet=(3/8)*(1.25-0.375) #Area of cross section at A(in^2)\n", - "sA=(Fac/Anet) #Largest Normal Stress in Link ABC(psi)\n", - "#Case(d)\n", - "F1=750/2 #Force on each side(lb)\n", - "Ad=(1.25*1.75) #Area at junction B(in^2)\n", - "tB=(F1/Ad) #Average Shearing Stress at B\n", - "#Case(e)\n", - "Ae=0.25*0.25 #Area at point C(in^2)\n", - "sB=(F1/Ae) #Bearing Stress in Link at C\n", - "\n", - "\n", - "#Result\n", - "print('Case(a): Shearing Stress in Pin A = %.1f psi' %tA)\n", - "print('Case(b): Shearing Stress in Pin C = %.f psi' %tC)\n", - "print('Case(c): Largest Normal Stress in Link ABC = %.f psi' %sA)\n", - "print('Case(d): Average Shearing Stress at B = %.f psi' %tB)\n", - "print('Case(e): Bearing Stress in Link at C = %.f psi' %sB)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.2, Page number 19" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Case(a): Diameter of the bolt = 28 mm\n", - "Case(a): Dimension b at Each End of the Bar = 62 mm\n", - "Case(a): Dimension h of the Bar = 34.300000 mm\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "P = 120 #Maximum allowable tension force \n", - "s = 175 #Maximum allowable stress\n", - "t = 100 #Maximum allowable stress\n", - "Sb = 350 #Maximum allowable stress\n", - "\n", - "\n", - "#Calculation\n", - "#Case(a)\n", - "F1=P/2 #Current(A)\n", - "d=math.sqrt(((P/2)*1000)/((22/(4*7))*(100000000))) #Diameter of bolt(m)\n", - "d=d*1000 #Diameter of bolt(mm)\n", - "d=round(d,0) #Rounding of the value of diameter of bolt(mm)\n", - "Ad=(0.020*0.028) #Area of cross section of plate \n", - "tb=((P*1000)/Ad)/(1000000) #Stress between between the 20-mm-thick plate and the 28-mm-diameter bolt\n", - "tb=round(tb,0) #Rounding of the above calculated stress to check if it is less than 350\n", - "a=(P/2)/((0.02)*(175)) #Dimension of cross section of ring \n", - "a=round(a,2) #Rounding dimension of cross section of ring to two decimal places\n", - "b=28 + (2*(a)) #Dimension b at Each End of the Bar\n", - "b=round(b,2) #Rounding the dimension b to two decimal places \n", - "h=(P)/((0.020)*(175)) #Dimension h of the Bar\n", - "h=round(h,1) #Rounding dimension h of bar to 1 decimal place\n", - "\n", - "\n", - "#Result\n", - "print ('Case(a): Diameter of the bolt = %.f mm' %d)\n", - "print ('Case(a): Dimension b at Each End of the Bar = %.f mm' %b)\n", - "print ('Case(a): Dimension h of the Bar = %f mm' %h)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.3, Page number 34" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Case(a): Diameter of the bolt = 16.730000 mm\n", - "Case(a): Dimension b at Each End of the Bar = 22.000000 mm\n", - "Case(a): Dimension h of the Bar = 6.000000 mm\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "Su = 600 #ultimate normal stress(MPa) \n", - "FS = 3.3 #Factor of safety with respect to failure\n", - "tU=350 #Ultimate shearing stress(MPa)\n", - "Cx=40 #X Component of reaction at C(kN)\n", - "Cy=65 #Y Component of reaction at C(kN)\n", - "Smax=300 #Allowable bearing stress of the steel \n", - "\n", - "#Calculation\n", - "C=math.sqrt((math.pow(40,2))+(math.pow(65,2)))\n", - "\n", - "#Case(a)\n", - "P=(15*0.6 + 50*0.3)/(0.6) #Allowable bearing stress of the steel(MPa)\n", - "Sall=(Su/FS) #Allowable Stress(MPa)\n", - "Sall=round(Sall,1) #Rounding Allowable stress to 1 decimal place(MPa)\n", - "Areqa=(P/(Sall*(1000))) #Cross Sectional area(m^2)\n", - "Areqa=round(Areqa,5) #Rounding cross sectional area to 5 decimal places(m^2)\n", - "dAB=math.sqrt(((Areqa)*(4))/(22/7)) #Diameter of AB(m)\n", - "dAB=dAB*1000 #Diameter of AB(mm)\n", - "dAB=round(dAB,2) #Rounding Diameter of AB(mm)\n", - "\n", - "#Case(b)\n", - "tALL=tU/FS #Stress(MPa)\n", - "tALL=round(tALL,1) #Rounding of Stress\n", - "AreqC=((C/2)/tALL) #Cross sectional area(m^2)\n", - "AreqC=AreqC*1000 \n", - "AreqC=round(AreqC,0) #Rounding the cross sectional area\n", - "dC=math.sqrt((4*AreqC)/(22/7)) #Diameter at point C\n", - "dC=round((dC+1),0) #Rounding of the diameter at C\n", - "\n", - "#Case(c)\n", - "\n", - "Areq=((C/2)/Smax) \n", - "Areq=Areq*1000 #Cross sectional area(mm^2)\n", - "t=(Areq/22) #Thickness of the bracket\n", - "t=round(t,0)\n", - "\n", - "#Result\n", - "print ('Case(a): Diameter of the bolt = % f mm' %dAB)\n", - "print ('Case(a): Dimension b at Each End of the Bar = % f mm' %dC)\n", - "print ('Case(a): Dimension h of the Bar = % f mm' %t)" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 1.4, Page number 35" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Case(a): Control Rod = 5.263672 kips\n", - "Case(b): Bolt at B = 5.156250 kips\n", - "Case(c): Bolt at D = 6.865179 kips\n", - "Case(d): Bolt at C = 5.238095 kips\n", - "Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:= 5.156250 kips\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#Variable declaration\n", - "tU=40 #ultimate tensile stress\n", - "sU=60 #ultimate shearing stress\n", - "FS=3 #Mimnimum factor of safety\n", - "dA=(7/16) #Diameter of bolt at A(in)\n", - "dB=3/8 #Diameter of bolt at B(in) \n", - "dD=3/8 #Diameter of bolt at D(in)\n", - "dC=1/2 #Diameter of bolt at C(in)\n", - "\n", - "\n", - "#Calculation\n", - "Sall=(sU/FS) #Total tensile stress(kips)\n", - "B=Sall*((1/4)*(22/7)*(pow((7/16),2))) #Allowable force in the control rod(kips)\n", - "C1=1.75*(B) #Control Rod(kips)\n", - "tall=(tU/FS) #Total shearing stress\n", - "B=2*(tall*(1/4)*(22/7)*(3/8)*(3/8)) #Allowable magnitude of the force B exerted on the bolt\n", - "C2=1.75*B #Bolt at B(kips) \n", - "D=B #Bolt at D. Since this bolt is the same as bolt B, the allowable force is same(kips) \n", - "C3=2.33*D #Bolt at D(kips)\n", - "C4=2*(tall*(1/4)*(22/7)*(1/2)*(1/2)) #Bolt at C(kips) \n", - "list1=[C1,C2,C3,C4] #Adding all the maximum allowable forces on C(kips) \n", - "\n", - "\n", - "#Result\n", - "print ('Case(a): Control Rod = % f kips' %C1)\n", - "print ('Case(b): Bolt at B = % f kips' %C2)\n", - "print ('Case(c): Bolt at D = % f kips' %C3)\n", - "print ('Case(d): Bolt at C = % f kips' %C4)\n", - "print ('Summary. We have found separately four maximum allowable values of the force C. In order to satisfy all these criteria we must choose the smallest value, namely:= % f kips' %min(list1));" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.5.1" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SantoshPawar/Chapter9.ipynb b/sample_notebooks/SantoshPawar/Chapter9.ipynb deleted file mode 100755 index 1ffaf482..00000000 --- a/sample_notebooks/SantoshPawar/Chapter9.ipynb +++ /dev/null @@ -1,569 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 09 : Transistor Biasing and Thermal Stabilization" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.1, Page No 55" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#initialisation of variables\n", - "Vcc=22.5 #in V\n", - "Rc=5.6 #in K\n", - "Re=1.0 #in K\n", - "R2=10.0 #in K\n", - "R1=90.0 #in K\n", - "B=55.0 #beta\n", - "\n", - "#Calculations\n", - "V=(R2*Vcc)/(R2+R1) #Thevenin Equivallent Voltage\n", - "Rb=(R2*R1)/(R2+R1) #Thevenin Equivallent Resistance\n", - "\n", - "#For base current large compared to reverse saturation current ie Ib>>Ico it follows that Ic=B*Ib\n", - "#Applying KVL to the base circuit\n", - "#0.65-2.25+Ic+10*Ib=0\n", - "#We have -1.60+Ic+(10/55)*Ic=0\n", - "\n", - "Ic=1.60/(65.0/55);\n", - "Ib=Ic/55.0\n", - "\n", - "#Applying KVL to the collector circuit yields\n", - "#-22.5+6.6*Ic+Ib+Vce\n", - "\n", - "Vce = 22.5-(6.6*1.36)-0.025\n", - "\n", - "#Results\n", - "print(\"The equivallent Vbb = %.2f Volts \" %V)\n", - "print(\"The equivallent Rb is = %.2f ohm \" %Rb)\n", - "print(\"As B=55 we have Ic=55*Ib \")\n", - "print(\" Ic= %.2f milli amp \" %Ic)\n", - "print(\"Ib= %.2f micro amp \" %Ib)\n", - "print(\"Vce= %.2f Volts \" %Vce)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The equivallent Vbb = 2.25 Volts \n", - "The equivallent Rb is = 9.00 ohm \n", - "As B=55 we have Ic=55*Ib \n", - " Ic= 1.35 milli amp \n", - "Ib= 0.02 micro amp \n", - "Vce= 13.50 Volts \n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.2, Page No 61" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialisation of variables\n", - "Rc=4.0 #in K\n", - "Vcc=20.0 #in V\n", - "Vce=10.0 #in V\n", - "Ic=2.0 #in mA\n", - "#Ic varies from 1.75 to 2.25 and B(beta) varies from 36 to 90\n", - "Re = (Vcc-Vce)/Ic - Rc\n", - "#S=delta Ic/delta B\n", - "Ic2=2.25 #in mA\n", - "Ic1=1.75 #in mA\n", - "B2=90.0\n", - "B1=36.0\n", - "\n", - "#Calculations\n", - "S=(Ic2-Ic1)/(B2-B1)\n", - "S2=(S*36*(1+90))/1.75\n", - "#S2=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", - "Rb=(S2-1)*(1+B2)*Re/(1+B2-S2);\n", - "Vbe=0.65 #in V\n", - "V = Vbe + ((Rb+Re*(1+B1))*Ic1/B1);\n", - "R1=Rb*Vcc/V\n", - "R2=R1*V/(Vcc-V)\n", - "\n", - "#Results\n", - "print(\"S2 = %.2f K \" %S2)\n", - "print(\"Re = is %.2f B2=90 \" %Re)\n", - "print(\"Rb= %.2f K \" %Rb)\n", - "print(\"V = %.2f Volts \" %V)\n", - "print(\"R1= %.2f K \" %R1)\n", - "print(\"R2= %.2f K \" %R2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "S2 = 17.33 K \n", - "Re = is 1.00 B2=90 \n", - "Rb= 20.18 K \n", - "V = 3.43 Volts \n", - "R1= 117.67 K \n", - "R2= 24.35 K \n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.3a Page No 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialisation of variables\n", - "Re=4.7 #in K\n", - "Rb=7.75 #in K\n", - "B1=55.0 #/beta at 25degree C\n", - "Ic1=1.5 #in mA\n", - "Ico1=1.0\n", - "Vbe1=0.6 #in V\n", - "\n", - "#Part a\n", - "\n", - "Ico2=33000.0 #in nA\n", - "Vbe2=0.225 #in V\n", - "\n", - "#Calculations\n", - "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", - "B2=100.0 #at 175degree C\n", - "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", - "\n", - "print(\"Stabitity Factor at 25deree C= %.2f \" %M1)\n", - "print(\"Stabitity Factor at 175deree C= %.2f \" %M2)\n", - "\n", - "if M2>M1 :\n", - " M1=1.0\n", - " M2=1.0\n", - "\n", - "\n", - "#Let k = (delta Ic)/(Ic1)\n", - "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", - "deltaIc=k*Ic1\n", - "print(\"Change in Collector Current at 175degree C is = %.2f mA\" %deltaIc)\n", - "\n", - "\n", - "#Given Data at -65degree C\n", - "Ico2=1.95*(10**-3)\n", - "B2=25.0\n", - "Vbe2=0.78\n", - "\n", - "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", - "print(\"Stabitity Factor at -65deree C= %.2f \" %M2)\n", - " \n", - "#Let k = (delta Ic)/(Ic1)\n", - "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1))\n", - "deltaIc=k*Ic1\n", - "\n", - "#Results\n", - "print(\"Change in Collector Current at -65degree C is = %.2f mA\" %deltaIc)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Stabitity Factor at 25deree C= 0.97 \n", - "Stabitity Factor at 175deree C= 0.98 \n", - "Change in Collector Current at 175degree C is = 0.11 mA\n", - "Stabitity Factor at -65deree C= 0.94 \n", - "Change in Collector Current at -65degree C is = -0.12 mA\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.3b, Page No 70" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#initialisation of variables\n", - "Re=4.7 #in K\n", - "Rb=7.75 #in K\n", - "B1=55.0 #/beta at 25degree C\n", - "Ic1=1.5 #in mA\n", - "Ico1=1.0\n", - "Vbe1=0.6 #in V\n", - "\n", - "\n", - "#Part a\n", - "\n", - "Ico2=33000.0 #in nA\n", - "Vbe2=0.225 #in V\n", - "\n", - "#Calculations\n", - "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", - "#Given Data at -65degree C\n", - "Ico2=1.95*(10**-3)\n", - "B2=25.0 #at -65degree C\n", - "Vbe2=0.78\n", - "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", - "\n", - "#Let k = (delta Ic)/(Ic1)\n", - "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", - "deltaIc=k*Ic1\n", - "\n", - "\n", - "\n", - "#Given Data\n", - "Ico2=32.0 #in nA\n", - "Vbe2=0.10 #in V\n", - "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", - "print(\"Stabitity Factor at 25deree C= %.2f \" %M1)\n", - "B2=90.0 #at 175degree C\n", - "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", - "print(\"Stabitity Factor at 75deree C= %.2f \" %M2)\n", - "\n", - "if M2>M1 :\n", - " M1=1.0\n", - " M2=1.0\n", - "\n", - "#Let k = (delta Ic)/(Ic1)\n", - "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", - "deltaIc=k*Ic1\n", - "print(\"Change in Collector Current at 75degree C is = %.2f mA\" %deltaIc)\n", - "\n", - "#Given Data at -65degree C\n", - "Ico2=1.95*(10**-3)\n", - "B2=20.0\n", - "Vbe2=0.38\n", - "\n", - "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", - "print(\"Stabitity Factor at -65deree C= %.2f \" %M2)\n", - " \n", - " \n", - "#Let k = (delta Ic)/(Ic1)\n", - "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", - "deltaIc=k*Ic1\n", - "print(\"Change in Collector Current at -65degree C is = %.2f mA\" %deltaIc)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Stabitity Factor at 25deree C= 0.97 \n", - "Stabitity Factor at 75deree C= 0.98 \n", - "Change in Collector Current at 75degree C is = 0.13 mA\n", - "Stabitity Factor at -65deree C= 0.92 \n", - "Change in Collector Current at -65degree C is = -0.07 mA\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.4 Page No 71" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#initialisation of variables\n", - "\n", - "B1=150.0 #beta\n", - "Ico1=50.0 #in nA\n", - "\n", - "#Given Data at 65degree C\n", - "B2=1200.0 #beta\n", - "Ico2=3.0 #in micro A\n", - "\n", - "Vbe=0.65 #in mV\n", - "Vcc=20.0 #in V\n", - "M=1.0 \n", - "#Assumption: Each factor Ico,B, and Vbe cuses the same percentge change(5%)\n", - "\n", - "#Let Rb/Re=k\n", - "#(1+k)*((1200-150)/(1200*150))=0.05\n", - "\n", - "\n", - "#Calculations\n", - "k=((0.05)*((1200*150)/(1200-150)))-1\n", - "print(\"Rb/Re = %.2f \" %k)\n", - "#Let us check our assumption\n", - "\n", - "if M>(1.0/(1+(k/B1))) :\n", - " M=1.0\n", - "\n", - "#(1+(Rb/Re))*((Ico2-Ico1)/Ic1)=0.05 Since Ico2>>Ico1, we consider only Ico2\n", - "\n", - "Ic1=((1+k)*Ico2)/(0.05*1000)\n", - "print(\"Ic1= %.2f mA \" %Ic1)\n", - "\n", - "#Vbe changes 2.5mV/degree\n", - "DVbe=2.5*40\n", - "#Total increment\n", - "dVbe=2*DVbe*(10**-3)\n", - "\n", - "#Let l=(Ic1*Re)\n", - "l=dVbe/0.05\n", - "\n", - "Re=l/Ic1\n", - "print(\"Re= %.2f \" %Re)\n", - "Rb=k*Re\n", - "print(\"Rb= %.2f \" %Rb)\n", - "\n", - "B=(B1+B2)/2 #beta\n", - "V=((Ic1/B)*Rb)+(Vbe)+(((Ic1/B)+Ic1)*Re)\n", - "print(\"V= %.2f Volts\" %V)\n", - "R1=(Rb*Vcc)/V\n", - "R2=(R1*V)/(Vcc-V)\n", - "\n", - "#Results\n", - "print(\"R1= %.2f ohm\" %R1)\n", - "print(\"R2= %.2f ohm\" %R2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Rb/Re = 7.55 \n", - "Ic1= 0.51 mA \n", - "Re= 7.80 \n", - "Rb= 58.87 \n", - "V= 4.70 Volts\n", - "R1= 250.47 ohm\n", - "R2= 76.96 ohm\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.5 Page No 78" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#initialisation of variables\n", - "\n", - "Vcc=30.0 #in V\n", - "Rc=2.0 #in K\n", - "Re=4.7 #in K\n", - "Ic=1.5 #in mA\n", - "\n", - "#We know that dPc/dIc = Vcc - (2*Ic*(Rc+Re))\n", - "#Let D=dPc/dIc\n", - "\n", - "D = Vcc - (2*Ic*(Re+Rc))\n", - "\n", - "print('Ic increases by 0.131mA over a temprature range of 35 to 75 degree C')\n", - "print('theta<(A=(dPc/dIc)*(dIc/dTc))')\n", - "A=D*((0.131*(10^-3))/(75-25))\n", - "\n", - "#Results\n", - "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n", - "print('The upper bound on theta is so high that transistor would not violate it and therefore circuit will be safe from thermal runaway')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Ic increases by 0.131mA over a temprature range of 35 to 75 degree C\n", - "theta<(A=(dPc/dIc)*(dIc/dTc))\n", - "theta< -4.28 degreeC/W \n", - "The upper bound on theta is so high that transistor would not violate it and therefore circuit will be safe from thermal runaway\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.6a, Page No 79 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#initialisation of variables\n", - "B=100.0 #beta\n", - "Ico=-5.0 #in mA\n", - "Ic=-1.0 #in mA\n", - "Vcc=40.0 \n", - "Re=5.0 #in ohm\n", - "Rc=10.0 #in ohm\n", - "\n", - "\n", - "#Calculations\n", - "#Ic= BIb + (1+B)*Ico\n", - "#Ic=B(Ib+Ico)\n", - "Ib=-(Ic/B)+Ico\n", - "\n", - "print(\"Ib= %.2f mA \" %Ib)\n", - "#Neglecting Vbe\n", - "Rb=(5-Vcc)/(Ib*0.001)\n", - "print(\"Rb= %.2f ohm \" %Rb)\n", - "\n", - "Vce=Vcc-15\n", - "if Vce>(Vcc/2) :\n", - " S=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", - " print(\"Stability Factor is= %.2f \" %S)\n", - "\n", - "A=-(Vcc+(2*Ic*(Re+Rc)))*(S)*(0.007*Ico*0.01)\n", - "\n", - "\n", - "#Results\n", - "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Ib= -4.99 mA \n", - "Rb= 7014.03 ohm \n", - "Stability Factor is= 94.28 \n", - "theta< 3.03 degreeC/W \n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.6b Page No 80" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#initialisation of variables\n", - "B=100.0 #beta\n", - "Ico=-5.0 #in mA\n", - "Ic=-1.0 #in mA\n", - "Vcc=40.0 \n", - "Re=5.0 #in ohm\n", - "Rc=10.0 #in ohm\n", - "\n", - "#Calculations\n", - "#Ic= BIb + (1+B)*Ico\n", - "#Ic=B(Ib+Ico)\n", - "Ib=-(Ic/B)+Ico\n", - "\n", - "#Neglecting Vbe\n", - "Rb=(5-Vcc)/(Ib*0.001)\n", - "\n", - "Vce=Vcc-15\n", - "if Vce>(Vcc/2) :\n", - " S=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", - " print(\"Stability Factor is= %.2f \" %S)\n", - "\n", - "A=-(Vcc+(2*Ic*(Re+Rc)))*(S)*(0.007*Ico*0.01)\n", - "\n", - "\n", - "#Results\n", - "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Ib= -4.99 mA \n", - "Rb= 7014.03 ohm \n", - "Stability Factor is= 94.28 \n", - "theta< 3.03 degreeC/W \n" - ] - } - ], - "prompt_number": 15 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SantoshPawar/SantoshPawar_version_backup/Chapter9.ipynb b/sample_notebooks/SantoshPawar/SantoshPawar_version_backup/Chapter9.ipynb new file mode 100755 index 00000000..1ffaf482 --- /dev/null +++ b/sample_notebooks/SantoshPawar/SantoshPawar_version_backup/Chapter9.ipynb @@ -0,0 +1,569 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 09 : Transistor Biasing and Thermal Stabilization" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.1, Page No 55" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#initialisation of variables\n", + "Vcc=22.5 #in V\n", + "Rc=5.6 #in K\n", + "Re=1.0 #in K\n", + "R2=10.0 #in K\n", + "R1=90.0 #in K\n", + "B=55.0 #beta\n", + "\n", + "#Calculations\n", + "V=(R2*Vcc)/(R2+R1) #Thevenin Equivallent Voltage\n", + "Rb=(R2*R1)/(R2+R1) #Thevenin Equivallent Resistance\n", + "\n", + "#For base current large compared to reverse saturation current ie Ib>>Ico it follows that Ic=B*Ib\n", + "#Applying KVL to the base circuit\n", + "#0.65-2.25+Ic+10*Ib=0\n", + "#We have -1.60+Ic+(10/55)*Ic=0\n", + "\n", + "Ic=1.60/(65.0/55);\n", + "Ib=Ic/55.0\n", + "\n", + "#Applying KVL to the collector circuit yields\n", + "#-22.5+6.6*Ic+Ib+Vce\n", + "\n", + "Vce = 22.5-(6.6*1.36)-0.025\n", + "\n", + "#Results\n", + "print(\"The equivallent Vbb = %.2f Volts \" %V)\n", + "print(\"The equivallent Rb is = %.2f ohm \" %Rb)\n", + "print(\"As B=55 we have Ic=55*Ib \")\n", + "print(\" Ic= %.2f milli amp \" %Ic)\n", + "print(\"Ib= %.2f micro amp \" %Ib)\n", + "print(\"Vce= %.2f Volts \" %Vce)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The equivallent Vbb = 2.25 Volts \n", + "The equivallent Rb is = 9.00 ohm \n", + "As B=55 we have Ic=55*Ib \n", + " Ic= 1.35 milli amp \n", + "Ib= 0.02 micro amp \n", + "Vce= 13.50 Volts \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.2, Page No 61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialisation of variables\n", + "Rc=4.0 #in K\n", + "Vcc=20.0 #in V\n", + "Vce=10.0 #in V\n", + "Ic=2.0 #in mA\n", + "#Ic varies from 1.75 to 2.25 and B(beta) varies from 36 to 90\n", + "Re = (Vcc-Vce)/Ic - Rc\n", + "#S=delta Ic/delta B\n", + "Ic2=2.25 #in mA\n", + "Ic1=1.75 #in mA\n", + "B2=90.0\n", + "B1=36.0\n", + "\n", + "#Calculations\n", + "S=(Ic2-Ic1)/(B2-B1)\n", + "S2=(S*36*(1+90))/1.75\n", + "#S2=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", + "Rb=(S2-1)*(1+B2)*Re/(1+B2-S2);\n", + "Vbe=0.65 #in V\n", + "V = Vbe + ((Rb+Re*(1+B1))*Ic1/B1);\n", + "R1=Rb*Vcc/V\n", + "R2=R1*V/(Vcc-V)\n", + "\n", + "#Results\n", + "print(\"S2 = %.2f K \" %S2)\n", + "print(\"Re = is %.2f B2=90 \" %Re)\n", + "print(\"Rb= %.2f K \" %Rb)\n", + "print(\"V = %.2f Volts \" %V)\n", + "print(\"R1= %.2f K \" %R1)\n", + "print(\"R2= %.2f K \" %R2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "S2 = 17.33 K \n", + "Re = is 1.00 B2=90 \n", + "Rb= 20.18 K \n", + "V = 3.43 Volts \n", + "R1= 117.67 K \n", + "R2= 24.35 K \n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.3a Page No 69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialisation of variables\n", + "Re=4.7 #in K\n", + "Rb=7.75 #in K\n", + "B1=55.0 #/beta at 25degree C\n", + "Ic1=1.5 #in mA\n", + "Ico1=1.0\n", + "Vbe1=0.6 #in V\n", + "\n", + "#Part a\n", + "\n", + "Ico2=33000.0 #in nA\n", + "Vbe2=0.225 #in V\n", + "\n", + "#Calculations\n", + "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", + "B2=100.0 #at 175degree C\n", + "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", + "\n", + "print(\"Stabitity Factor at 25deree C= %.2f \" %M1)\n", + "print(\"Stabitity Factor at 175deree C= %.2f \" %M2)\n", + "\n", + "if M2>M1 :\n", + " M1=1.0\n", + " M2=1.0\n", + "\n", + "\n", + "#Let k = (delta Ic)/(Ic1)\n", + "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", + "deltaIc=k*Ic1\n", + "print(\"Change in Collector Current at 175degree C is = %.2f mA\" %deltaIc)\n", + "\n", + "\n", + "#Given Data at -65degree C\n", + "Ico2=1.95*(10**-3)\n", + "B2=25.0\n", + "Vbe2=0.78\n", + "\n", + "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", + "print(\"Stabitity Factor at -65deree C= %.2f \" %M2)\n", + " \n", + "#Let k = (delta Ic)/(Ic1)\n", + "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1))\n", + "deltaIc=k*Ic1\n", + "\n", + "#Results\n", + "print(\"Change in Collector Current at -65degree C is = %.2f mA\" %deltaIc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Stabitity Factor at 25deree C= 0.97 \n", + "Stabitity Factor at 175deree C= 0.98 \n", + "Change in Collector Current at 175degree C is = 0.11 mA\n", + "Stabitity Factor at -65deree C= 0.94 \n", + "Change in Collector Current at -65degree C is = -0.12 mA\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.3b, Page No 70" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#initialisation of variables\n", + "Re=4.7 #in K\n", + "Rb=7.75 #in K\n", + "B1=55.0 #/beta at 25degree C\n", + "Ic1=1.5 #in mA\n", + "Ico1=1.0\n", + "Vbe1=0.6 #in V\n", + "\n", + "\n", + "#Part a\n", + "\n", + "Ico2=33000.0 #in nA\n", + "Vbe2=0.225 #in V\n", + "\n", + "#Calculations\n", + "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", + "#Given Data at -65degree C\n", + "Ico2=1.95*(10**-3)\n", + "B2=25.0 #at -65degree C\n", + "Vbe2=0.78\n", + "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", + "\n", + "#Let k = (delta Ic)/(Ic1)\n", + "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", + "deltaIc=k*Ic1\n", + "\n", + "\n", + "\n", + "#Given Data\n", + "Ico2=32.0 #in nA\n", + "Vbe2=0.10 #in V\n", + "M1=1/(1+(Rb/(Re*B1))) #Stability Factor\n", + "print(\"Stabitity Factor at 25deree C= %.2f \" %M1)\n", + "B2=90.0 #at 175degree C\n", + "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", + "print(\"Stabitity Factor at 75deree C= %.2f \" %M2)\n", + "\n", + "if M2>M1 :\n", + " M1=1.0\n", + " M2=1.0\n", + "\n", + "#Let k = (delta Ic)/(Ic1)\n", + "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", + "deltaIc=k*Ic1\n", + "print(\"Change in Collector Current at 75degree C is = %.2f mA\" %deltaIc)\n", + "\n", + "#Given Data at -65degree C\n", + "Ico2=1.95*(10**-3)\n", + "B2=20.0\n", + "Vbe2=0.38\n", + "\n", + "M2=1/(1+(Rb/(Re*B2))) #Stability Factor\n", + "print(\"Stabitity Factor at -65deree C= %.2f \" %M2)\n", + " \n", + " \n", + "#Let k = (delta Ic)/(Ic1)\n", + "k=(1+(Rb/Re))*(M1*(Ico2-Ico1)*(10**-9)/Ic1*(10**-3))-(M1*(Vbe2-Vbe1)/(Ic1*Re))+(1+(Rb/Re))*(M2*(B2-B1)/(B2*B1));\n", + "deltaIc=k*Ic1\n", + "print(\"Change in Collector Current at -65degree C is = %.2f mA\" %deltaIc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Stabitity Factor at 25deree C= 0.97 \n", + "Stabitity Factor at 75deree C= 0.98 \n", + "Change in Collector Current at 75degree C is = 0.13 mA\n", + "Stabitity Factor at -65deree C= 0.92 \n", + "Change in Collector Current at -65degree C is = -0.07 mA\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.4 Page No 71" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#initialisation of variables\n", + "\n", + "B1=150.0 #beta\n", + "Ico1=50.0 #in nA\n", + "\n", + "#Given Data at 65degree C\n", + "B2=1200.0 #beta\n", + "Ico2=3.0 #in micro A\n", + "\n", + "Vbe=0.65 #in mV\n", + "Vcc=20.0 #in V\n", + "M=1.0 \n", + "#Assumption: Each factor Ico,B, and Vbe cuses the same percentge change(5%)\n", + "\n", + "#Let Rb/Re=k\n", + "#(1+k)*((1200-150)/(1200*150))=0.05\n", + "\n", + "\n", + "#Calculations\n", + "k=((0.05)*((1200*150)/(1200-150)))-1\n", + "print(\"Rb/Re = %.2f \" %k)\n", + "#Let us check our assumption\n", + "\n", + "if M>(1.0/(1+(k/B1))) :\n", + " M=1.0\n", + "\n", + "#(1+(Rb/Re))*((Ico2-Ico1)/Ic1)=0.05 Since Ico2>>Ico1, we consider only Ico2\n", + "\n", + "Ic1=((1+k)*Ico2)/(0.05*1000)\n", + "print(\"Ic1= %.2f mA \" %Ic1)\n", + "\n", + "#Vbe changes 2.5mV/degree\n", + "DVbe=2.5*40\n", + "#Total increment\n", + "dVbe=2*DVbe*(10**-3)\n", + "\n", + "#Let l=(Ic1*Re)\n", + "l=dVbe/0.05\n", + "\n", + "Re=l/Ic1\n", + "print(\"Re= %.2f \" %Re)\n", + "Rb=k*Re\n", + "print(\"Rb= %.2f \" %Rb)\n", + "\n", + "B=(B1+B2)/2 #beta\n", + "V=((Ic1/B)*Rb)+(Vbe)+(((Ic1/B)+Ic1)*Re)\n", + "print(\"V= %.2f Volts\" %V)\n", + "R1=(Rb*Vcc)/V\n", + "R2=(R1*V)/(Vcc-V)\n", + "\n", + "#Results\n", + "print(\"R1= %.2f ohm\" %R1)\n", + "print(\"R2= %.2f ohm\" %R2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Rb/Re = 7.55 \n", + "Ic1= 0.51 mA \n", + "Re= 7.80 \n", + "Rb= 58.87 \n", + "V= 4.70 Volts\n", + "R1= 250.47 ohm\n", + "R2= 76.96 ohm\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 Page No 78" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#initialisation of variables\n", + "\n", + "Vcc=30.0 #in V\n", + "Rc=2.0 #in K\n", + "Re=4.7 #in K\n", + "Ic=1.5 #in mA\n", + "\n", + "#We know that dPc/dIc = Vcc - (2*Ic*(Rc+Re))\n", + "#Let D=dPc/dIc\n", + "\n", + "D = Vcc - (2*Ic*(Re+Rc))\n", + "\n", + "print('Ic increases by 0.131mA over a temprature range of 35 to 75 degree C')\n", + "print('theta<(A=(dPc/dIc)*(dIc/dTc))')\n", + "A=D*((0.131*(10^-3))/(75-25))\n", + "\n", + "#Results\n", + "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n", + "print('The upper bound on theta is so high that transistor would not violate it and therefore circuit will be safe from thermal runaway')\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Ic increases by 0.131mA over a temprature range of 35 to 75 degree C\n", + "theta<(A=(dPc/dIc)*(dIc/dTc))\n", + "theta< -4.28 degreeC/W \n", + "The upper bound on theta is so high that transistor would not violate it and therefore circuit will be safe from thermal runaway\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6a, Page No 79 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#initialisation of variables\n", + "B=100.0 #beta\n", + "Ico=-5.0 #in mA\n", + "Ic=-1.0 #in mA\n", + "Vcc=40.0 \n", + "Re=5.0 #in ohm\n", + "Rc=10.0 #in ohm\n", + "\n", + "\n", + "#Calculations\n", + "#Ic= BIb + (1+B)*Ico\n", + "#Ic=B(Ib+Ico)\n", + "Ib=-(Ic/B)+Ico\n", + "\n", + "print(\"Ib= %.2f mA \" %Ib)\n", + "#Neglecting Vbe\n", + "Rb=(5-Vcc)/(Ib*0.001)\n", + "print(\"Rb= %.2f ohm \" %Rb)\n", + "\n", + "Vce=Vcc-15\n", + "if Vce>(Vcc/2) :\n", + " S=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", + " print(\"Stability Factor is= %.2f \" %S)\n", + "\n", + "A=-(Vcc+(2*Ic*(Re+Rc)))*(S)*(0.007*Ico*0.01)\n", + "\n", + "\n", + "#Results\n", + "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Ib= -4.99 mA \n", + "Rb= 7014.03 ohm \n", + "Stability Factor is= 94.28 \n", + "theta< 3.03 degreeC/W \n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.6b Page No 80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#initialisation of variables\n", + "B=100.0 #beta\n", + "Ico=-5.0 #in mA\n", + "Ic=-1.0 #in mA\n", + "Vcc=40.0 \n", + "Re=5.0 #in ohm\n", + "Rc=10.0 #in ohm\n", + "\n", + "#Calculations\n", + "#Ic= BIb + (1+B)*Ico\n", + "#Ic=B(Ib+Ico)\n", + "Ib=-(Ic/B)+Ico\n", + "\n", + "#Neglecting Vbe\n", + "Rb=(5-Vcc)/(Ib*0.001)\n", + "\n", + "Vce=Vcc-15\n", + "if Vce>(Vcc/2) :\n", + " S=(1+B)*(1+(Rb/Re))/(1+B+(Rb/Re))\n", + " print(\"Stability Factor is= %.2f \" %S)\n", + "\n", + "A=-(Vcc+(2*Ic*(Re+Rc)))*(S)*(0.007*Ico*0.01)\n", + "\n", + "\n", + "#Results\n", + "print(\"theta< %.2f degreeC/W \" %(1.0/A))\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Ib= -4.99 mA \n", + "Rb= 7014.03 ohm \n", + "Stability Factor is= 94.28 \n", + "theta< 3.03 degreeC/W \n" + ] + } + ], + "prompt_number": 15 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/SaurabhBarot/SaurabhBarot_version_backup/ch2.ipynb b/sample_notebooks/SaurabhBarot/SaurabhBarot_version_backup/ch2.ipynb new file mode 100755 index 00000000..79ba56c5 --- /dev/null +++ b/sample_notebooks/SaurabhBarot/SaurabhBarot_version_backup/ch2.ipynb @@ -0,0 +1,510 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:883876eb2a3f623c02ca3c86ebd8020a1b244805e7be4ab0f882af58fcdc4d16" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 : MAGNETIC CIRCUITS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.1 Page No : 89" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "N = 2000.;\t\t\t#no of turns\n", + "I = 10.;\t\t\t#current in A\n", + "Rm = 25.;\t\t\t#mean radius in cm\n", + "d = 6.;\t\t\t#diameter of each turn in cm\n", + "\n", + "#CALCULATIONS \n", + "MMF = N*I;\t\t\t#magneto motive force in A\n", + "l = 2*math.pi*(Rm/100);\t\t\t#circumference of coli in m\n", + "u = (4*math.pi*10**-7);\t\t\t#permeability (U = Ur*U0)\n", + "a = (math.pi*d*d*10**-4)/4;\n", + "reluctance = (l/(a*u));\t\t\t#reluctance in At/Wb\n", + "flux = (MMF)/(reluctance);\t\t\t#flux in Wb\n", + "fluxdensity = (flux/a);\t\t\t#flux density in Wb/m**2 or tesla\n", + "\n", + "#OUTPUT\n", + "print \"Thus MMF, flux, flux density are %d A, %g Wb , %g Wb/m**2 or Tesla respectively \"%(MMF,flux,fluxdensity);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus MMF, flux, flux density are 20000 A, 4.52389e-05 Wb , 0.016 Wb/m**2 or Tesla respectively \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 Page No : 90" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#Chapter-2, Example 2.2, Page 90\n", + "\n", + "#INPUT DATA\n", + "phi = 5*10**-2;\t\t\t#flux in wb\n", + "a = 0.2;\t\t\t#area of cross-section in m**2\n", + "lg = 1.2*10**-2;\t\t\t#length of air gap in m\n", + "ur = 1;\t\t\t#permeability\n", + "u = ur*4*math.pi*10**-7;\t\t\t#permeability\n", + "\n", + "#CALCULATIONS \n", + "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", + "H = (B/(4*math.pi*10**-7*ur));\t\t\t#magnetic flux density in A/m\n", + "S = lg/(a*u);\t\t\t#reluctance of air gap in A/wb\n", + "permeance = 1/S;\t\t\t#permenace in A/wb\n", + "mmf_in_airgap = phi*S;\t\t\t#mmf in A\n", + "\n", + "#OUTPUT\n", + "print \"Thus B, H,S, permeance, MMF in air gap are %1.2f Wb/sq.m, %g A/m ,%f A/wb ,\\\n", + "%g Wb/A %d A respectively \"%(B,H,S,permeance,mmf_in_airgap);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus B, H,S, permeance, MMF in air gap are 0.25 Wb/sq.m, 198944 A/m ,47746.482928 A/wb ,2.0944e-05 Wb/A 2387 A respectively \n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page No : 90" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "phi = 0.1*10**-3;\t\t\t#flux in wb\n", + "a = 1.7*10**-4;\t\t\t#area of cross-section in m**2\n", + "lg = 0.5*10**-3;\t\t\t#length of air gap in m\n", + "Rm = 15./2;\t\t\t#radius of ring in cm\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space in henry/m\n", + "N = 1500.;\t\t\t#no of turns of ring\n", + "\n", + "#CALCULATIONS \n", + "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", + "H = (B/(4*math.pi*10**-7));\t\t\t#magnetic flux density in A/m\n", + "ampere_turns_provided_fo = H*lg;\n", + "total_ampere_turns_provi = N*1;\n", + "Available_for_iron_path = N-(H*lg);\n", + "length_of_iron_path = (2*Rm*math.pi*10**-2)-(lg);\t\t\t#length of iron path in m\n", + "H_for_iron_path = ((N-(H*lg)))/(length_of_iron_path);\n", + "ur = (B/(u0*H_for_iron_path));\t\t\t#relative permeability of iron\n", + "\n", + "#OUTPUT\n", + "print \"Thus relative permeability of iron is %d\"%(ur);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus relative permeability of iron is 174\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page No : 91" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "li = 0.5;\t\t\t#iron path length in m\n", + "lg = 10.**-3;\t\t\t#length of air gap in m\n", + "phi = 0.9*10**-3;\t\t\t#flux in wb\n", + "a = 6.66*10**-4;\t\t\t#area of cross-section of iron in m**2\n", + "N = 400.;\t\t\t#no of turns \n", + "\n", + "#CALCULATIONS \n", + "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", + "Hg = (B/(4*math.pi*10**-7));\t\t\t#magnetic flux density in A/m\n", + "AT_required = Hg*lg;\t\t\t#AT required for air path\n", + "Hi = 1000;\t\t\t#magnetic flux density in A/m\n", + "AT_required_for_iron_pat = Hi*li;\n", + "total_AT_required = (Hg*lg)+(Hi*li);\n", + "I = ((Hg*lg)+(Hi*li))/(N);\n", + "\n", + "#OUTPUT\n", + "print \"Thus exciting current required is %1.2f A\"%(I);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus exciting current required is 3.94 A\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page No : 92" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#Chapter-2, Example 2.5, Page 92\n", + "\n", + "#INPUT DATA\n", + "r = 0.01;\t\t\t#radius in m\n", + "lg = 10.**-3;\t\t\t#length of air gap in m\n", + "Rm = (30./2)*10**-2;\t\t\t#mean radius in m\n", + "ur = 800.;\t\t\t#relative permeability of iron\n", + "ur2 = 1.;\t\t\t#relative permeability of air gap\n", + "N = 250.;\t\t\t#no of turns\n", + "phi = 20000.*10**-8;\t\t\t#flux in Wb\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space \n", + "a = math.pi*(r)**2;\t\t\t#area of cross-section in m\n", + "leakage_factor = 1.1\n", + "\n", + "#CALCULATIONS \n", + "reluctance_of_air_gap = (lg/(u0*ur2*a));\t\t\t#reluctance of air gap in A/wb\n", + "li = (math.pi*(2*r)-(lg));\t\t\t#length of iron path in m\n", + "reluctance_of_iron_path = ((math.pi*0.3)-(lg))/(4*math.pi*10**-7*800*a);\t\t\t#in A/wb\n", + "total_reluctance = reluctance_of_air_gap+reluctance_of_iron_path;\t\t\t#in A/wb\n", + "MMF = phi*total_reluctance;\t\t\t#in Ampere turns\n", + "current_required = (MMF)/(N);\t\t\t#in A\n", + "\n", + "#OUTPUT\n", + "print \"Thus current required is %1.2f A \"%(current_required);\n", + "#Including leakage\n", + "\n", + "#CALCULATIONS\n", + "MMF_of_airgap = phi*reluctance_of_air_gap;\t\t\t#in A/wb\n", + "Total_flux_in_ironpath = leakage_factor*phi;\t\t\t#in Wb\n", + "MMF_of_ironpath = Total_flux_in_ironpath*reluctance_of_iron_path;\t\t\t#in A\n", + "Total_MMF = MMF_of_ironpath+MMF_of_airgap;\t\t\t#in A/wb\n", + "current_required2 = Total_MMF/(N);\t\t\t#in A\n", + "\n", + "#OUTPUT\n", + "print \"Thus current required is %1.3f A\"%(current_required2);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus current required is 4.41 A \n", + "Thus current required is 4.650 A\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page No : 93" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "l1 = 0.1;\t\t\t#length in m\n", + "l2 = 0.18;\t\t\t#length in m\n", + "l3 = 0.18;\t\t\t#length in m\n", + "lg = 1.*10**-3;\t\t\t#airgap length in mm\n", + "a1 = 6.25*10**-4;\t\t\t#area in m**2\n", + "a2 = 3.*10**-4;\t\t\t#area in m**2\n", + "ur = 800.;\t\t\t#relative permeability of iron path\n", + "ur2 = 1.;\t\t\t#relative permeability in free space\n", + "u0 = 4*math.pi*10**-7\n", + "N = 600.;\n", + "phi = 10.**-4;\t\t\t#airgap flux in Wb\n", + "\n", + "#CALCULATIONS \n", + "#for the airgap\n", + "Bg = (phi/(a1));\t\t\t#fluxdensity in Tesla\n", + "Hg = (Bg/(u0*ur2));\t\t\t#magnetimath.sing force in A/m\n", + "MMF1 = Hg*lg;\t\t\t#in A\n", + "#for path I1\n", + "B1 = 0.16;\t\t\t# flux density in tesla\n", + "H1 = (B1/(ur*u0));\t\t\t#magnetimath.sing force in A/m\n", + "MMF2 = H1*l1;\t\t\t#in A\n", + "#math.since paths l2 and l3 are similar,the total flux divide equally between these two paths.Since these paths are in parallel,consider only one of them\n", + "#for path l2\n", + "flux = 50*10**-6;\t\t\t#flux in wb\n", + "B2 = (flux/a2);\t\t\t#fluxdensity in tesla\n", + "H2 = (B2/(ur*u0));\t\t\t#magnetimath.sing force in A/m\n", + "MMF3 = H2*l2;\t\t\t#in A\n", + "totalmmf = MMF1+MMF2+MMF3;\t\t\t#in A\n", + "I = (totalmmf/N);\t\t\t#current required in A\n", + "\n", + "#OUTPUT\n", + "print \"Thus current required is %1.3f A\"%(I);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus current required is 0.288 A\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page No : 95" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#Chapter-2, Example 2.7, Page 95\n", + "\n", + "#INPUT DATA\n", + "Dm = 0.1\t\t\t#diameter in m\n", + "a = 10.**-3;\t\t\t#area of cross-section im m**2\n", + "N = 150.;\t\t\t#no of turns\n", + "ur = 800.;\t\t\t#permeability of iron ring\n", + "B = 0.1;\t\t\t#in Wb/m**2\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeability of free space\n", + "\n", + "#CALCULATIONS \n", + "S = (math.pi*Dm)/(a*ur*u0);\t\t\t#reluctance\n", + "I = (B*a*S)/(N);\t\t\t#current in A\n", + "\n", + "#OUTPUT\n", + "print \"Thus current is %f A\"%(I);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus current is 0.208333 A\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 Page No : 95" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "l = 0.3;\t\t\t#length in m\n", + "d = 1.5*10**-2;\t\t\t#diameter in m\n", + "N = 900;\t\t\t#no of turns\n", + "ur = 1;\t\t\t#relative permeability in free space\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space\n", + "I = 5;\t\t\t#current in A\n", + "\n", + "#CALCULATIONS \n", + "a = (math.pi*(d)**2/4);\t\t\t#in m**2\n", + "S = (l)/(a*ur*u0);\t\t\t#reluctance\n", + "\n", + "#OUTPUT\n", + "print \"Thus reluctance is %f A/wb\"%(S);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus reluctance is 1350949115.231170 A/wb\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 Page No : 95" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "lg = 10**-3;\t\t\t#length of air gap in m\n", + "B = 0.9;\t\t\t#flux density in wb/m**2\n", + "li = 0.3;\t\t\t#length of ironpath in m\n", + "Hi = 800;\t\t\t#magnetic flux density in AT/m\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeabilty in free space\n", + "\n", + "#CALCULATIONS \n", + "#for iron path\n", + "MMF_required1 = Hi*li;\t\t\t#magnetic motive force in AT\n", + "#for air gap\n", + "MMF_required2 = (B/u0)*lg;\t\t\t#magnetic motive force in AT\n", + "Totalmmf = MMF_required1+MMF_required2\n", + "\n", + "#OUTPUT\n", + "print \"Thus total MMF required is %d AT\"%(Totalmmf);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus total MMF required is 956 AT\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.10 Page No : 96" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "\n", + "#INPUT DATA\n", + "li = 0.5;\t\t\t#length of iron ring mean length in m\n", + "N = 220;\t\t\t#no of turns\n", + "I = 1.2;\t\t\t#current in A\n", + "lg = 1.2*10**-3;\t\t\t#length of airgap in m\n", + "ur = 350;\t\t\t#relative permeability of iron\n", + "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space\n", + "\n", + "#CALCULATIONS \n", + "MMF_produced = N*I;\n", + "Si = li/(u0*ur);\t\t\t#reluctance of iron path\n", + "Sg = lg/(u0);\t\t\t#reluctance of air gap\n", + "S = Si+Sg;\t\t\t#total reluctance \n", + "Flux_density = (MMF_produced)/(S);\n", + "\n", + "#OUTPUT\n", + "print \"Thus fluxdensity is %1.3f Wb/m**2\"%(Flux_density);\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thus fluxdensity is 0.126 Wb/m**2\n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/SaurabhBarot/ch2.ipynb b/sample_notebooks/SaurabhBarot/ch2.ipynb deleted file mode 100755 index 79ba56c5..00000000 --- a/sample_notebooks/SaurabhBarot/ch2.ipynb +++ /dev/null @@ -1,510 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:883876eb2a3f623c02ca3c86ebd8020a1b244805e7be4ab0f882af58fcdc4d16" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 : MAGNETIC CIRCUITS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1 Page No : 89" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "N = 2000.;\t\t\t#no of turns\n", - "I = 10.;\t\t\t#current in A\n", - "Rm = 25.;\t\t\t#mean radius in cm\n", - "d = 6.;\t\t\t#diameter of each turn in cm\n", - "\n", - "#CALCULATIONS \n", - "MMF = N*I;\t\t\t#magneto motive force in A\n", - "l = 2*math.pi*(Rm/100);\t\t\t#circumference of coli in m\n", - "u = (4*math.pi*10**-7);\t\t\t#permeability (U = Ur*U0)\n", - "a = (math.pi*d*d*10**-4)/4;\n", - "reluctance = (l/(a*u));\t\t\t#reluctance in At/Wb\n", - "flux = (MMF)/(reluctance);\t\t\t#flux in Wb\n", - "fluxdensity = (flux/a);\t\t\t#flux density in Wb/m**2 or tesla\n", - "\n", - "#OUTPUT\n", - "print \"Thus MMF, flux, flux density are %d A, %g Wb , %g Wb/m**2 or Tesla respectively \"%(MMF,flux,fluxdensity);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus MMF, flux, flux density are 20000 A, 4.52389e-05 Wb , 0.016 Wb/m**2 or Tesla respectively \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2 Page No : 90" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#Chapter-2, Example 2.2, Page 90\n", - "\n", - "#INPUT DATA\n", - "phi = 5*10**-2;\t\t\t#flux in wb\n", - "a = 0.2;\t\t\t#area of cross-section in m**2\n", - "lg = 1.2*10**-2;\t\t\t#length of air gap in m\n", - "ur = 1;\t\t\t#permeability\n", - "u = ur*4*math.pi*10**-7;\t\t\t#permeability\n", - "\n", - "#CALCULATIONS \n", - "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", - "H = (B/(4*math.pi*10**-7*ur));\t\t\t#magnetic flux density in A/m\n", - "S = lg/(a*u);\t\t\t#reluctance of air gap in A/wb\n", - "permeance = 1/S;\t\t\t#permenace in A/wb\n", - "mmf_in_airgap = phi*S;\t\t\t#mmf in A\n", - "\n", - "#OUTPUT\n", - "print \"Thus B, H,S, permeance, MMF in air gap are %1.2f Wb/sq.m, %g A/m ,%f A/wb ,\\\n", - "%g Wb/A %d A respectively \"%(B,H,S,permeance,mmf_in_airgap);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus B, H,S, permeance, MMF in air gap are 0.25 Wb/sq.m, 198944 A/m ,47746.482928 A/wb ,2.0944e-05 Wb/A 2387 A respectively \n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 Page No : 90" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "phi = 0.1*10**-3;\t\t\t#flux in wb\n", - "a = 1.7*10**-4;\t\t\t#area of cross-section in m**2\n", - "lg = 0.5*10**-3;\t\t\t#length of air gap in m\n", - "Rm = 15./2;\t\t\t#radius of ring in cm\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space in henry/m\n", - "N = 1500.;\t\t\t#no of turns of ring\n", - "\n", - "#CALCULATIONS \n", - "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", - "H = (B/(4*math.pi*10**-7));\t\t\t#magnetic flux density in A/m\n", - "ampere_turns_provided_fo = H*lg;\n", - "total_ampere_turns_provi = N*1;\n", - "Available_for_iron_path = N-(H*lg);\n", - "length_of_iron_path = (2*Rm*math.pi*10**-2)-(lg);\t\t\t#length of iron path in m\n", - "H_for_iron_path = ((N-(H*lg)))/(length_of_iron_path);\n", - "ur = (B/(u0*H_for_iron_path));\t\t\t#relative permeability of iron\n", - "\n", - "#OUTPUT\n", - "print \"Thus relative permeability of iron is %d\"%(ur);\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus relative permeability of iron is 174\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 Page No : 91" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "li = 0.5;\t\t\t#iron path length in m\n", - "lg = 10.**-3;\t\t\t#length of air gap in m\n", - "phi = 0.9*10**-3;\t\t\t#flux in wb\n", - "a = 6.66*10**-4;\t\t\t#area of cross-section of iron in m**2\n", - "N = 400.;\t\t\t#no of turns \n", - "\n", - "#CALCULATIONS \n", - "B = (phi/a);\t\t\t#flux density in wb/sq.m\n", - "Hg = (B/(4*math.pi*10**-7));\t\t\t#magnetic flux density in A/m\n", - "AT_required = Hg*lg;\t\t\t#AT required for air path\n", - "Hi = 1000;\t\t\t#magnetic flux density in A/m\n", - "AT_required_for_iron_pat = Hi*li;\n", - "total_AT_required = (Hg*lg)+(Hi*li);\n", - "I = ((Hg*lg)+(Hi*li))/(N);\n", - "\n", - "#OUTPUT\n", - "print \"Thus exciting current required is %1.2f A\"%(I);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus exciting current required is 3.94 A\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5 Page No : 92" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#Chapter-2, Example 2.5, Page 92\n", - "\n", - "#INPUT DATA\n", - "r = 0.01;\t\t\t#radius in m\n", - "lg = 10.**-3;\t\t\t#length of air gap in m\n", - "Rm = (30./2)*10**-2;\t\t\t#mean radius in m\n", - "ur = 800.;\t\t\t#relative permeability of iron\n", - "ur2 = 1.;\t\t\t#relative permeability of air gap\n", - "N = 250.;\t\t\t#no of turns\n", - "phi = 20000.*10**-8;\t\t\t#flux in Wb\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space \n", - "a = math.pi*(r)**2;\t\t\t#area of cross-section in m\n", - "leakage_factor = 1.1\n", - "\n", - "#CALCULATIONS \n", - "reluctance_of_air_gap = (lg/(u0*ur2*a));\t\t\t#reluctance of air gap in A/wb\n", - "li = (math.pi*(2*r)-(lg));\t\t\t#length of iron path in m\n", - "reluctance_of_iron_path = ((math.pi*0.3)-(lg))/(4*math.pi*10**-7*800*a);\t\t\t#in A/wb\n", - "total_reluctance = reluctance_of_air_gap+reluctance_of_iron_path;\t\t\t#in A/wb\n", - "MMF = phi*total_reluctance;\t\t\t#in Ampere turns\n", - "current_required = (MMF)/(N);\t\t\t#in A\n", - "\n", - "#OUTPUT\n", - "print \"Thus current required is %1.2f A \"%(current_required);\n", - "#Including leakage\n", - "\n", - "#CALCULATIONS\n", - "MMF_of_airgap = phi*reluctance_of_air_gap;\t\t\t#in A/wb\n", - "Total_flux_in_ironpath = leakage_factor*phi;\t\t\t#in Wb\n", - "MMF_of_ironpath = Total_flux_in_ironpath*reluctance_of_iron_path;\t\t\t#in A\n", - "Total_MMF = MMF_of_ironpath+MMF_of_airgap;\t\t\t#in A/wb\n", - "current_required2 = Total_MMF/(N);\t\t\t#in A\n", - "\n", - "#OUTPUT\n", - "print \"Thus current required is %1.3f A\"%(current_required2);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus current required is 4.41 A \n", - "Thus current required is 4.650 A\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 Page No : 93" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "l1 = 0.1;\t\t\t#length in m\n", - "l2 = 0.18;\t\t\t#length in m\n", - "l3 = 0.18;\t\t\t#length in m\n", - "lg = 1.*10**-3;\t\t\t#airgap length in mm\n", - "a1 = 6.25*10**-4;\t\t\t#area in m**2\n", - "a2 = 3.*10**-4;\t\t\t#area in m**2\n", - "ur = 800.;\t\t\t#relative permeability of iron path\n", - "ur2 = 1.;\t\t\t#relative permeability in free space\n", - "u0 = 4*math.pi*10**-7\n", - "N = 600.;\n", - "phi = 10.**-4;\t\t\t#airgap flux in Wb\n", - "\n", - "#CALCULATIONS \n", - "#for the airgap\n", - "Bg = (phi/(a1));\t\t\t#fluxdensity in Tesla\n", - "Hg = (Bg/(u0*ur2));\t\t\t#magnetimath.sing force in A/m\n", - "MMF1 = Hg*lg;\t\t\t#in A\n", - "#for path I1\n", - "B1 = 0.16;\t\t\t# flux density in tesla\n", - "H1 = (B1/(ur*u0));\t\t\t#magnetimath.sing force in A/m\n", - "MMF2 = H1*l1;\t\t\t#in A\n", - "#math.since paths l2 and l3 are similar,the total flux divide equally between these two paths.Since these paths are in parallel,consider only one of them\n", - "#for path l2\n", - "flux = 50*10**-6;\t\t\t#flux in wb\n", - "B2 = (flux/a2);\t\t\t#fluxdensity in tesla\n", - "H2 = (B2/(ur*u0));\t\t\t#magnetimath.sing force in A/m\n", - "MMF3 = H2*l2;\t\t\t#in A\n", - "totalmmf = MMF1+MMF2+MMF3;\t\t\t#in A\n", - "I = (totalmmf/N);\t\t\t#current required in A\n", - "\n", - "#OUTPUT\n", - "print \"Thus current required is %1.3f A\"%(I);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus current required is 0.288 A\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 Page No : 95" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#Chapter-2, Example 2.7, Page 95\n", - "\n", - "#INPUT DATA\n", - "Dm = 0.1\t\t\t#diameter in m\n", - "a = 10.**-3;\t\t\t#area of cross-section im m**2\n", - "N = 150.;\t\t\t#no of turns\n", - "ur = 800.;\t\t\t#permeability of iron ring\n", - "B = 0.1;\t\t\t#in Wb/m**2\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeability of free space\n", - "\n", - "#CALCULATIONS \n", - "S = (math.pi*Dm)/(a*ur*u0);\t\t\t#reluctance\n", - "I = (B*a*S)/(N);\t\t\t#current in A\n", - "\n", - "#OUTPUT\n", - "print \"Thus current is %f A\"%(I);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus current is 0.208333 A\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8 Page No : 95" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "l = 0.3;\t\t\t#length in m\n", - "d = 1.5*10**-2;\t\t\t#diameter in m\n", - "N = 900;\t\t\t#no of turns\n", - "ur = 1;\t\t\t#relative permeability in free space\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space\n", - "I = 5;\t\t\t#current in A\n", - "\n", - "#CALCULATIONS \n", - "a = (math.pi*(d)**2/4);\t\t\t#in m**2\n", - "S = (l)/(a*ur*u0);\t\t\t#reluctance\n", - "\n", - "#OUTPUT\n", - "print \"Thus reluctance is %f A/wb\"%(S);\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus reluctance is 1350949115.231170 A/wb\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.9 Page No : 95" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "lg = 10**-3;\t\t\t#length of air gap in m\n", - "B = 0.9;\t\t\t#flux density in wb/m**2\n", - "li = 0.3;\t\t\t#length of ironpath in m\n", - "Hi = 800;\t\t\t#magnetic flux density in AT/m\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeabilty in free space\n", - "\n", - "#CALCULATIONS \n", - "#for iron path\n", - "MMF_required1 = Hi*li;\t\t\t#magnetic motive force in AT\n", - "#for air gap\n", - "MMF_required2 = (B/u0)*lg;\t\t\t#magnetic motive force in AT\n", - "Totalmmf = MMF_required1+MMF_required2\n", - "\n", - "#OUTPUT\n", - "print \"Thus total MMF required is %d AT\"%(Totalmmf);\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus total MMF required is 956 AT\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.10 Page No : 96" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "\n", - "#INPUT DATA\n", - "li = 0.5;\t\t\t#length of iron ring mean length in m\n", - "N = 220;\t\t\t#no of turns\n", - "I = 1.2;\t\t\t#current in A\n", - "lg = 1.2*10**-3;\t\t\t#length of airgap in m\n", - "ur = 350;\t\t\t#relative permeability of iron\n", - "u0 = 4*math.pi*10**-7;\t\t\t#permeability in free space\n", - "\n", - "#CALCULATIONS \n", - "MMF_produced = N*I;\n", - "Si = li/(u0*ur);\t\t\t#reluctance of iron path\n", - "Sg = lg/(u0);\t\t\t#reluctance of air gap\n", - "S = Si+Sg;\t\t\t#total reluctance \n", - "Flux_density = (MMF_produced)/(S);\n", - "\n", - "#OUTPUT\n", - "print \"Thus fluxdensity is %1.3f Wb/m**2\"%(Flux_density);\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thus fluxdensity is 0.126 Wb/m**2\n" - ] - } - ], - "prompt_number": 10 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SayanDas Karmakar/Chapter_4.ipynb b/sample_notebooks/SayanDas Karmakar/Chapter_4.ipynb deleted file mode 100755 index 09f41e0f..00000000 --- a/sample_notebooks/SayanDas Karmakar/Chapter_4.ipynb +++ /dev/null @@ -1,339 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:61bd0df995c71f463ddf51b756707a8ae69406d81e9ac36b5c0b23d29319f2ab" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 4: Cotrol System Components" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4.1 Page No. 61" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print(\"Given \\n a)Excitation voltage(Ein)=2V \\n b) Setting Ratio(a)= 0.4 \\n\")\n", - "Ein=2;\n", - "print \"Ein=\", Ein\n", - "a=0.4;\n", - "print \"a=\",a\n", - "Rt=10**3;\n", - "print \"Rt=\",Rt\n", - "Rl=5*10**3;\n", - "print \"Rl=\",Rl\n", - "print \"Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl)\" ;\n", - "Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl);\n", - "print \"output voltage(E0)=\",round(Eo,3)\n", - "print \"e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt)) \"\n", - "e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt));\n", - "print \"loading error=\",round(e,4)\n", - "print \"E= Ein*e \"\n", - "E=Ein*e; #Voltage error=Excitation voltage(Ein)*Loading error(e)\n", - "print \"Voltage error=\",round(E,4),\"V\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Given \n", - " a)Excitation voltage(Ein)=2V \n", - " b) Setting Ratio(a)= 0.4 \n", - "\n", - "Ein= 2\n", - "a= 0.4\n", - "Rt= 1000\n", - "Rl= 5000\n", - "Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl)\n", - "output voltage(E0)= 0.763\n", - "e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt)) \n", - "loading error= 0.0183\n", - "E= Ein*e \n", - "Voltage error= 0.0366 V\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4.2 Page No. 62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "print \"Helical turn \"\n", - "n=5; #Helical turn\n", - "print \"n=\",n \n", - "print \"\\n Winding Turn \"\n", - "N=9000; #Winding Turn\n", - "print \"N=\",N\n", - "print \"\\n Potentiometer Resistance \"\n", - "R=10000; #Potentiometer Resistance\n", - "print \"R=\",R\n", - "print \"\\n Input voltage \"\n", - "Ein=90; #Input voltage\n", - "print \"Ein=\",Ein\n", - "print \"\\n Resistance at mid point \"\n", - "r=5050; #Resistance at mid point \n", - "print \"r=\",r\n", - "print \"\\n Deviation from nominal at mid-point \"\n", - "D=r-5000; #Deviation from nominal at mid-point\n", - "print \"D=\",D\n", - "print \"\\n Linearity \"\n", - "L=D/R*100; #Linearity\n", - "print \"L=\",L\n", - "print \"\\n Resolution \"\n", - "R=Ein/N; #Resolution\n", - "print \"R=\",R\n", - "print \"\\n Potentiometer Constant \"\n", - "Kp=Ein/(2*math.pi*n); #Potentiometer Constant\n", - "print \"Kp=\",round(Kp,3),\"V/rad\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Helical turn \n", - "n= 5\n", - "\n", - " Winding Turn \n", - "N= 9000\n", - "\n", - " Potentiometer Resistance \n", - "R= 10000\n", - "\n", - " Input voltage \n", - "Ein= 90\n", - "\n", - " Resistance at mid point \n", - "r= 5050\n", - "\n", - " Deviation from nominal at mid-point \n", - "D= 50\n", - "\n", - " Linearity \n", - "L= 0\n", - "\n", - " Resolution \n", - "R= 0\n", - "\n", - " Potentiometer Constant \n", - "Kp= 2.865 V/rad\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4.3 Page No. 65" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "print \"Since S2 is the referance stator winding , Es2=KVcos(theta) \\n where Es2 & Er are rms voltages \\n\"\n", - "k=1\n", - "Theta=60;\n", - "print \"Theta=\",Theta\n", - "V=28;\n", - "print \"V(applied)=\",V,\"V\"\n", - "print \"Es2=V*cos(Theta) \\n\"\n", - "Es2=k*V*cos(Theta*(math.pi/180));\n", - "print \"Es2=\",Es2,\"V\"\n", - "print \"Es1=k*V*cos(Theta-120)\\n\"\n", - "Es1=k*V*cos((Theta-120)*(math.pi/180)); # Given Theta=60 in degrees\n", - "print \"Es1=\",Es1,\"V\"\n", - "print \"Es3=k*V*cos(Theta+120) \\n\"\n", - "Es3=k*V*cos((Theta+120)*(math.pi/180));\n", - "print \"Es3=\",Es3,\"V\"\n", - "print \"Es31=sqrt(3)*k*Er*sin(Theta)\"\n", - "Es31=sqrt(3)*k*V*sin(Theta*(math.pi/180));\n", - "print \"Es31=\",Es31,\"V\"\n", - "print \"Es12=sqrt(3)*k*Er*sin((Theta-120)\"\n", - "Es12=sqrt(3)*k*V*sin((Theta-120)*(math.pi/180));\n", - "print \"Es12=\",Es12,\"V\"\n", - "print \"Es23=sqrt(3)*k*Er*sin((Theta+120)\"\n", - "Es23=sqrt(3)*k*V*sin((Theta+120)*(math.pi/180));\n", - "print \"Es23=\",round(Es23,1),\"V\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Since S2 is the referance stator winding , Es2=KVcos(theta) \n", - " where Es2 & Er are rms voltages \n", - "\n", - "Theta= 60\n", - "V(applied)= 28\n", - "Es2=V*cos(Theta) \n", - "\n", - "Es2= 14.0 V\n", - "Es1=k*V*cos(Theta-120)\n", - "\n", - "Es1= 14.0 V\n", - "Es3=k*V*cos(Theta+120) \n", - "\n", - "Es3= -28.0 V\n", - "Es31=sqrt(3)*k*Er*sin(Theta)\n", - "Es31= 42.0 V\n", - "Es12=sqrt(3)*k*Er*sin((Theta-120)\n", - "Es12= -42.0 V\n", - "Es23=sqrt(3)*k*Er*sin((Theta+120)\n", - "Es23= 0.0 V\n" - ] - } - ], - "prompt_number": 21 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4.4 Page No. 67" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "print \"Sensitivity = 5v/1000rpm \\n\"\n", - "Vg=5;\n", - "print \"Vg=\",Vg,\"\\n\"\n", - "print \"w(in radians/sec)=(1000/60)*2* pi \\n\"\n", - "w=(1000/60)*2*math.pi;\n", - "print \"w=\",round(w,6),\"radians/sec\",\"\\n\"\n", - "print \"Kt=Vg/w \\n\"\n", - "Kt=Vg/w;\n", - "print \"Gain constant(Kt)=\",round(Kt,4),\"V/rad/sec\" # Answer given in textbook is after taking appoximation." - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Sensitivity = 5v/1000rpm \n", - "\n", - "Vg= 5 \n", - "\n", - "w(in radians/sec)=(1000/60)*2* pi \n", - "\n", - "w= 100.530965 radians/sec \n", - "\n", - "Kt=Vg/w \n", - "\n", - "Gain constant(Kt)= 0.0497 V/rad/sec\n" - ] - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 4.5 Page No. 80" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "print \"Torque = KmVm = 2 \\n\"\n", - "t=2;\n", - "print \"Torque(t) = \",t,\"\\n\"\n", - "Fm=0.2;\n", - "print \"Coefficient of Viscous friction(Fm)=\",Fm,\"\\n\"\n", - "N=4\n", - "I=0.2\n", - "F1=0.05\n", - "print \"Wnl = t/Fm \\n\"\n", - "Wnl = t/Fm;\n", - "print \"No Load Speed(Wnl) = \",Wnl,\"rad/sec \\n\"\n", - "print \"Fwt = I+(N^2*F1) \\n\"\n", - "Fwt = I+(N**2*F1);\n", - "print \"Total Viscous Friction(Fwt) = \",Fwt,\"lb ft sec\\n\"\n", - "print \"Te = t-(Fwt*w) \\n\"\n", - "Te=0.8 #load\n", - "w=(t-Te)/Fwt;\n", - "print \"Speed of Motor(w) = \",w,\"rad/sec \\n\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Torque = KmVm = 2 \n", - "\n", - "Torque(t) = 2 \n", - "\n", - "Coefficient of Viscous friction(Fm)= 0.2 \n", - "\n", - "Wnl = t/Fm \n", - "\n", - "No Load Speed(Wnl) = 10.0 rad/sec \n", - "\n", - "Fwt = I+(N^2*F1) \n", - "\n", - "Total Viscous Friction(Fwt) = 1.0 lb ft sec\n", - "\n", - "Te = t-(Fwt*w) \n", - "\n", - "Speed of Motor(w) = 1.2 rad/sec \n", - "\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SayanDas Karmakar/SayanDas Karmakar_version_backup/Chapter_4.ipynb b/sample_notebooks/SayanDas Karmakar/SayanDas Karmakar_version_backup/Chapter_4.ipynb new file mode 100755 index 00000000..09f41e0f --- /dev/null +++ b/sample_notebooks/SayanDas Karmakar/SayanDas Karmakar_version_backup/Chapter_4.ipynb @@ -0,0 +1,339 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:61bd0df995c71f463ddf51b756707a8ae69406d81e9ac36b5c0b23d29319f2ab" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 4: Cotrol System Components" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.1 Page No. 61" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print(\"Given \\n a)Excitation voltage(Ein)=2V \\n b) Setting Ratio(a)= 0.4 \\n\")\n", + "Ein=2;\n", + "print \"Ein=\", Ein\n", + "a=0.4;\n", + "print \"a=\",a\n", + "Rt=10**3;\n", + "print \"Rt=\",Rt\n", + "Rl=5*10**3;\n", + "print \"Rl=\",Rl\n", + "print \"Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl)\" ;\n", + "Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl);\n", + "print \"output voltage(E0)=\",round(Eo,3)\n", + "print \"e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt)) \"\n", + "e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt));\n", + "print \"loading error=\",round(e,4)\n", + "print \"E= Ein*e \"\n", + "E=Ein*e; #Voltage error=Excitation voltage(Ein)*Loading error(e)\n", + "print \"Voltage error=\",round(E,4),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Given \n", + " a)Excitation voltage(Ein)=2V \n", + " b) Setting Ratio(a)= 0.4 \n", + "\n", + "Ein= 2\n", + "a= 0.4\n", + "Rt= 1000\n", + "Rl= 5000\n", + "Eo = (a*Ein)/(1+(a*(1-a)*Rt)/Rl)\n", + "output voltage(E0)= 0.763\n", + "e=((a**2)*(1-a))/((a*(1-a))+(Rl/Rt)) \n", + "loading error= 0.0183\n", + "E= Ein*e \n", + "Voltage error= 0.0366 V\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.2 Page No. 62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "print \"Helical turn \"\n", + "n=5; #Helical turn\n", + "print \"n=\",n \n", + "print \"\\n Winding Turn \"\n", + "N=9000; #Winding Turn\n", + "print \"N=\",N\n", + "print \"\\n Potentiometer Resistance \"\n", + "R=10000; #Potentiometer Resistance\n", + "print \"R=\",R\n", + "print \"\\n Input voltage \"\n", + "Ein=90; #Input voltage\n", + "print \"Ein=\",Ein\n", + "print \"\\n Resistance at mid point \"\n", + "r=5050; #Resistance at mid point \n", + "print \"r=\",r\n", + "print \"\\n Deviation from nominal at mid-point \"\n", + "D=r-5000; #Deviation from nominal at mid-point\n", + "print \"D=\",D\n", + "print \"\\n Linearity \"\n", + "L=D/R*100; #Linearity\n", + "print \"L=\",L\n", + "print \"\\n Resolution \"\n", + "R=Ein/N; #Resolution\n", + "print \"R=\",R\n", + "print \"\\n Potentiometer Constant \"\n", + "Kp=Ein/(2*math.pi*n); #Potentiometer Constant\n", + "print \"Kp=\",round(Kp,3),\"V/rad\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Helical turn \n", + "n= 5\n", + "\n", + " Winding Turn \n", + "N= 9000\n", + "\n", + " Potentiometer Resistance \n", + "R= 10000\n", + "\n", + " Input voltage \n", + "Ein= 90\n", + "\n", + " Resistance at mid point \n", + "r= 5050\n", + "\n", + " Deviation from nominal at mid-point \n", + "D= 50\n", + "\n", + " Linearity \n", + "L= 0\n", + "\n", + " Resolution \n", + "R= 0\n", + "\n", + " Potentiometer Constant \n", + "Kp= 2.865 V/rad\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.3 Page No. 65" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "print \"Since S2 is the referance stator winding , Es2=KVcos(theta) \\n where Es2 & Er are rms voltages \\n\"\n", + "k=1\n", + "Theta=60;\n", + "print \"Theta=\",Theta\n", + "V=28;\n", + "print \"V(applied)=\",V,\"V\"\n", + "print \"Es2=V*cos(Theta) \\n\"\n", + "Es2=k*V*cos(Theta*(math.pi/180));\n", + "print \"Es2=\",Es2,\"V\"\n", + "print \"Es1=k*V*cos(Theta-120)\\n\"\n", + "Es1=k*V*cos((Theta-120)*(math.pi/180)); # Given Theta=60 in degrees\n", + "print \"Es1=\",Es1,\"V\"\n", + "print \"Es3=k*V*cos(Theta+120) \\n\"\n", + "Es3=k*V*cos((Theta+120)*(math.pi/180));\n", + "print \"Es3=\",Es3,\"V\"\n", + "print \"Es31=sqrt(3)*k*Er*sin(Theta)\"\n", + "Es31=sqrt(3)*k*V*sin(Theta*(math.pi/180));\n", + "print \"Es31=\",Es31,\"V\"\n", + "print \"Es12=sqrt(3)*k*Er*sin((Theta-120)\"\n", + "Es12=sqrt(3)*k*V*sin((Theta-120)*(math.pi/180));\n", + "print \"Es12=\",Es12,\"V\"\n", + "print \"Es23=sqrt(3)*k*Er*sin((Theta+120)\"\n", + "Es23=sqrt(3)*k*V*sin((Theta+120)*(math.pi/180));\n", + "print \"Es23=\",round(Es23,1),\"V\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Since S2 is the referance stator winding , Es2=KVcos(theta) \n", + " where Es2 & Er are rms voltages \n", + "\n", + "Theta= 60\n", + "V(applied)= 28\n", + "Es2=V*cos(Theta) \n", + "\n", + "Es2= 14.0 V\n", + "Es1=k*V*cos(Theta-120)\n", + "\n", + "Es1= 14.0 V\n", + "Es3=k*V*cos(Theta+120) \n", + "\n", + "Es3= -28.0 V\n", + "Es31=sqrt(3)*k*Er*sin(Theta)\n", + "Es31= 42.0 V\n", + "Es12=sqrt(3)*k*Er*sin((Theta-120)\n", + "Es12= -42.0 V\n", + "Es23=sqrt(3)*k*Er*sin((Theta+120)\n", + "Es23= 0.0 V\n" + ] + } + ], + "prompt_number": 21 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.4 Page No. 67" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "print \"Sensitivity = 5v/1000rpm \\n\"\n", + "Vg=5;\n", + "print \"Vg=\",Vg,\"\\n\"\n", + "print \"w(in radians/sec)=(1000/60)*2* pi \\n\"\n", + "w=(1000/60)*2*math.pi;\n", + "print \"w=\",round(w,6),\"radians/sec\",\"\\n\"\n", + "print \"Kt=Vg/w \\n\"\n", + "Kt=Vg/w;\n", + "print \"Gain constant(Kt)=\",round(Kt,4),\"V/rad/sec\" # Answer given in textbook is after taking appoximation." + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Sensitivity = 5v/1000rpm \n", + "\n", + "Vg= 5 \n", + "\n", + "w(in radians/sec)=(1000/60)*2* pi \n", + "\n", + "w= 100.530965 radians/sec \n", + "\n", + "Kt=Vg/w \n", + "\n", + "Gain constant(Kt)= 0.0497 V/rad/sec\n" + ] + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 4.5 Page No. 80" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "print \"Torque = KmVm = 2 \\n\"\n", + "t=2;\n", + "print \"Torque(t) = \",t,\"\\n\"\n", + "Fm=0.2;\n", + "print \"Coefficient of Viscous friction(Fm)=\",Fm,\"\\n\"\n", + "N=4\n", + "I=0.2\n", + "F1=0.05\n", + "print \"Wnl = t/Fm \\n\"\n", + "Wnl = t/Fm;\n", + "print \"No Load Speed(Wnl) = \",Wnl,\"rad/sec \\n\"\n", + "print \"Fwt = I+(N^2*F1) \\n\"\n", + "Fwt = I+(N**2*F1);\n", + "print \"Total Viscous Friction(Fwt) = \",Fwt,\"lb ft sec\\n\"\n", + "print \"Te = t-(Fwt*w) \\n\"\n", + "Te=0.8 #load\n", + "w=(t-Te)/Fwt;\n", + "print \"Speed of Motor(w) = \",w,\"rad/sec \\n\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Torque = KmVm = 2 \n", + "\n", + "Torque(t) = 2 \n", + "\n", + "Coefficient of Viscous friction(Fm)= 0.2 \n", + "\n", + "Wnl = t/Fm \n", + "\n", + "No Load Speed(Wnl) = 10.0 rad/sec \n", + "\n", + "Fwt = I+(N^2*F1) \n", + "\n", + "Total Viscous Friction(Fwt) = 1.0 lb ft sec\n", + "\n", + "Te = t-(Fwt*w) \n", + "\n", + "Speed of Motor(w) = 1.2 rad/sec \n", + "\n" + ] + } + ], + "prompt_number": 2 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ShantanuBhosale/ShantanuBhosale_version_backup/chapter40.ipynb b/sample_notebooks/ShantanuBhosale/ShantanuBhosale_version_backup/chapter40.ipynb new file mode 100755 index 00000000..e297a2c2 --- /dev/null +++ b/sample_notebooks/ShantanuBhosale/ShantanuBhosale_version_backup/chapter40.ipynb @@ -0,0 +1,1989 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# CHAPTER 40: D.C TRANSMISSION AND DISTRIBUTION\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.1 ,Page No :- 1574" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "percentage saving in copper is = 50.0 %.\n" + ] + } + ], + "source": [ + "#A DC 2-wire feeder supplies a constant load with a sending-end voltage of 220V.Calculate the saving in copper\n", + "#if this voltage is doubled with power transmitted remaining the same.\n", + "##################################################################################################################\n", + "\n", + "\n", + "\n", + "#Given\n", + "V1 = 220.0\n", + "V2 = 440.0\n", + "##Let us assume the wire has##\n", + "#length -> length \n", + "#area -> area\n", + "#current density -> cd\n", + "#power -> P\n", + "P = 10000.0 #assumption\n", + "length = 1000.0 #assumption \n", + "cd = 5.0 #assumption\n", + "#The values are assumed as these terms cancel out while calculating percentage.\n", + "I1 = P/V1\n", + "area = I1/cd\n", + "#Vol of Cu required for 220V ->vol1\n", + "vol1 = 2*area*length\n", + "\n", + "\n", + "I2 = P/V2\n", + "area = I2/cd\n", + "#Vol of Cu required for 440V ->vol2\n", + "vol2 = 2*area*length\n", + "\n", + "#percentage saving of copper is\n", + "per_cent = ((vol1-vol2)/vol1)*100\n", + "print 'percentage saving in copper is ',per_cent,'%.'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.2 ,Page No :- 1577" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Maximum voltage drop from one end is = 12.0 V.\n", + "Maximum voltage drop from both end is = 3.0 V.\n" + ] + } + ], + "source": [ + "#A uniform 2-wire d.c distributor 200 metres long is loaded with 2 amperes/metre.Resistance of\n", + "#single wire is 0.3 ohm/kilometre.Calculate the maximum voltage drop if the distributor is fed\n", + "#(a)from one end (b)from both ends with equal voltages.\n", + "#################################################################################################\n", + "\n", + "#Given\n", + "length = 200.0 #metres\n", + "#current per unit length is\n", + "cur = 2.0 #amp/metre\n", + "#resistance per unit length is\n", + "res = 0.3/1000 #ohm/metre\n", + "\n", + "#total resistance is\n", + "R = res*length #ohm\n", + "#total current is\n", + "I = cur*length #amp\n", + "#Total drop over a distributor fed from one end is given by\n", + "drop1 = (1/2.0)*I*R #volts\n", + "#Total drop over a distributor fed from both ends is given by\n", + "drop2 = (1/8.0)*I*R\n", + "print 'Maximum voltage drop from one end is = ',drop1,'V.'\n", + "print 'Maximum voltage drop from both end is = ',drop2,'V.'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.3 ,Page No :- 1577" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Cross sectional area of distributor = 116.412 cm^2\n" + ] + } + ], + "source": [ + "#A 2-wire d.c distributor AB is 300 metres long.It is fed at point A.The various loads and\n", + "#their positions are given below.\n", + "# At point distance from A in metres concentrated load in A\n", + "# C 40 30\n", + "# D 100 40 \n", + "# E 150 100\n", + "# F 250 50\n", + "#If the maximum permissible voltage drop is not to exceed 10V,find the cross-sectional\n", + "#area of the distributor.Take resistivity = 1.78*10^(-8) ohm-m.\n", + "###########################################################################################\n", + "\n", + "\n", + "#Given\n", + "resistivity = 1.78e-8 #ohm-m\n", + "drop_max = 10.0 #V\n", + "#loads and their positions\n", + "I1 = 30.0 #A\n", + "l1 = 40.0 #m\n", + "I2 = 40.0 #A\n", + "l2 = 100.0 #m\n", + "I3 = 100.0 #A\n", + "l3 = 150.0 #m\n", + "I4 = 50 #A\n", + "l4 = 250 #m\n", + "#We know that R = resistivity*length/Area\n", + "#Also max drop = I1*R1 + I2*R2 + I3*R3 + I4*R4 , using this\n", + "area = 2*(I1*l1 + I2*l2 + I3*l3 + I4*l4)*resistivity/drop_max #m^2\n", + "area = area*1000000 #cm^2 \n", + "print 'Cross sectional area of distributor =',area,'cm^2'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.4 ,Page No :- 1578" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Hence drop at minimum potential where load is 70 A is = 48.4 V.\n" + ] + } + ], + "source": [ + "#A 2-wire d.c distributor F1F2 1000 metres long is loaded as under:\n", + "#Distance from F1(in metres): 100 250 500 600 700 800 850 920\n", + "#Load in amperes: 20 80 50 70 40 30 10 15\n", + "#The feeding points F1 and F2 are maintained at the same potential.Find which point will have the\n", + "#minimum potential and what will be the drop at this point?Take the cross-section of the conductors\n", + "#as 0.35 cm^2 and specific resistance of copper as 1.764*10^(-6) ohm-cm\n", + "#####################################################################################################\n", + "\n", + "#Given\n", + "import numpy as np\n", + "resistivity = 1.764e-8 #ohm-m\n", + "area = 0.35e-4 #m^2 \n", + "#loads and their positions taking from F1\n", + "I1 = 20 #A\n", + "l1 = 100 #m\n", + "I2 = 80 #A\n", + "l2 = 150 #m\n", + "I3 = 50 #A\n", + "l3 = 250 #m\n", + "I4 = 70 #A\n", + "l4 = 100 #m\n", + "I5 = 40 #A\n", + "l5 = 100 #m\n", + "I6 = 30 #A\n", + "l6 = 50 #m\n", + "I7 = 10 #A\n", + "l7 = 70 #m\n", + "I8 = 15 #A\n", + "l8 = 80 #m \n", + "\n", + "#sum of loads from F1\n", + "load1 = I1*l1 + I2*(l1+l2) + I3*(l1+l2+l3) #A-m\n", + "load2 = I8*l8 + I7*(l7+l8) + I6*(l6+l7+l8) + I5*(l5+l6+l7+l8) #A-m\n", + "\n", + "#guessing the point of minimum potential\n", + "if load1>load2:\n", + " load2_new = load2 + I4*(l4+l5+l6+l7+l8)\n", + " if load2_new>load1:\n", + " pivot = I4\n", + "\n", + "#solving 2 equations simultaneously\n", + "# x + y = 70(pivot) & 47000(load1) + 600(l1+l2+l3)x = 20,700(load2) + 400(l5+l6+l7+l8)y)\n", + "line1 = l1+l2+l3+l4 #m\n", + "line2 = l4+l5+l6+l7+l8 #m \n", + "\n", + "a = [[1,1],[line1,-line2]]\n", + "b = [pivot,load2-load1]\n", + "soln = np.linalg.solve(a,b) #soln is array with its elements[x,y]\n", + "#drop at minimum potential per conductor (in A-m)\n", + "drop_m = load1 + soln[0]*line1 #A-m\n", + "\n", + "#resistance per metre = resistivity/Area\n", + "res = resistivity/area #ohm/m\n", + "\n", + "#Hence, drop in voltage per conductor is\n", + "drop = drop_m*res #V \n", + "#drop due to both is\n", + "drop = drop*2 #V\n", + "\n", + "print 'Hence drop at minimum potential where load is',pivot,'A is =',round(drop,2),'V.'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.5 ,Page No :- 1579" + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current entering at A is = 88.6 A \n", + "The current entering at B is = 211.4 A.\n" + ] + } + ], + "source": [ + "#The resistance of a cable is 0.1ohm per 1000 metre for both conductors.It is loaded as shown in Fig.40.14(a).\n", + "#Find the current supplied at A and at B.If both the ends are supplied at 200 V\n", + "##############################################################################################################\n", + "\n", + "#Given\n", + "#resistance per metre\n", + "res = 0.1/1000 #ohm/m\n", + "#loads and their positions taking from A\n", + "I1 = 50.0 #A\n", + "l1 = 500.0 #m\n", + "I2 = 100.0 #A\n", + "l2 = 700.0 #m\n", + "I3 = 150.0 #A\n", + "l3 = 300.0 #m\n", + "l4 = 250.0 #m \n", + "\n", + "#Assuming I flows from A to B\n", + "# equation is res*[500*i + 700(i-50) + 300(i-150) + 250(i-300)] = 0\n", + "current_i = (I1*l2+(I1+I2)*l3 + (I1+I2+I3)*l4)/(l1+l2+l3+l4)\n", + "current_AC = current_i\n", + "current_CD = current_i-I1\n", + "current_DE = current_CD-I2\n", + "current_EB = current_DE-I3\n", + "if current_EB<0:\n", + " current_EB = -current_EB;\n", + "print 'The current entering at A is = ',round(current_i,1),'A '\n", + "print 'The current entering at B is = ',round(current_EB,1),'A.' " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.6 ,Page No :- 1580" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current supplied at A is = 88.6 A.\n", + "Current supplied at B is = -211.4 A.\n", + "Current in AC is = 88.6 A.\n", + "Current in CD is = 38.6 A.\n", + "Current in DE is = -61.4 A.\n", + "Current in EB is = -211.4 A.\n", + "Drop over AC is = 4.4 V.\n", + "Drop over CD is = 2.7 V.\n", + "Drop over DE is = -1.8 V.\n", + "Voltage at C is = 195.6 V.\n", + "Voltage at D is = 192.9 V.\n", + "Voltage at E is = 194.7 V.\n" + ] + } + ], + "source": [ + "#The resistance of two conductors of a 2-conductor distributor shown in Fig.39.15 is 0.1ohm per 1000m\n", + "#for both conductors.Find (a)the current supplied at A(b)the current supplied at B\n", + "#(c)the current in each section (d)the voltages at C,D and E.Both A and B are maintained at 200V.\n", + "######################################################################################################\n", + "\n", + "#Given\n", + "#resistance per metre\n", + "res = 0.1/1000 #ohm/m\n", + "#loads and their positions taking from A\n", + "I1 = 50.0 #A\n", + "l1 = 500.0 #m\n", + "I2 = 100.0 #A\n", + "l2 = 700.0 #m\n", + "I3 = 150.0 #A\n", + "l3 = 300.0 #m\n", + "l4 = 250.0 #m \n", + "\n", + "#Assuming I flows from A to B\n", + "# equation is res*[500*i + 700(i-50) + 300(i-150) + 250(i-300)] = 0\n", + "current_i = (I1*l2+(I1+I2)*l3 + (I1+I2+I3)*l4)/(l1+l2+l3+l4)\n", + "current_AC = current_i\n", + "current_CD = current_i-I1\n", + "current_DE = current_CD-I2\n", + "current_EB = current_DE-I3\n", + "print \"Current supplied at A is = \",round(current_i,1),\"A.\"\n", + "print \"Current supplied at B is = \",round(current_EB,1),\"A.\"\n", + "print \"Current in AC is = \",round(current_i,1),\"A.\"\n", + "print \"Current in CD is = \",round(current_CD,1),\"A.\"\n", + "print \"Current in DE is = \",round(current_DE,1),\"A.\"\n", + "print \"Current in EB is = \",round(current_EB,1),\"A.\"\n", + "#Drop in volts is (resistance/metre)*length*current\n", + "drop_AC = res*l1*current_AC #V\n", + "drop_CD = res*l2*current_CD #V \n", + "drop_DE = res*l3*current_DE #V\n", + "print \"Drop over AC is = \",round(drop_AC,1),\"V.\"\n", + "print \"Drop over CD is = \",round(drop_CD,1),\"V.\"\n", + "print \"Drop over DE is = \",round(drop_DE,1),\"V.\"\n", + "\n", + "#Voltages at C,D,E are\n", + "volt_C = 200-drop_AC #V\n", + "volt_D = volt_C-drop_CD #V\n", + "volt_E = volt_D-drop_DE #V\n", + "print 'Voltage at C is = ',round(volt_C,1),'V.'\n", + "print 'Voltage at D is =',round(volt_D,1),'V.'\n", + "print 'Voltage at E is = ',round(volt_E,1),'V.'\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.7 ,Page No :- 1581" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Therefore point of minimum potential is D and minimum potential is = 246.0 V.\n" + ] + } + ], + "source": [ + "#A 200 m long distributor is fed from both ends A and B at the same voltage of 250V.The\n", + "#concentrated loads of 50,40,30 and 25 A are coming on the distributor at distances of 50,75,\n", + "#100 and 150 m respectively from end A.Determine the minimum potential and locate its positions.\n", + "#Also,determine the current in each section of the distributor.It is given that the resistance\n", + "#of the distributor is 0.08ohm per 100 metres for go and return.\n", + "##################################################################################################\n", + "\n", + "\n", + "#Given\n", + "#resistance per metre\n", + "res = 0.08/100 #ohm/m\n", + "V_A = 250.0 #V\n", + "V_B = 250.0 #V\n", + "#load currents and their positions\n", + "I_C = 50.0 #A\n", + "I_D = 40.0 #A\n", + "I_E = 30.0 #A\n", + "I_F = 25.0 #A\n", + "l_AC = 50.0 #m\n", + "l_CD = 75.0 - l_AC #m\n", + "l_DE = 100.0 - l_CD - l_AC #m\n", + "l_EF = 150.0 - l_DE - l_CD - l_AC #m\n", + "l_FB = 200.0-150.0\n", + "#Assuming I flows from A to B\n", + "# equation is res*[50*i + 25(i-50) + 25(i-90) + 50(i-120)+50(i-145)] = 0\n", + "current_i = (l_CD*I_C + l_DE*(I_C+I_D)+l_EF*(I_C+I_D+I_E) + l_FB*(I_C+I_D+I_E+I_F))/200.0\n", + "current_AC = current_i\n", + "current_CD = current_i-I_C\n", + "current_DE = current_CD-I_D\n", + "current_EF = current_DE-I_E\n", + "current_FB = current_EF-I_F\n", + "#As from figure in the book , point D is at minimum potential\n", + "if (current_CD>0) & (current_DE<0):\n", + " point = \"D\"\n", + " \n", + "#drop in volts = resistance/metre*sum(length*current) \n", + "drop_d = res*(l_AC*current_AC + l_CD*current_CD)\n", + "min_pot = V_A-drop_d\n", + "print \"Therefore point of minimum potential is\",point,\"and minimum potential is = \",round(min_pot,1),\"V.\" " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.8 ,Page No :- 1582" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage at point C is = 250.13 V.\n", + "Voltage at point D is = 247.73 V.\n" + ] + } + ], + "source": [ + "#Each conductor of a 2-core distributor,500 metres long has a cross-sectional area\n", + "#of 2 cm^2.The feeding point A is supplied at 255V and the feeding point B at\n", + "#250V and load currents of 120A and 160A are taken at points C and D which are\n", + "#150 metres and 350 metres respectively from the feeding point A.Calculate the\n", + "#voltage at each load.Specific Resistance of copper is 1.7*10^(-6) ohm-cm\n", + "##################################################################################\n", + "\n", + "#Given\n", + "area = 2e-4 #m^2\n", + "resistivity = 1.7e-8 #ohm-m\n", + "#load currents and their positions\n", + "i_c = 120.0 #A\n", + "i_d = 160.0 #A\n", + "l_ac = 150.0 #m\n", + "l_cd = 200.0 #m\n", + "l_db = 150.0 #m\n", + "V_a = 255.0 #V\n", + "V_b = 250.0 #V\n", + "#Resistance = resistivity*length/Area\n", + "#It is a 2 core distributor.Therefore,resistance per metre is\n", + "res = 2*resistivity/area #ohm/m\n", + "#drop over whole distributor is equal to\n", + "drop = V_a - V_b #V\n", + "#Therefore equation of total drop can be written as\n", + "# resistivity*(150i+200(i-120)+150(i-280))=5\n", + "current_i = (drop/res + l_cd*i_c + l_db*(i_c+i_d))/(l_ac+l_cd+l_db) #A\n", + "current_ac = current_i #A\n", + "current_cd = current_ac-i_c #A\n", + "current_db = current_cd-i_d #A\n", + "\n", + "#Voltage at C = 255-drop over AC\n", + "volt_c = V_a-res*l_ac*current_ac #V\n", + "#Voltage at D = 250-drop over DB \n", + "volt_d = V_b -res*l_db*abs(current_db) #V\n", + "print \"Voltage at point C is = \",round(volt_c,2),\"V.\"\n", + "print \"Voltage at point D is = \",round(volt_d,2),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.9 ,Page No :- 1583" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Volatge at point Q is = 225.25 V.\n", + "Voltage at point B is = 236.56 V.\n" + ] + } + ], + "source": [ + "#A 2-wire distributor 500 metres long is fed at P at 250V and loads of 40A,20A,60A,30A are tapped off\n", + "#off from points A,B,C and D which are at distances of 100 metres,150 metres,300 metres and 400 metres\n", + "#from P respectively.The distributor is also uniformly loaded at the rate of 0.1A/m.If the resistance of\n", + "#the distributor per metre(go and return) is 0.0005 ohm,calculate the voltage at(i)pointQ and(ii)point B.\n", + "###########################################################################################################\n", + "\n", + "#Given\n", + "V_P = 250.0 #V\n", + "resistance = 0.0005 #ohm/m\n", + "\n", + "#loads and their positions\n", + "i_a = 40.0 #A\n", + "i_b = 20.0 #A\n", + "i_c = 60.0 #A\n", + "i_d = 30.0 #A\n", + "l_pa = 100.0 #m\n", + "l_ab = 150.0-100.0 #m\n", + "l_bc = 300.0-150.0 #m\n", + "l_cd = 400.0-300.0 #m\n", + "#uniform dstributed load\n", + "cur_uni = 0.1 #A/m\n", + "\n", + "\n", + "#considering drop due to concentrated loading\n", + "drop_pa = (i_a+i_b+i_c+i_d)*l_pa*resistance #V\n", + "drop_ab = (i_b+i_c+i_d)*l_ab*resistance #V \n", + "drop_bc = (i_c+i_d)*l_bc*resistance #V\n", + "drop_cd = i_d*l_cd*resistance #V\n", + "tot_drop = drop_pa + drop_ab + drop_bc + drop_cd #V\n", + "\n", + "#considering drop due to uniform loading(drop = irl^2/2) l = 500m\n", + "drop_uni = cur_uni*resistance*(500.0*500.0)/2 #V\n", + "\n", + "V_Q = V_P - (tot_drop + drop_uni) #V\n", + "#for point B\n", + "#drop due to concentrated loading\n", + "drop_b = drop_pa + drop_ab #V\n", + "#drop due to uniform loading (drop = ir(lx-x^2/2)) l=500m x=150m\n", + "drop_ub = cur_uni*resistance*(500*(l_pa+l_ab)-(l_pa+l_ab)*(l_pa+l_ab)/2) #V\n", + "\n", + "V_B = V_P - (drop_b + drop_ub) #V\n", + "\n", + "print \"Volatge at point Q is = \",round(V_Q,2),\"V.\"\n", + "print \"Voltage at point B is = \",round(V_B,2),\"V.\" " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.10 ,Page No :- 1583" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current in section AC is = 53.75 A.\n", + "Current in section CD is = 33.75 A.\n", + "Current in section DE is = -6.25 A.\n", + "Current in section EF is = -31.25 A.\n", + "Current in section FB is = -61.25 A.\n", + "Minimum voltage is at point D and minimum voltage is = 233.18 V.\n" + ] + } + ], + "source": [ + "#A distributor AB is fed from both ends.At feeding point A,the voltage is maintained at 236V and at B at 237V.\n", + "#The total length of the distributor is 200 metres and loads are tapped off as under:\n", + "#(i) 20A at 50 metres from A (ii) 40A at 75 metres from A. (iii)25A at 100 metres from A (iv)30A at 150 metres from A\n", + "#The reistance per kilometre of one conductor is 0.4ohm.Calculate the currents in the various sections of the distributor,\n", + "#the minimum voltage and the point at which it occurs.\n", + "###########################################################################################################################\n", + "\n", + "\n", + "#Given\n", + "#resistance per metre\n", + "res = 2*0.4/1000 #ohm/m\n", + "V_a = 236.0 #V\n", + "V_b = 237.0 #V\n", + "#loads and their positions\n", + "i_c = 20.0 #A\n", + "i_d = 40.0 #A\n", + "i_e = 25.0 #A\n", + "i_f = 30.0 #A\n", + "l_ac = 50.0 #m\n", + "l_cd = 25.0 #m\n", + "l_de = 25.0 #m\n", + "l_ef = 50.0 #m\n", + "l_fb = 50.0 #m\n", + "#Voltage drop equation res*(50i + 25(i-20)+25(i-60) + 50(i-85) + 50(i-115)=-1)\n", + "current_i = ((V_a-V_b)/res + l_cd*(i_c)+l_de*(i_c+i_d)+l_ef*(i_c+i_d+i_e)+l_fb*(i_c+i_d+i_e+i_f))/200.0\n", + "current_ac = current_i\n", + "current_cd = current_ac-i_c\n", + "current_de = current_cd-i_d\n", + "current_ef = current_de-i_e\n", + "current_fb= current_ef-i_f\n", + "if current_cd>0:\n", + " if current_de<0:\n", + " point = \"D\"\n", + "#Minimum potential is at D as shown in figure\n", + "drop = res*(current_ac*l_ac + current_cd*l_cd)\n", + "V_d = V_a-drop\n", + "print \"Current in section AC is = \",round(current_ac,2),\"A.\"\n", + "print \"Current in section CD is = \",round(current_cd,2),\"A.\"\n", + "print \"Current in section DE is = \",round(current_de,2),\"A.\"\n", + "print \"Current in section EF is = \",round(current_ef,2),\"A.\"\n", + "print \"Current in section FB is = \",round(current_fb,2),\"A.\"\n", + "print \"Minimum voltage is at point\",point,\"and minimum voltage is = \",round(V_d,2),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.11 ,Page No :- 1584" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current supplied by feeder at point A is 46.29 A and that by point B is 109.71 A.\n", + "Voltage at point B is = 240.55 V.\n", + "Voltage at point C is = 239.63 V.\n", + "Voltage at point D is = 239.42 V.\n", + "Voltage at point E is = 239.38 V.\n" + ] + } + ], + "source": [ + "#A distributor cable AB is fed at its ends A and B.Loads of 12,24,72 and 48 A are taken from the cable at\n", + "#points C,D,E and F.The resistances of sections AC,CD,DE,EF and FB of the cable are 8,6,4,10 and 5 milliohm\n", + "#respecively(for the go and return conductors together). The potential difference at point A is 240V,the p.d\n", + "#at the load F is also to be 240V.Calculate the voltages at the feeding point B,the current supplied by each\n", + "#feeder and the p.d.s at the loads C,D and E.\n", + "##############################################################################################################\n", + "\n", + "#Given\n", + "V_a = 240.0 #V \n", + "V_f = 240.0 #V\n", + "#loads and their resistances.\n", + "i_c = 12.0 #A\n", + "i_d = 24.0 #A\n", + "i_e = 72.0 #A\n", + "i_f = 48.0 #A\n", + "\n", + "r_ac = 8e-3 #ohm\n", + "r_cd = 6e-3 #ohm\n", + "r_de = 4e-3 #ohm\n", + "r_ef = 10e-3 #ohm\n", + "r_fb = 5e-3 #ohm\n", + "\n", + "#Voltage drop accross AF is zero.Therefore equation 8i +6(i-12) + 4(i-36)+10(i-108)*10^(-3)\n", + "current_i = (r_cd*i_c + r_de*(i_c+i_d) + r_ef*(i_c+i_d+i_e))/(28.0e-3) #A\n", + "#currents in different sections\n", + "current_ac = current_i #A\n", + "current_cd= current_ac-i_c #A\n", + "current_de = current_cd-i_d #A\n", + "current_ef = current_de-i_e #A \n", + "current_fb = current_ef-i_f #A\n", + "#voltage at different points are\n", + "V_b = V_f - current_fb*r_fb #V\n", + "V_c = V_a - current_ac*r_ac #V\n", + "V_d = V_c - current_cd*r_cd #V\n", + "V_e = V_d - current_de*r_de #V \n", + "\n", + "print \"Current supplied by feeder at point A is\",round(current_ac,2),\"A and that by point B is\",round(abs(current_fb),2),\"A.\"\n", + "print \"Voltage at point B is = \",round(V_b,2),\"V.\"\n", + "print \"Voltage at point C is = \",round(V_c,2),\"V.\"\n", + "print \"Voltage at point D is = \",round(V_d,2),\"V.\"\n", + "print \"Voltage at point E is = \",round(V_e,2),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.12 ,Page No :- 1585" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The current supplied at P is = 143.75 A.\n", + "The current supplied at Q is = 116.25 A.\n", + "Power dissipated in distributor is = 847.34 W.\n" + ] + } + ], + "source": [ + "#A two-wire d.c sdistributor PQ,800 metre long is loaded as under:\n", + "#Distance from P(metres): 100 250 500 600 700\n", + "#Loads in amperes: 20 80 50 70 40\n", + "#The feeding point at P is maintained at 248V and that at Q at 245V.The total resistance of\n", + "#the distributor(lead and return) is 0.1 ohm.Find (a)the current supplied at P and Q and\n", + "#(b)the power dissipated in the distributor.\n", + "##################################################################################################\n", + "\n", + "#Given\n", + "V_p = 248.0 #V\n", + "V_q = 245.0 #V\n", + "res = 0.1/800 #ohm/m \n", + "#loads and their positions\n", + "i1 = 20.0 #A\n", + "i2 = 80.0 #A\n", + "i3 = 50.0 #A\n", + "i4 = 70.0 #A\n", + "i5 = 40.0 #A\n", + "l1 = 100.0 #m\n", + "l2 = 250.0-100.0 #m\n", + "l3 = 500.0 -250.0 #m\n", + "l4 = 600.0-500.0 #m\n", + "l5 = 700.0-600.0 #m\n", + "l6 = 800.0-700.0 #m\n", + "#drop accross the distributor :- 1/8000(100i + 150(i-20) + 250(i-100)+ 100(i-150)+100(i-220)+100(i-260) )=3\n", + "current_i = ((V_p-V_q)/res + l2*i1+l3*(i1+i2)+l4*(i1+i2+i3)+l5*(i1+i2+i3+i4)+l6*(i1+i2+i3+i4+i5))/800.0\n", + "current_p = current_i #A\n", + "current_2 = current_p-i1 #A\n", + "current_3 = current_2-i2 #A\n", + "current_4 = current_3-i3 #A\n", + "current_5 = current_4-i4 #A\n", + "current_q = current_5-i5 #A\n", + "#Power loss = sum(I^2R)\n", + "loss = res*(current_p*current_p*l1 + current_2*current_2*l2 + current_3*current_3*l3 + current_4*current_4*l4 + current_5*current_5*l5 + current_q*current_q*l6)\n", + "print \"The current supplied at P is = \",round(current_p,2),\"A.\"\n", + "print \"The current supplied at Q is = \",round(abs(current_q),2),\"A.\"\n", + "print \"Power dissipated in distributor is =\",round(loss,2),\"W.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.13 ,Page No :- 1586" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The point of minimum potential is D and minimum potential is = 231.76 V.\n", + "Current fed at the end A is = 366.0 A.\n", + "Current fed at the end B is = 454.0 A.\n" + ] + } + ], + "source": [ + "#The two conductors of a d.c distributor cable 1000m long have a total resistance of 0.1 ohm.\n", + "#The ends A and B are fed at 240V.The cable is uniformly loaded at 0.5 A per metre length\n", + "#and has concentrated loads of 120A,60A,100A and 40A at points distant 200,400,700 and 900m.\n", + "#respectively from the end A.Calculate (i)the point of minimum potential on the distributor\n", + "#(ii)the value of minimum potential and (iii) currents fed at the ends A and B.\n", + "###############################################################################################\n", + "\n", + "#Given\n", + "V_a = 240.0 #V\n", + "V_b = 240.0 #V\n", + "res = 0.1/1000 #ohm/m\n", + "#concentrated loads and their positions\n", + "i_c = 120.0 #A\n", + "i_d = 60.0 #A\n", + "i_e = 100.0 #A\n", + "i_f = 40.0 #A\n", + "l_ac = 200.0 #m\n", + "l_cd = 400.0-200.0 #m\n", + "l_de = 700.0-400.0 #m\n", + "l_ef = 900.0-700.0 #m\n", + "l_fb = 1000.0-900.0 #m\n", + "#Uniform loading\n", + "cur_uni = 0.5 #A/m\n", + "#Equation for drop from A to B -> (1/10000)*(200i + 200(i-120)+ 300(i-180)+200(i-280)+100(i-320))=0\n", + "current_i = (l_cd*i_c + l_de*(i_c+i_d)+l_ef*(i_c+i_d+i_e)+l_fb*(i_c+i_d+i_e+i_f))/1000\n", + "\n", + "#point of minimum potential\n", + "current_ac = current_i #A\n", + "current_cd = current_ac-i_c #A\n", + "current_de = current_cd-i_d #A\n", + "current_ef = current_de-i_e #A\n", + "current_fb = current_ef-i_f #A\n", + "\n", + "if current_cd>0:\n", + " if current_de<0:\n", + " point = \"D\"\n", + "#As from figure it is inferred that point of minimum potential is D.\n", + "#Therefore,uniform load from point A to D(supplied from A)\n", + "cur_uni_A = cur_uni*(l_ac + l_cd) #A\n", + "cur_A = cur_uni_A + current_ac #A\n", + "#Therefore,uniform load from point B to D(supplied from B)\n", + "cur_uni_B = cur_uni*(l_de + l_ef + l_fb) #A\n", + "cur_B = cur_uni_B + abs(current_fb) #A\n", + "\n", + "#drop at D due to concentrated load(from A)\n", + "drop_con = res*(current_ac*l_ac + current_cd*l_cd)\n", + "#drop at D due to uniform load(from A)[formula-> irl^2/2]\n", + "drop_uni = cur_uni*res*(l_ac+l_cd)*(l_ac+l_cd)/2\n", + "#total drop is\n", + "drop_tot = drop_con + drop_uni\n", + "\n", + "#potential at D is\n", + "V_d = V_a - drop_tot\n", + "print \"The point of minimum potential is\",point,\"and minimum potential is = \",round(V_d,2),\"V.\"\n", + "print \"Current fed at the end A is = \",round(cur_A,2),\"A.\"\n", + "print \"Current fed at the end B is = \",round(cur_B,2),\"A.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.14 ,Page No :- 1587" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage V is = 8.62 V.\n", + "Cross-sectional Area A is = 2.78 cm^2.\n", + "Cross-sectional Area A1 is = 0.26 cm^2.\n", + "Cross-sectional Area A2 is = 2.24 cm^2.\n" + ] + } + ], + "source": [ + "#It is proposed to lay out a d.c distribution system comprising three sections-the first section consists\n", + "#of a cable from the sub-station to a point distant 800 metres from which two cables are taken,one 350 metres\n", + "#long supplying a load of 22kW and the other 1.5 kilometre long and supplying a load of 44kW.Calculate the\n", + "#cross-sectional area of each cable so that the total weight of copper required shall be minimum if the maximum\n", + "#drop of voltage along the cable is not to exceed 5% of the normal voltage of 440V at the consumer's premises.\n", + "#Take specific resistance of copper at working temperature equal to 2*10e-7 ohm-cm.\n", + "###################################################################################################################\n", + "\n", + "#Given\n", + "resistivity = 2*10e-7 #ohm-cm\n", + "dist = 800.0*100 #cm\n", + "#Current taken from 350m section\n", + "cur_1 = 22000.0/440\n", + "#Current taken from 1.5km section\n", + "cur_2 = 44000.0/440\n", + "#Therefore,current in first section\n", + "cur = cur_1 + cur_2\n", + "#Let us assume\n", + "#V->voltage drop accross first section\n", + "#R->resistance of the first section\n", + "#A->cross-sectional area of te first section\n", + "\n", + "from sympy import Eq, var, solve\n", + "var('V') \n", + "#Now , R = V/I\n", + "R = V/cur\n", + "# A = resistivity*l/R -> A = resistivity*l*I/V \n", + "A = resistivity*dist/R\n", + "#Max allowable drop\n", + "max_drop = (5.0/100)*440.0\n", + "#Voltage drop along other sections\n", + "vol_drop = max_drop - V\n", + "#Cross-sectional area of 350 m A = resistivity*l/R \n", + "A1 = resistivity*350.0*100*cur_1/(vol_drop)\n", + "#Cross-sectional area of 1.5km A = resistivity*l/R \n", + "A2 = resistivity*1500.0*100*cur_2/(vol_drop)\n", + "\n", + "\n", + "#Now,Total weight is propotional to total volume \n", + "W = 800.0*A + 350.0*A1+1500.0*A2\n", + "Diff = W.diff(V)\n", + "eq = Eq(Diff,0)\n", + "\n", + "V = solve(eq)\n", + "#We get 2 values of V of which Negative is not possible.Therefore,\n", + "V = float(V[1])\n", + "A = resistivity*dist*cur/V\n", + "vol_drop = max_drop - V\n", + "A1 = resistivity*350.0*100*cur_1/vol_drop\n", + "A2 = resistivity*1500.0*100*cur_2/vol_drop\n", + "print \"Voltage V is = \",round(V,2),\"V.\"\n", + "print \"Cross-sectional Area A is = \",round(A,2),\"cm^2.\"\n", + "print \"Cross-sectional Area A1 is = \",round(A1,2),\"cm^2.\"\n", + "print \"Cross-sectional Area A2 is = \",round(A2,2),\"cm^2.\"\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.15 ,,Page No :- 1588" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The point of minimum potential is at 261.74 m from A.\n", + "The minimum potential is = 247.34 V.\n" + ] + } + ], + "source": [ + "#A d.c two-wire distributor AB is 450m long and is fed at both ends at 250 volts.It is loaded as follows:20A at 60m from A,\n", + "#40A at 100m from A and a uniform loading of 1.5A/m from 200 to 450m from A.The resistance of each conductor is\n", + "#0.05ohm/km.Find the point of minimum potential and its potential.\n", + "####################################################################################################################\n", + "\n", + "#Given\n", + "V_a = 250.0 #V\n", + "V_b = 250.0 #V\n", + "res = 0.05/1000 #ohm/m\n", + "cur_uni = 1.5 #A/m (uniform loading)\n", + "#loads and positions\n", + "i_c = 20.0 #A\n", + "i_d = 40.0 #A\n", + "l_ac = 60.0 #m\n", + "l_cd = 40.0 #m\n", + "l_de = 100.0 #m\n", + "l_eb = 250.0 #m\n", + "\n", + "#Let us assume that point of minimum potential is D and let i be current in section CD.\n", + "#Therefore,current from B is (40-i).If r is resistance then\n", + "#(20+i)*60r + i*40r = (40-i)*350r + 1.5*r*250^2/2 [drop over AD = drop over BD as V_a = V_b]\n", + "\n", + "cur_i = (i_d*(l_de+l_eb)*res + cur_uni*res*l_eb*l_eb/2 - i_c*l_ac*res)/((l_ac+l_cd+l_de+l_eb)*res) #A\n", + "\n", + "#cur_i > 40 i.e 40-i is negative,it means D is not point of minimum potential.Let F be point of minimum potential(between DB)\n", + "#current in section DF is\n", + "cur_df = cur_i-i_d #A\n", + "\n", + "#distance EF\n", + "dist_ef = cur_df/cur_uni #m\n", + "\n", + "#distance of F from A is\n", + "dist = l_ac + l_cd + l_de + dist_ef #m\n", + "\n", + "#total drop over AF is [(20+i)*60r + i*40r+ (i-40)*161.7r - 1.5*r*61.7^2/2\n", + "drop_af = 2*res*((i_c+cur_i)*l_ac + cur_i*l_cd + cur_df*(l_de+dist_ef)-cur_uni*dist_ef*dist_ef/2) #V\n", + "#potential at F\n", + "V_f = V_a - drop_af #V\n", + "print \"The point of minimum potential is at\",round(dist,2),\"m from A.\"\n", + "print \"The minimum potential is = \",round(V_f,2),\"V.\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.16 ,Page No :- 1588" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current fed at A is = 225.0 A.\n", + "Current fed at B is = 475.0 A.\n", + "Point of minimum potential from B is = 475.0 metres.\n", + "Voltage at minimum potential is = 230.72 V.\n" + ] + } + ], + "source": [ + "#A two-wire d.c distributor AB,1000 metres long,is supplied from both ends,240V at A and 242V at B.There is a\n", + "#concentrated load of 200A at a distance of 400 metre from A and a uniformly distrubuted load of 1.0A/m between\n", + "#the mid-point and end B.Determine (i)the currents fed at A and B(ii)the point of minimum potential and\n", + "#(iii)voltage at this point.Take cable resistance as 0.005 ohm per 100 metre each core.\n", + "#####################################################################################################################\n", + "\n", + "#Given\n", + "#resistance per 100 metres\n", + "res = 2*0.005/100 #ohm/m\n", + "cur_uni = 1.0 #A/m\n", + "cur_con = 200.0 #A\n", + "len_uni = 500.0\n", + "#Let us assume that Ib current flows from point B.\n", + "#Considering a element dx in BD(500 metres) at a distance of X units(100 m each)\n", + "#voltage drop over dx = (1-100*x)*res*dx\n", + "#voltage drop over BD by integrating is = 0.05*Ib - 12.5\n", + "#voltage drop over DC = (Ib-500)*0.01\n", + "#voltage drop over CA = (Ib-700)*0.01*4\n", + "#total drop over AB = \n", + "tot_drop = 242.0-240.0\n", + "#summation of drops from AC + CD + DB\n", + "from sympy import Eq, var, solve\n", + "var('Ib') \n", + "sum = (Ib-500)*0.01 +(Ib-700)*0.01*4 + 0.05*Ib - 12.5\n", + "\n", + "eq = Eq(sum,tot_drop)\n", + "\n", + "Ib = solve(eq)\n", + "Ib = float(Ib[0])\n", + "#Total current\n", + "cur_tot = len_uni*cur_uni + cur_con\n", + "Ia = cur_tot - Ib #A\n", + "#Current in distributed load\n", + "cur_dis = Ia-cur_con #A\n", + "#point of minimum potential from D is\n", + "distD = cur_dis/cur_uni\n", + "#Therefore distance from B is\n", + "distB = len_uni-distD\n", + "#Therefore voltage drop is\n", + "from scipy.integrate import quad\n", + "\n", + "def integrand(x):\n", + " return (Ib-100*x)*res*100\n", + "\n", + "ans, err = quad(integrand, 0, (distB/100))\n", + "#Therefore potential of M is\n", + "pot_M = 242.0-ans #V\n", + "print \"Current fed at A is = \",Ia,\"A.\"\n", + "print \"Current fed at B is = \",Ib,\"A.\"\n", + "print \"Point of minimum potential from B is = \",distB,\"metres.\"\n", + "print \"Voltage at minimum potential is = \",round(pot_M,2),\"V.\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.17 ,Page No :- 1590" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage at B is = 236.9 V.\n", + "Voltage at C is = 235.98 V.\n", + "Voltage at D is = 237.45 V.\n" + ] + } + ], + "source": [ + "#A 400-metre ring distributor has loads as shown in Fig. 40.29(a) where distances are in metres.The resistance\n", + "#of each conductor is 0.2 ohm per 1000 metres and the loads tapped off at points B,C,D are as shown.If the\n", + "#distributor is fed at A,find voltages at B,C and D.\n", + "#################################################################################################################\n", + "\n", + "#Given\n", + "\n", + "res = 0.2/1000 #ohm/m\n", + "V_a = 240.0 #V\n", + "#loads and positions\n", + "i_b = 100.0 #A\n", + "i_c = 70.0 #A\n", + "i_d = 50.0 #A\n", + "l_ab = 60.0 #m\n", + "l_bc = 80.0 #m\n", + "l_cd = 90.0 #m\n", + "l_da = 70.0 #m\n", + "\n", + "#total drop ->70i + 90(i-50)+80(i-120)+60(i-220)=0\n", + "cur_i = (l_cd*i_d + l_bc*(i_d+i_c) + l_ab*(i_d+i_c+i_b))/(l_ab+l_bc+l_cd+l_da)\n", + "#drops in different sections\n", + "drop_da = 2*cur_i*l_da*res\n", + "drop_cd = 2*(cur_i-i_d)*l_cd*res\n", + "drop_bc = 2*abs(cur_i-i_d-i_c)*l_bc*res\n", + "drop_ab = 2*abs(cur_i-i_d-i_c-i_b)*l_ab*res\n", + "\n", + "#voltages at different points\n", + "V_d = V_a - drop_da\n", + "V_c = V_d - drop_cd\n", + "V_b = V_a - drop_ab\n", + "print \"Voltage at B is = \",round(V_b,2),\"V.\"\n", + "print \"Voltage at C is = \",round(V_c,2),\"V.\"\n", + "print \"Voltage at D is = \",round(V_d,2),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.18 ,Page No :- 1591" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage at B is = 394.2 V.\n", + "Voltage at C is = 393.42 V.\n", + "Current in section BC is = 43.33 A.\n" + ] + } + ], + "source": [ + "#In a direct current ring main,a voltage of 400V is maintained at A.At B,500 metres away from A,a load of 150A is taken\n", + "#and at C,300 metres from B,a load of 200A is taken.The distance between A and C is 700 metres.The resistance of each\n", + "#conductor of the mains is 0.03ohm per 1000 metres.Find the voltage at B and C and also find the current in the section BC.\n", + "##############################################################################################################################\n", + "\n", + "#Given\n", + "V_a = 400.0 #V\n", + "res = 0.03/1000 #ohm/m\n", + "#loads and positions\n", + "i_b = 150.0 #A\n", + "i_c = 200.0 #A\n", + "l_ab = 500.0 #m\n", + "l_bc = 300.0 #m\n", + "l_ca = 700.0 #m\n", + "\n", + "#total drop-> 500i + 300(i-150) + 700(i-350) = 0\n", + "cur_i = (l_bc*i_b + l_ca*(i_b+i_c))/(l_ab+l_bc+l_ca)\n", + "#current in different sections\n", + "cur_ab = cur_i\n", + "cur_bc = cur_i-i_b\n", + "cur_ca = abs(cur_bc-i_c)\n", + "#drops in different sections\n", + "drop_ab = 2*cur_ab*l_ab*res\n", + "drop_bc = 2*cur_bc*l_bc*res\n", + "#voltages in different sections\n", + "V_b = V_a-drop_ab\n", + "V_c = V_b-drop_bc\n", + "print \"Voltage at B is = \",round(V_b,2),\"V.\"\n", + "print \"Voltage at C is = \",round(V_c,2),\"V.\"\n", + "print \"Current in section BC is = \",round(cur_bc,2),\"A.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.19 ,Page No :- 1591" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current in AB,BC,CD,DE,EA is 29.04 A, 19.04 A, 0.96 A, 30.96 A, 40.96 A respectively.\n", + "\n", + "Voltage at B,C,D,E is 217.1 V, 216.14 V, 216.15 V, 216.93 V respectively\n", + "\n", + "Current in AB,BC,DE,CE,EA is 27.72 A, 17.72 A, 32.28 A, 9.76 A, 42.28 A respectively.\n", + "\n", + "Voltage at B,C,D,E is 217.23 V, 216.34 V, 216.02 V, 216.83 V respectively\n" + ] + } + ], + "source": [ + "#A d.c ring main ABCDE is fed at point A from a 220-V supply and the resistances(including both lead and return)\n", + "#of the various sections are as follows(in ohms):AB=0.1;BC=0.05;CD=0.01;DE=0.025 and EA=0.075.The main supplies\n", + "#loads of 10A at B; 20A at C; 30A at D and 10A at E.Find the magnitude and direction of the current flowing in each\n", + "#section and the voltage at each load point.\n", + "#If the points C and E are further linked together by a conductor of 0.05 ohm resistance and the output currents\n", + "#from the mains remain unchanged,find the new distribution of the current and voltage in the network.\n", + "#####################################################################################################################\n", + "\n", + "#Given\n", + "\n", + "V_a = 220.0 #V\n", + "#resistances of different sections\n", + "r_ab = 0.1 #ohm\n", + "r_bc = 0.05 #ohm\n", + "r_cd = 0.01 #ohm\n", + "r_de = 0.025 #ohm\n", + "r_ea = 0.075 #ohm\n", + "#loads\n", + "i_b = 10.0 #A\n", + "i_c = 20.0 #A\n", + "i_d = 30.0 #A\n", + "i_e = 10.0 #A\n", + "#total drop -> 0.1i + 0.05(i-10) + 0.01(i-30) + 0.025(i-60) + 0.075(i-70)=0\n", + "cur_i = (r_bc*i_b + r_cd*(i_b+i_c) + r_de*(i_b+i_c+i_d) + r_ea*(i_b+i_c+i_d+i_e))/(r_ab+r_bc+r_cd+r_de+r_ea)\n", + "#current in different sections\n", + "cur_ab = cur_i\n", + "cur_bc = cur_ab-i_b\n", + "cur_cd = cur_bc-i_c\n", + "cur_de = cur_cd-i_d\n", + "cur_ea = cur_de-i_e\n", + "\n", + "#drops in different sections\n", + "drop_ab = cur_ab*r_ab\n", + "drop_bc = cur_bc*r_bc\n", + "drop_de = abs(cur_de)*r_de\n", + "drop_ea = abs(cur_ea)*r_ea\n", + "#voltages at different points\n", + "V_b = V_a - drop_ab\n", + "V_c = V_b - drop_bc\n", + "V_e = V_a - drop_ea\n", + "V_d = V_e - drop_de\n", + "print \"Current in AB,BC,CD,DE,EA is\",round(cur_ab,2),\"A,\",round(cur_bc,2),\"A,\",round(abs(cur_cd),2),\"A,\",round(abs(cur_de),2),\"A,\",round(abs(cur_ea),2),\"A respectively.\" \n", + "print \"\"\n", + "print \"Voltage at B,C,D,E is\",round(V_b,2),\"V,\",round(V_c,2),\"V,\",round(V_d,2),\"V,\",round(V_e,2),\"V respectively\"\n", + "print \"\"\n", + "#part-2\n", + "#Potential difference between end points of interconnector(CE)\n", + "V_ce = V_e-V_c\n", + "#Resistance between CE ,as shown in figure\n", + "r1 = r_ab+r_bc+r_ea\n", + "r2 = r_de + r_cd\n", + "res_ce = r1*r2/(r1+r2)+ 0.05\n", + "\n", + "#Current in interconnector [I = V/R Ohm's Law]\n", + "cur_ce = V_ce/res_ce\n", + "#Current goes from E to C as E is at higher potential.\n", + "\n", + "#The current in other sections will also change.\n", + "#let us assume i1 along ED, voltage round the closed mesh EDC is zero.\n", + "#total drop -> -0.025*i1-0.01*(i1-30)+0.05*9.75 = 0\n", + "\n", + "cur_i1 = (0.05*cur_ce + r_cd*i_d)/(r_cd+r_de)\n", + "\n", + "current_ea = i_e+cur_i1+cur_ce\n", + "current_ab = (i_b+i_c+i_d+i_e)-current_ea\n", + "current_bc = current_ab-i_b\n", + "current_de = current_ea-i_e\n", + "#new drops\n", + "drop_ab = current_ab*r_ab\n", + "drop_bc = current_bc*r_bc\n", + "drop_ea = current_ea*r_ea\n", + "drop_de = current_de*r_de\n", + "\n", + "#new potentials\n", + "V_b = V_a - drop_ab\n", + "V_c = V_b - drop_bc\n", + "V_e = V_a - drop_ea\n", + "V_d = V_e - drop_de\n", + "\n", + "print \"Current in AB,BC,DE,CE,EA is\",round(current_ab,2),\"A,\",round(current_bc,2),\"A,\",round(current_de,2),\"A,\",round(cur_ce,2),\"A,\",round(current_ea,2),\"A respectively.\"\n", + "print \"\"\n", + "print \"Voltage at B,C,D,E is\",round(V_b,2),\"V,\",round(V_c,2),\"V,\",round(V_d,2),\"V,\",round(V_e,2),\"V respectively\" \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.20 ,Page No :- 1594" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage across 3 ohm load is = 244.9 V.\n", + "Voltage across 4 ohm load is = 247.9 V.\n" + ] + } + ], + "source": [ + "#In a 3-wire distribution system,the supply voltage is 250V on each side.The load on one side is a 3 ohm\n", + "#resistance and on the other, a 4 ohm resistance.The resistance of each of the 3 conductors is 0.05 ohm.\n", + "#Find the load voltages.\n", + "#########################################################################################################\n", + "\n", + "import numpy as np\n", + "#Given\n", + "#Resistances\n", + "res_1 = 3.0 #ohm\n", + "res_2 = 4.0 #ohm\n", + "res_con = 0.05 #ohm\n", + "V_sup = 250.0 #V\n", + "\n", + "#Let the assumed directions of unknown currents be as shown in figure.\n", + "#KVL for ABCD\n", + "# (3+0.05)x + 0.05(x-y) = 250 -------------- eqn 1\n", + "a = res_1 + 2*res_con\n", + "b = -(res_con)\n", + "#KVL for DCEFD\n", + "# 0.05(y-x) + (4+0.05)y = 250 -------------- eqn 2\n", + "c = res_2+ 2*res_con \n", + "#Solving eqn 1 and eqn2\n", + "m = [[a,b],[b,c]]\n", + "n = [V_sup,V_sup]\n", + "soln = np.linalg.solve(m,n) #soln is array with its elements[x,y]\n", + "#Calculating the load voltages\n", + "#V1 = 250-0.05*x-0.05(x-y)\n", + "vol1 = V_sup - res_con*soln[0]-res_con*(soln[0]-soln[1]) #V\n", + "#V2 = 250 + 0.05(x-y)- 0.05y\n", + "vol2 = V_sup + res_con*(soln[0]-soln[1]) - res_con*soln[1] #V\n", + "print \"Voltage across 3 ohm load is = \",round(vol1,1),\"V.\"\n", + "print \"Voltage across 4 ohm load is = \",round(vol2,1),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.21 ,Page No :- 1594" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Potential Difference across AB is = 248.62 V.\n", + "Potential Difference across QK is = 247.83 V.\n", + "Potential Difference across CD is = 248.4 V.\n", + "Potential Difference across FE is = 247.65 V.\n" + ] + } + ], + "source": [ + "#A 3-wire d.c distributor PQ,250 metres long,is supplied at end P at 500/250V and is loaded as under:\n", + "#Positive side: 20A 150 metres from P ; 30A 250 metres from P.\n", + "#Negative side: 24A 100 metres from P ; 36A 220 metres from P.\n", + "#The resistance of each outer wire is 0.02 ohm per 100 metres and the cross-section of the middle wire\n", + "#is one-half of the outer.Find the voltage across each load point.\n", + "##########################################################################################################\n", + "\n", + "#Given\n", + "V_PN = 250.0 #V\n", + "V_NR = 250.0 #V\n", + "res_out = 0.02/100 #ohm/m\n", + "res_mid = 2*res_out #ohm/m (Area of middle wire is half.As, R = rho*l/A .Therefore,Resistance doubles)\n", + "\n", + "#Given Currents\n", + "i_ab = 20.0 #A\n", + "i_qk = 30.0 #A\n", + "i_cd = 24.0 #A\n", + "i_fe = 36.0 #A\n", + "\n", + "#Currents in different sections\n", + "i_pa = i_ab+i_qk #A\n", + "i_aq = i_qk #A\n", + "i_fk = i_qk #A\n", + "i_bf = i_fe-i_qk #A\n", + "i_bc = i_ab-i_bf #A\n", + "i_cn = i_cd-i_bc #A\n", + "i_de = i_fe #A\n", + "i_dr = i_cd+i_fe #A\n", + "\n", + "\n", + "#lengths of different sections\n", + "l_pa = 150.0 #m\n", + "l_aq = 100.0 #m\n", + "l_kf = 250.0-220.0 #m\n", + "l_bc = 150.0-100.0 #m\n", + "l_bf = 220.0-150.0 #m\n", + "l_cn = 100.0 #m\n", + "l_de = 220.0-100.0 #m\n", + "l_dr = 100.0 #m\n", + "\n", + "#Resistances of different sections\n", + "r_pa = l_pa*res_out #ohm\n", + "r_aq = l_aq*res_out #ohm\n", + "r_kf = l_kf*res_mid #ohm\n", + "r_bc = l_bc*res_mid #ohm\n", + "r_bf = l_bf*res_mid #ohm\n", + "r_cn = l_cn*res_mid #ohm\n", + "r_de = l_de*res_out #ohm\n", + "r_dr = l_dr*res_out #ohm\n", + "\n", + "#Drop across different sections\n", + "drop_pa = r_pa*i_pa #V\n", + "drop_aq = r_aq*i_aq #V\n", + "drop_kf = r_kf*i_fk #V\n", + "drop_bc = r_bc*i_bc #V\n", + "drop_bf = r_bf*i_bf #V\n", + "drop_cn = r_cn*i_cn #V\n", + "drop_de = r_de*i_de #V\n", + "drop_dr = r_dr*i_dr #V\n", + "\n", + "#Voltages across different sections\n", + "vol_ab = V_PN - drop_pa - drop_bc + drop_cn #V\n", + "vol_qk = vol_ab - drop_aq - drop_kf + drop_bf #V\n", + "vol_cd = V_NR - drop_cn - drop_dr #V \n", + "vol_fe = vol_cd + drop_bc - drop_bf - drop_de #V\n", + "\n", + "print \"Potential Difference across AB is = \",round(vol_ab,2),\"V.\"\n", + "print \"Potential Difference across QK is = \",round(vol_qk,2),\"V.\"\n", + "print \"Potential Difference across CD is = \",round(vol_cd,2),\"V.\"\n", + "print \"Potential Difference across FE is = \",round(vol_fe,2),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.22 ,Page No :- 1597" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total load on main generator is = 155.0 kW.\n", + "Load on Balancer 1 is = 22.5 kW.\n", + "Load on Balancer 2 is = 27.5 kW.\n" + ] + } + ], + "source": [ + "#A d.c 3-wire system with 500-V between outers has lighting load of 100kW on the positive and 50kW on the\n", + "#negative side.If,at this loading,the balancer machines have each a loss of 2.5kW,Calculate the kW loading\n", + "#of each balancer machine and the total load on the system.\n", + "###########################################################################################################\n", + "\n", + "#Given\n", + "V_out = 500.0 #V\n", + "load_p = 100.0 #kW (positive side)\n", + "load_n = 50.0 #KW (negative side)\n", + "load_b = 2.5 #kW (balancer machine)\n", + "#total load on main generator\n", + "load_tot = load_p + load_n + 2*load_b #kW\n", + "#Output current of main generator\n", + "cur_out = load_tot*1000/V_out #W/V->A\n", + "#load current on positive side\n", + "cur_p = load_p*1000/(V_out/2) #A\n", + "#load current on negative side\n", + "cur_n = load_n*1000/(V_out/2) #A\n", + "#Current through neutral(Out of balance)\n", + "cur_o = cur_p-cur_n #A\n", + "\n", + "#Currents of balancer\n", + "cur_b1 = cur_p-cur_out #A\n", + "cur_b2 = cur_o - cur_b1 #A\n", + "\n", + "#Load on balancer\n", + "load_b1 = (V_out/2)*cur_b1/1000 #kW\n", + "load_b2 = (V_out/2)*cur_b2/1000 #kW\n", + "\n", + "print \"Total load on main generator is = \",round(load_tot,2),\"kW.\"\n", + "print \"Load on Balancer 1 is = \",round(load_b1,2),\"kW.\"\n", + "print \"Load on Balancer 2 is = \",round(load_b2,2),\"kW.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.23 ,Page No :- 1598" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total load on main generator is = 1216.0 kW.\n", + "Current through Balancer 1 is = 168.0 A.\n", + "Current through Balancer 2 is = 232.0 A.\n" + ] + } + ], + "source": [ + "#In a 500/250-V d.c 3-wire system,there is a current of 2000A on the +ve side, 1600A on the negative side\n", + "#and a load of 300 kW across the outers.The loss in each balancer set is 8 kW.Calculate the current in each\n", + "#armature of the balancer set and total load on the main generator.\n", + "#############################################################################################################\n", + "\n", + "#Given\n", + "V_out = 500.0 #V\n", + "cur_p = 2000.0 #A (current on positive side)\n", + "cur_n = 1600.0 #A (current on negative side)\n", + "load_ext = 300.0 #kW (across outers)\n", + "load_b = 8.0 #kW (loss in balancer set)\n", + "#loading on positive side\n", + "load_p = (cur_p*(V_out/2))/1000 #kW\n", + "#loading on negative side\n", + "load_n = (cur_n*(V_out/2))/1000 #kW\n", + "#Total loading on main generator\n", + "load_tot = load_p + load_n + 2*load_b + load_ext #kW\n", + "\n", + "#current on main generator -> I = W/V\n", + "cur_tot = load_tot*1000/V_out #A\n", + "\n", + "#current through neutral(out of balance)\n", + "cur_o = cur_p-cur_n #A\n", + "\n", + "#current through external resistance\n", + "cur_ext = load_ext*1000/V_out #A\n", + "\n", + "#current through balancer sets\n", + "cur_b1 = (cur_p+cur_ext)-cur_tot #A\n", + "cur_b2 = cur_o - cur_b1 #A\n", + "\n", + "print \"Total load on main generator is = \",round(load_tot,2),\"kW.\"\n", + "print \"Current through Balancer 1 is = \",round(cur_b1,2),\"A.\"\n", + "print \"Current through Balancer 2 is = \",round(cur_b2,2),\"A.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.24 ,Page No :- 1598" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current supplied by generator is = 7000.0 A.\n", + "Current in positive side is = 6000.0 A.\n", + "Current in negative side is = 8000.0 A.\n", + "Current in neutral is = 2000.0 A.\n", + "Current through armature 1 is = 1000.0 A.\n", + "Current through armature 2 is = 1000.0 A.\n" + ] + } + ], + "source": [ + "#On a 3-wire d.c distribution system with 500V between outers,there is a load of 1500kW on the positive\n", + "#side and 2000 kW on the negative side.Calculate the current in the neutral and in each of the balancer\n", + "#armatures and the total current supplied by the generator.Neglect losses.\n", + "##########################################################################################################\n", + "\n", + "#Given\n", + "V_out = 500.0 #V\n", + "load_p = 1500.0 #kW (load on positive side)\n", + "load_n = 2000.0 #kW (load on negative side)\n", + "#total loading on main generator\n", + "load_tot = load_p + load_n #kW\n", + "#current supplied by generator\n", + "cur_tot = load_tot*1000/V_out #A\n", + "#current on positive side\n", + "cur_p = load_p*1000/(V_out/2) #A\n", + "#current on negative side\n", + "cur_n = load_n*1000/(V_out/2) #A\n", + "#current in neutral(out of balance)\n", + "cur_o = abs(cur_p-cur_n) #A\n", + "#current through armatures\n", + "cur_b1 = cur_tot-cur_p #A\n", + "cur_b2 = cur_o-cur_b1 #A\n", + "\n", + "print \"Current supplied by generator is = \",cur_tot,\"A.\"\n", + "print \"Current in positive side is = \",cur_p,\"A.\"\n", + "print \"Current in negative side is = \",cur_n,\"A.\"\n", + "print \"Current in neutral is = \",cur_o,\"A.\"\n", + "print \"Current through armature 1 is = \",cur_b1,\"A.\"\n", + "print \"Current through armature 2 is = \",cur_b2,\"A.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.25 ,Page No :- 1599" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Current in balancer set 1 is = 22.0 A.\n", + "Current in balancer set 2 is = 28.0 A.\n", + "Output of main generator is = 119.5 kW.\n" + ] + } + ], + "source": [ + "#A 125/250 V,3-wire distributor has an out-of-balance current of 50 A and larger load of 500 A.The balancer\n", + "#set has a loss of 375 W in each machine.Calculate the current in each of the balancer machines and output\n", + "#of main generator.\n", + "############################################################################################################\n", + "\n", + "#Given\n", + "V_out = 250.0 #V\n", + "#Currents\n", + "cur_p = 500.0 #A\n", + "cur_o = 50.0 #A\n", + "cur_n = cur_p - cur_o #A\n", + "#larger Load\n", + "load_p = cur_p*(V_out/2)/1000 #kW\n", + "#smaller Load\n", + "load_n = cur_n*(V_out/2)/1000 #kW\n", + "#Balancer loss\n", + "loss_b = 2*375.0/1000 #kW\n", + "#total load on generator\n", + "load_tot = load_p + load_n + loss_b\n", + "#current from main generator -> VI = W\n", + "cur_tot = load_tot*1000/V_out #A\n", + "\n", + "#Current in balancer sets\n", + "cur_b1 = cur_p - cur_tot #A\n", + "cur_b2 = cur_o - cur_b1 #A\n", + "print \"Current in balancer set 1 is = \",cur_b1,\"A.\"\n", + "print \"Current in balancer set 2 is = \",cur_b2,\"A.\"\n", + "print \"Output of main generator is = \",load_tot,\"kW.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.26 ,Page No :- 1599" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total load on main generator is = 1210.0 kW.\n", + "Load on Balancer set 1 is = 20.0 kW.\n", + "Load on balancer set 2 is = 30.0 kW.\n" + ] + } + ], + "source": [ + "#The load on d.c 3-wire system with 500 V between outers consists of lighting current of 1500 A on the\n", + "#positive side and 1300 A on the negative side while motors connected across the outers absorb 500kW.\n", + "#Assuming that at this loading,the balancer machines have each a loss of 5kW,calculate the load on the\n", + "#main generator and on each of the balancer machines.\n", + "##########################################################################################################\n", + "\n", + "#Given\n", + "cur_p = 1500.0 #A\n", + "cur_n = 1300.0 #A\n", + "V_out = 500.0 #V\n", + "load_ext = 500.0 #kW\n", + "loss_b = 2*5.0 #kW\n", + "\n", + "#current through external load\n", + "cur_ext = load_ext*1000/V_out #A\n", + "#larger load\n", + "load_p = cur_p*(V_out/2)/1000 #kW\n", + "#smaller load\n", + "load_n = cur_n*(V_out/2)/1000 #kW\n", + "#total load on generator\n", + "load_tot = load_p + load_n + loss_b + load_ext #kW\n", + "#current from generator -> VI = W\n", + "cur_tot = load_tot*1000/V_out #A\n", + "#current through neutral(out of balance)\n", + "cur_o = cur_p-cur_n #A\n", + "#current through balancer sets\n", + "cur_b1 = (cur_p+cur_ext)-cur_tot #A\n", + "cur_b2 = cur_o-cur_b1 #A\n", + "#load of balancer sets\n", + "load_b1 = cur_b1*(V_out/2)/1000 #kW\n", + "load_b2 = cur_b2*(V_out/2)/1000 #kW\n", + "\n", + "print \"Total load on main generator is = \",load_tot,\"kW.\"\n", + "print \"Load on Balancer set 1 is = \",load_b1,\"kW.\"\n", + "print \"Load on balancer set 2 is = \",load_b2,\"kW.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.27 ,Page No :- 1599" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage across Balancer 1 is = 230.0 A.\n", + "Voltage across Balancer 2 is = 250.0 A.\n", + "Load current on main generator is = 1110.0 A.\n" + ] + } + ], + "source": [ + "#A d.c 3-wire system with 480 V across outers supplies 1200 A on the positive and 1000 A on the negative side.\n", + "#The balancer machines have each an armature resistances of 0.1W and take 10 A on no-load.Find\n", + "#(a)the voltage across each balancer and\n", + "#(b)the total load on the main generator and the current loading of each balancer machine.\n", + "#The balancer field windings are in series across the outers\n", + "################################################################################################################\n", + "\n", + "#Given\n", + "V_out = 480.0 #V\n", + "#currents\n", + "cur_p = 1200.0 #A\n", + "cur_n = 1000.0 #A\n", + "cur_o = cur_p - cur_n #A (out of balance)\n", + "#armature resistance \n", + "res_arm = 0.1 #ohm\n", + "#no-load current\n", + "cur_nold = 10.0 #A\n", + "\n", + "#Let us assume current Im flows through mtoring machine,then (200-Im) flows through generating machine.\n", + "#Let Vg and Vm be potential difference of 2 machines.\n", + "\n", + "#Total losses in sets = no-load losses + Cu losses in two machines\n", + "#loss_set = V_out*cur_nold + 0.1*Im^2+ 0.1*(200-Im)^2\n", + "#Vm*Im = Vg*Ig + loss_set\n", + "#Now, Vm = Eb+Im*Ra Vg = Eb-Ig*Ra\n", + "Eb = V_out/2-res_arm*cur_nold\n", + "\n", + "#Therefore, Vm = 239 + Im*0.1 and Vg = 239 - (200-Im)*0.1\n", + "#Hence,Equation is \n", + "#(239+0.1*Im)*Im = [239 - (200-Im)*0.1]*(200-Im) + loss_set\n", + "#Simplified -> 239Im = 239*(200-Im)+4800\n", + "\n", + "#Solving this equation\n", + "from sympy import Eq, var, solve\n", + "var('Im') \n", + "eq = Eq(Eb*(2*Im-cur_o),V_out*cur_nold)\n", + "Im = solve(eq)\n", + "Im = int(Im[0])\n", + "Ig = cur_o-Im\n", + "#Voltage across balancers\n", + "\n", + "Vm = Eb + Im*res_arm #V\n", + "Vg = Eb - Ig*res_arm #V \n", + "\n", + "#Load on main generator\n", + "cur_load = cur_p - Ig #A\n", + "print \"Voltage across Balancer 1 is = \",round(Vg,2),\"A.\"\n", + "print \"Voltage across Balancer 2 is = \",round(Vm,2),\"A.\"\n", + "print \"Load current on main generator is = \",round(cur_load,2),\"A.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.28 ,Page No :- 1600" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Voltage on positive side is = 283.0 V.\n", + "Voltage on negative side is = 177.0 V.\n" + ] + } + ], + "source": [ + "#A d.c 3-wire system with 460V between outers supplies 250kW on the positive and 400kW on the negative side,\n", + "#the voltages being balanced.Calculate the voltage on the positive and negative side,the voltages being balanced.\n", + "#Calculate the voltage on the positive and negative sides repectively,if the neutral wire becomes disconnected\n", + "#from balancer set.\n", + "#################################################################################################################\n", + "\n", + "#Given\n", + "V_mid = 230.0 #V\n", + "V_out = 460.0 #V\n", + "#loads\n", + "load_p = 250.0 #kW\n", + "load_n = 400.0 #kW\n", + "#resistance on positive side -> (V^2/R) = W\n", + "res_p = (V_mid*V_mid)/(load_p*1000) #ohm\n", + "\n", + "#resistance on negative side -> (V^2/R) = W\n", + "res_n = (V_mid*V_mid)/(load_n*1000) #ohm\n", + "\n", + "#Voltages after disconnecting balancer set\n", + "vol_p = (res_p/(res_p+res_n))*V_out #V\n", + "vol_n = V_out - vol_p #V\n", + "\n", + "print \"Voltage on positive side is = \",round(vol_p),\"V.\"\n", + "print \"Voltage on negative side is = \",round(vol_n),\"V.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "EXAMPLE 40.29 ,Page No :- 1601" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Terminal potential difference of the booster is = 180.0 V.\n", + "Output of booster is = 21.6 kW.\n" + ] + } + ], + "source": [ + "#A 2-wire system has the voltage at the supply end maintained at 500.The line is 3 km long.If the full-load\n", + "#current is 120 A,what must be the booster voltage and output in order that the far end voltage may also be 500 V.\n", + "#Take the resistance of the cable at the working temperature as 0.5ohm/kilometre.\n", + "####################################################################################################################\n", + "\n", + "#Total resistance of line\n", + "res_tot = 0.5*3 #ohm\n", + "#Full load current\n", + "cur_full = 120.0 #A\n", + "\n", + "#drop in the line-> V=IR\n", + "drop = res_tot*cur_full #V\n", + "\n", + "#Output of booster ->VI = W\n", + "output = drop*cur_full/1000 #kW\n", + "\n", + "print \"Terminal potential difference of the booster is = \",drop,\"V.\"\n", + "print \"Output of booster is = \",round(output,2),\"kW.\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.11" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ShantanuBhosale/chapter40.ipynb b/sample_notebooks/ShantanuBhosale/chapter40.ipynb deleted file mode 100755 index e297a2c2..00000000 --- a/sample_notebooks/ShantanuBhosale/chapter40.ipynb +++ /dev/null @@ -1,1989 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# CHAPTER 40: D.C TRANSMISSION AND DISTRIBUTION\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.1 ,Page No :- 1574" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "percentage saving in copper is = 50.0 %.\n" - ] - } - ], - "source": [ - "#A DC 2-wire feeder supplies a constant load with a sending-end voltage of 220V.Calculate the saving in copper\n", - "#if this voltage is doubled with power transmitted remaining the same.\n", - "##################################################################################################################\n", - "\n", - "\n", - "\n", - "#Given\n", - "V1 = 220.0\n", - "V2 = 440.0\n", - "##Let us assume the wire has##\n", - "#length -> length \n", - "#area -> area\n", - "#current density -> cd\n", - "#power -> P\n", - "P = 10000.0 #assumption\n", - "length = 1000.0 #assumption \n", - "cd = 5.0 #assumption\n", - "#The values are assumed as these terms cancel out while calculating percentage.\n", - "I1 = P/V1\n", - "area = I1/cd\n", - "#Vol of Cu required for 220V ->vol1\n", - "vol1 = 2*area*length\n", - "\n", - "\n", - "I2 = P/V2\n", - "area = I2/cd\n", - "#Vol of Cu required for 440V ->vol2\n", - "vol2 = 2*area*length\n", - "\n", - "#percentage saving of copper is\n", - "per_cent = ((vol1-vol2)/vol1)*100\n", - "print 'percentage saving in copper is ',per_cent,'%.'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.2 ,Page No :- 1577" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum voltage drop from one end is = 12.0 V.\n", - "Maximum voltage drop from both end is = 3.0 V.\n" - ] - } - ], - "source": [ - "#A uniform 2-wire d.c distributor 200 metres long is loaded with 2 amperes/metre.Resistance of\n", - "#single wire is 0.3 ohm/kilometre.Calculate the maximum voltage drop if the distributor is fed\n", - "#(a)from one end (b)from both ends with equal voltages.\n", - "#################################################################################################\n", - "\n", - "#Given\n", - "length = 200.0 #metres\n", - "#current per unit length is\n", - "cur = 2.0 #amp/metre\n", - "#resistance per unit length is\n", - "res = 0.3/1000 #ohm/metre\n", - "\n", - "#total resistance is\n", - "R = res*length #ohm\n", - "#total current is\n", - "I = cur*length #amp\n", - "#Total drop over a distributor fed from one end is given by\n", - "drop1 = (1/2.0)*I*R #volts\n", - "#Total drop over a distributor fed from both ends is given by\n", - "drop2 = (1/8.0)*I*R\n", - "print 'Maximum voltage drop from one end is = ',drop1,'V.'\n", - "print 'Maximum voltage drop from both end is = ',drop2,'V.'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.3 ,Page No :- 1577" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Cross sectional area of distributor = 116.412 cm^2\n" - ] - } - ], - "source": [ - "#A 2-wire d.c distributor AB is 300 metres long.It is fed at point A.The various loads and\n", - "#their positions are given below.\n", - "# At point distance from A in metres concentrated load in A\n", - "# C 40 30\n", - "# D 100 40 \n", - "# E 150 100\n", - "# F 250 50\n", - "#If the maximum permissible voltage drop is not to exceed 10V,find the cross-sectional\n", - "#area of the distributor.Take resistivity = 1.78*10^(-8) ohm-m.\n", - "###########################################################################################\n", - "\n", - "\n", - "#Given\n", - "resistivity = 1.78e-8 #ohm-m\n", - "drop_max = 10.0 #V\n", - "#loads and their positions\n", - "I1 = 30.0 #A\n", - "l1 = 40.0 #m\n", - "I2 = 40.0 #A\n", - "l2 = 100.0 #m\n", - "I3 = 100.0 #A\n", - "l3 = 150.0 #m\n", - "I4 = 50 #A\n", - "l4 = 250 #m\n", - "#We know that R = resistivity*length/Area\n", - "#Also max drop = I1*R1 + I2*R2 + I3*R3 + I4*R4 , using this\n", - "area = 2*(I1*l1 + I2*l2 + I3*l3 + I4*l4)*resistivity/drop_max #m^2\n", - "area = area*1000000 #cm^2 \n", - "print 'Cross sectional area of distributor =',area,'cm^2'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.4 ,Page No :- 1578" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Hence drop at minimum potential where load is 70 A is = 48.4 V.\n" - ] - } - ], - "source": [ - "#A 2-wire d.c distributor F1F2 1000 metres long is loaded as under:\n", - "#Distance from F1(in metres): 100 250 500 600 700 800 850 920\n", - "#Load in amperes: 20 80 50 70 40 30 10 15\n", - "#The feeding points F1 and F2 are maintained at the same potential.Find which point will have the\n", - "#minimum potential and what will be the drop at this point?Take the cross-section of the conductors\n", - "#as 0.35 cm^2 and specific resistance of copper as 1.764*10^(-6) ohm-cm\n", - "#####################################################################################################\n", - "\n", - "#Given\n", - "import numpy as np\n", - "resistivity = 1.764e-8 #ohm-m\n", - "area = 0.35e-4 #m^2 \n", - "#loads and their positions taking from F1\n", - "I1 = 20 #A\n", - "l1 = 100 #m\n", - "I2 = 80 #A\n", - "l2 = 150 #m\n", - "I3 = 50 #A\n", - "l3 = 250 #m\n", - "I4 = 70 #A\n", - "l4 = 100 #m\n", - "I5 = 40 #A\n", - "l5 = 100 #m\n", - "I6 = 30 #A\n", - "l6 = 50 #m\n", - "I7 = 10 #A\n", - "l7 = 70 #m\n", - "I8 = 15 #A\n", - "l8 = 80 #m \n", - "\n", - "#sum of loads from F1\n", - "load1 = I1*l1 + I2*(l1+l2) + I3*(l1+l2+l3) #A-m\n", - "load2 = I8*l8 + I7*(l7+l8) + I6*(l6+l7+l8) + I5*(l5+l6+l7+l8) #A-m\n", - "\n", - "#guessing the point of minimum potential\n", - "if load1>load2:\n", - " load2_new = load2 + I4*(l4+l5+l6+l7+l8)\n", - " if load2_new>load1:\n", - " pivot = I4\n", - "\n", - "#solving 2 equations simultaneously\n", - "# x + y = 70(pivot) & 47000(load1) + 600(l1+l2+l3)x = 20,700(load2) + 400(l5+l6+l7+l8)y)\n", - "line1 = l1+l2+l3+l4 #m\n", - "line2 = l4+l5+l6+l7+l8 #m \n", - "\n", - "a = [[1,1],[line1,-line2]]\n", - "b = [pivot,load2-load1]\n", - "soln = np.linalg.solve(a,b) #soln is array with its elements[x,y]\n", - "#drop at minimum potential per conductor (in A-m)\n", - "drop_m = load1 + soln[0]*line1 #A-m\n", - "\n", - "#resistance per metre = resistivity/Area\n", - "res = resistivity/area #ohm/m\n", - "\n", - "#Hence, drop in voltage per conductor is\n", - "drop = drop_m*res #V \n", - "#drop due to both is\n", - "drop = drop*2 #V\n", - "\n", - "print 'Hence drop at minimum potential where load is',pivot,'A is =',round(drop,2),'V.'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.5 ,Page No :- 1579" - ] - }, - { - "cell_type": "code", - "execution_count": 33, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The current entering at A is = 88.6 A \n", - "The current entering at B is = 211.4 A.\n" - ] - } - ], - "source": [ - "#The resistance of a cable is 0.1ohm per 1000 metre for both conductors.It is loaded as shown in Fig.40.14(a).\n", - "#Find the current supplied at A and at B.If both the ends are supplied at 200 V\n", - "##############################################################################################################\n", - "\n", - "#Given\n", - "#resistance per metre\n", - "res = 0.1/1000 #ohm/m\n", - "#loads and their positions taking from A\n", - "I1 = 50.0 #A\n", - "l1 = 500.0 #m\n", - "I2 = 100.0 #A\n", - "l2 = 700.0 #m\n", - "I3 = 150.0 #A\n", - "l3 = 300.0 #m\n", - "l4 = 250.0 #m \n", - "\n", - "#Assuming I flows from A to B\n", - "# equation is res*[500*i + 700(i-50) + 300(i-150) + 250(i-300)] = 0\n", - "current_i = (I1*l2+(I1+I2)*l3 + (I1+I2+I3)*l4)/(l1+l2+l3+l4)\n", - "current_AC = current_i\n", - "current_CD = current_i-I1\n", - "current_DE = current_CD-I2\n", - "current_EB = current_DE-I3\n", - "if current_EB<0:\n", - " current_EB = -current_EB;\n", - "print 'The current entering at A is = ',round(current_i,1),'A '\n", - "print 'The current entering at B is = ',round(current_EB,1),'A.' " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.6 ,Page No :- 1580" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current supplied at A is = 88.6 A.\n", - "Current supplied at B is = -211.4 A.\n", - "Current in AC is = 88.6 A.\n", - "Current in CD is = 38.6 A.\n", - "Current in DE is = -61.4 A.\n", - "Current in EB is = -211.4 A.\n", - "Drop over AC is = 4.4 V.\n", - "Drop over CD is = 2.7 V.\n", - "Drop over DE is = -1.8 V.\n", - "Voltage at C is = 195.6 V.\n", - "Voltage at D is = 192.9 V.\n", - "Voltage at E is = 194.7 V.\n" - ] - } - ], - "source": [ - "#The resistance of two conductors of a 2-conductor distributor shown in Fig.39.15 is 0.1ohm per 1000m\n", - "#for both conductors.Find (a)the current supplied at A(b)the current supplied at B\n", - "#(c)the current in each section (d)the voltages at C,D and E.Both A and B are maintained at 200V.\n", - "######################################################################################################\n", - "\n", - "#Given\n", - "#resistance per metre\n", - "res = 0.1/1000 #ohm/m\n", - "#loads and their positions taking from A\n", - "I1 = 50.0 #A\n", - "l1 = 500.0 #m\n", - "I2 = 100.0 #A\n", - "l2 = 700.0 #m\n", - "I3 = 150.0 #A\n", - "l3 = 300.0 #m\n", - "l4 = 250.0 #m \n", - "\n", - "#Assuming I flows from A to B\n", - "# equation is res*[500*i + 700(i-50) + 300(i-150) + 250(i-300)] = 0\n", - "current_i = (I1*l2+(I1+I2)*l3 + (I1+I2+I3)*l4)/(l1+l2+l3+l4)\n", - "current_AC = current_i\n", - "current_CD = current_i-I1\n", - "current_DE = current_CD-I2\n", - "current_EB = current_DE-I3\n", - "print \"Current supplied at A is = \",round(current_i,1),\"A.\"\n", - "print \"Current supplied at B is = \",round(current_EB,1),\"A.\"\n", - "print \"Current in AC is = \",round(current_i,1),\"A.\"\n", - "print \"Current in CD is = \",round(current_CD,1),\"A.\"\n", - "print \"Current in DE is = \",round(current_DE,1),\"A.\"\n", - "print \"Current in EB is = \",round(current_EB,1),\"A.\"\n", - "#Drop in volts is (resistance/metre)*length*current\n", - "drop_AC = res*l1*current_AC #V\n", - "drop_CD = res*l2*current_CD #V \n", - "drop_DE = res*l3*current_DE #V\n", - "print \"Drop over AC is = \",round(drop_AC,1),\"V.\"\n", - "print \"Drop over CD is = \",round(drop_CD,1),\"V.\"\n", - "print \"Drop over DE is = \",round(drop_DE,1),\"V.\"\n", - "\n", - "#Voltages at C,D,E are\n", - "volt_C = 200-drop_AC #V\n", - "volt_D = volt_C-drop_CD #V\n", - "volt_E = volt_D-drop_DE #V\n", - "print 'Voltage at C is = ',round(volt_C,1),'V.'\n", - "print 'Voltage at D is =',round(volt_D,1),'V.'\n", - "print 'Voltage at E is = ',round(volt_E,1),'V.'\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.7 ,Page No :- 1581" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Therefore point of minimum potential is D and minimum potential is = 246.0 V.\n" - ] - } - ], - "source": [ - "#A 200 m long distributor is fed from both ends A and B at the same voltage of 250V.The\n", - "#concentrated loads of 50,40,30 and 25 A are coming on the distributor at distances of 50,75,\n", - "#100 and 150 m respectively from end A.Determine the minimum potential and locate its positions.\n", - "#Also,determine the current in each section of the distributor.It is given that the resistance\n", - "#of the distributor is 0.08ohm per 100 metres for go and return.\n", - "##################################################################################################\n", - "\n", - "\n", - "#Given\n", - "#resistance per metre\n", - "res = 0.08/100 #ohm/m\n", - "V_A = 250.0 #V\n", - "V_B = 250.0 #V\n", - "#load currents and their positions\n", - "I_C = 50.0 #A\n", - "I_D = 40.0 #A\n", - "I_E = 30.0 #A\n", - "I_F = 25.0 #A\n", - "l_AC = 50.0 #m\n", - "l_CD = 75.0 - l_AC #m\n", - "l_DE = 100.0 - l_CD - l_AC #m\n", - "l_EF = 150.0 - l_DE - l_CD - l_AC #m\n", - "l_FB = 200.0-150.0\n", - "#Assuming I flows from A to B\n", - "# equation is res*[50*i + 25(i-50) + 25(i-90) + 50(i-120)+50(i-145)] = 0\n", - "current_i = (l_CD*I_C + l_DE*(I_C+I_D)+l_EF*(I_C+I_D+I_E) + l_FB*(I_C+I_D+I_E+I_F))/200.0\n", - "current_AC = current_i\n", - "current_CD = current_i-I_C\n", - "current_DE = current_CD-I_D\n", - "current_EF = current_DE-I_E\n", - "current_FB = current_EF-I_F\n", - "#As from figure in the book , point D is at minimum potential\n", - "if (current_CD>0) & (current_DE<0):\n", - " point = \"D\"\n", - " \n", - "#drop in volts = resistance/metre*sum(length*current) \n", - "drop_d = res*(l_AC*current_AC + l_CD*current_CD)\n", - "min_pot = V_A-drop_d\n", - "print \"Therefore point of minimum potential is\",point,\"and minimum potential is = \",round(min_pot,1),\"V.\" " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.8 ,Page No :- 1582" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage at point C is = 250.13 V.\n", - "Voltage at point D is = 247.73 V.\n" - ] - } - ], - "source": [ - "#Each conductor of a 2-core distributor,500 metres long has a cross-sectional area\n", - "#of 2 cm^2.The feeding point A is supplied at 255V and the feeding point B at\n", - "#250V and load currents of 120A and 160A are taken at points C and D which are\n", - "#150 metres and 350 metres respectively from the feeding point A.Calculate the\n", - "#voltage at each load.Specific Resistance of copper is 1.7*10^(-6) ohm-cm\n", - "##################################################################################\n", - "\n", - "#Given\n", - "area = 2e-4 #m^2\n", - "resistivity = 1.7e-8 #ohm-m\n", - "#load currents and their positions\n", - "i_c = 120.0 #A\n", - "i_d = 160.0 #A\n", - "l_ac = 150.0 #m\n", - "l_cd = 200.0 #m\n", - "l_db = 150.0 #m\n", - "V_a = 255.0 #V\n", - "V_b = 250.0 #V\n", - "#Resistance = resistivity*length/Area\n", - "#It is a 2 core distributor.Therefore,resistance per metre is\n", - "res = 2*resistivity/area #ohm/m\n", - "#drop over whole distributor is equal to\n", - "drop = V_a - V_b #V\n", - "#Therefore equation of total drop can be written as\n", - "# resistivity*(150i+200(i-120)+150(i-280))=5\n", - "current_i = (drop/res + l_cd*i_c + l_db*(i_c+i_d))/(l_ac+l_cd+l_db) #A\n", - "current_ac = current_i #A\n", - "current_cd = current_ac-i_c #A\n", - "current_db = current_cd-i_d #A\n", - "\n", - "#Voltage at C = 255-drop over AC\n", - "volt_c = V_a-res*l_ac*current_ac #V\n", - "#Voltage at D = 250-drop over DB \n", - "volt_d = V_b -res*l_db*abs(current_db) #V\n", - "print \"Voltage at point C is = \",round(volt_c,2),\"V.\"\n", - "print \"Voltage at point D is = \",round(volt_d,2),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.9 ,Page No :- 1583" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Volatge at point Q is = 225.25 V.\n", - "Voltage at point B is = 236.56 V.\n" - ] - } - ], - "source": [ - "#A 2-wire distributor 500 metres long is fed at P at 250V and loads of 40A,20A,60A,30A are tapped off\n", - "#off from points A,B,C and D which are at distances of 100 metres,150 metres,300 metres and 400 metres\n", - "#from P respectively.The distributor is also uniformly loaded at the rate of 0.1A/m.If the resistance of\n", - "#the distributor per metre(go and return) is 0.0005 ohm,calculate the voltage at(i)pointQ and(ii)point B.\n", - "###########################################################################################################\n", - "\n", - "#Given\n", - "V_P = 250.0 #V\n", - "resistance = 0.0005 #ohm/m\n", - "\n", - "#loads and their positions\n", - "i_a = 40.0 #A\n", - "i_b = 20.0 #A\n", - "i_c = 60.0 #A\n", - "i_d = 30.0 #A\n", - "l_pa = 100.0 #m\n", - "l_ab = 150.0-100.0 #m\n", - "l_bc = 300.0-150.0 #m\n", - "l_cd = 400.0-300.0 #m\n", - "#uniform dstributed load\n", - "cur_uni = 0.1 #A/m\n", - "\n", - "\n", - "#considering drop due to concentrated loading\n", - "drop_pa = (i_a+i_b+i_c+i_d)*l_pa*resistance #V\n", - "drop_ab = (i_b+i_c+i_d)*l_ab*resistance #V \n", - "drop_bc = (i_c+i_d)*l_bc*resistance #V\n", - "drop_cd = i_d*l_cd*resistance #V\n", - "tot_drop = drop_pa + drop_ab + drop_bc + drop_cd #V\n", - "\n", - "#considering drop due to uniform loading(drop = irl^2/2) l = 500m\n", - "drop_uni = cur_uni*resistance*(500.0*500.0)/2 #V\n", - "\n", - "V_Q = V_P - (tot_drop + drop_uni) #V\n", - "#for point B\n", - "#drop due to concentrated loading\n", - "drop_b = drop_pa + drop_ab #V\n", - "#drop due to uniform loading (drop = ir(lx-x^2/2)) l=500m x=150m\n", - "drop_ub = cur_uni*resistance*(500*(l_pa+l_ab)-(l_pa+l_ab)*(l_pa+l_ab)/2) #V\n", - "\n", - "V_B = V_P - (drop_b + drop_ub) #V\n", - "\n", - "print \"Volatge at point Q is = \",round(V_Q,2),\"V.\"\n", - "print \"Voltage at point B is = \",round(V_B,2),\"V.\" " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.10 ,Page No :- 1583" - ] - }, - { - "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current in section AC is = 53.75 A.\n", - "Current in section CD is = 33.75 A.\n", - "Current in section DE is = -6.25 A.\n", - "Current in section EF is = -31.25 A.\n", - "Current in section FB is = -61.25 A.\n", - "Minimum voltage is at point D and minimum voltage is = 233.18 V.\n" - ] - } - ], - "source": [ - "#A distributor AB is fed from both ends.At feeding point A,the voltage is maintained at 236V and at B at 237V.\n", - "#The total length of the distributor is 200 metres and loads are tapped off as under:\n", - "#(i) 20A at 50 metres from A (ii) 40A at 75 metres from A. (iii)25A at 100 metres from A (iv)30A at 150 metres from A\n", - "#The reistance per kilometre of one conductor is 0.4ohm.Calculate the currents in the various sections of the distributor,\n", - "#the minimum voltage and the point at which it occurs.\n", - "###########################################################################################################################\n", - "\n", - "\n", - "#Given\n", - "#resistance per metre\n", - "res = 2*0.4/1000 #ohm/m\n", - "V_a = 236.0 #V\n", - "V_b = 237.0 #V\n", - "#loads and their positions\n", - "i_c = 20.0 #A\n", - "i_d = 40.0 #A\n", - "i_e = 25.0 #A\n", - "i_f = 30.0 #A\n", - "l_ac = 50.0 #m\n", - "l_cd = 25.0 #m\n", - "l_de = 25.0 #m\n", - "l_ef = 50.0 #m\n", - "l_fb = 50.0 #m\n", - "#Voltage drop equation res*(50i + 25(i-20)+25(i-60) + 50(i-85) + 50(i-115)=-1)\n", - "current_i = ((V_a-V_b)/res + l_cd*(i_c)+l_de*(i_c+i_d)+l_ef*(i_c+i_d+i_e)+l_fb*(i_c+i_d+i_e+i_f))/200.0\n", - "current_ac = current_i\n", - "current_cd = current_ac-i_c\n", - "current_de = current_cd-i_d\n", - "current_ef = current_de-i_e\n", - "current_fb= current_ef-i_f\n", - "if current_cd>0:\n", - " if current_de<0:\n", - " point = \"D\"\n", - "#Minimum potential is at D as shown in figure\n", - "drop = res*(current_ac*l_ac + current_cd*l_cd)\n", - "V_d = V_a-drop\n", - "print \"Current in section AC is = \",round(current_ac,2),\"A.\"\n", - "print \"Current in section CD is = \",round(current_cd,2),\"A.\"\n", - "print \"Current in section DE is = \",round(current_de,2),\"A.\"\n", - "print \"Current in section EF is = \",round(current_ef,2),\"A.\"\n", - "print \"Current in section FB is = \",round(current_fb,2),\"A.\"\n", - "print \"Minimum voltage is at point\",point,\"and minimum voltage is = \",round(V_d,2),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.11 ,Page No :- 1584" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current supplied by feeder at point A is 46.29 A and that by point B is 109.71 A.\n", - "Voltage at point B is = 240.55 V.\n", - "Voltage at point C is = 239.63 V.\n", - "Voltage at point D is = 239.42 V.\n", - "Voltage at point E is = 239.38 V.\n" - ] - } - ], - "source": [ - "#A distributor cable AB is fed at its ends A and B.Loads of 12,24,72 and 48 A are taken from the cable at\n", - "#points C,D,E and F.The resistances of sections AC,CD,DE,EF and FB of the cable are 8,6,4,10 and 5 milliohm\n", - "#respecively(for the go and return conductors together). The potential difference at point A is 240V,the p.d\n", - "#at the load F is also to be 240V.Calculate the voltages at the feeding point B,the current supplied by each\n", - "#feeder and the p.d.s at the loads C,D and E.\n", - "##############################################################################################################\n", - "\n", - "#Given\n", - "V_a = 240.0 #V \n", - "V_f = 240.0 #V\n", - "#loads and their resistances.\n", - "i_c = 12.0 #A\n", - "i_d = 24.0 #A\n", - "i_e = 72.0 #A\n", - "i_f = 48.0 #A\n", - "\n", - "r_ac = 8e-3 #ohm\n", - "r_cd = 6e-3 #ohm\n", - "r_de = 4e-3 #ohm\n", - "r_ef = 10e-3 #ohm\n", - "r_fb = 5e-3 #ohm\n", - "\n", - "#Voltage drop accross AF is zero.Therefore equation 8i +6(i-12) + 4(i-36)+10(i-108)*10^(-3)\n", - "current_i = (r_cd*i_c + r_de*(i_c+i_d) + r_ef*(i_c+i_d+i_e))/(28.0e-3) #A\n", - "#currents in different sections\n", - "current_ac = current_i #A\n", - "current_cd= current_ac-i_c #A\n", - "current_de = current_cd-i_d #A\n", - "current_ef = current_de-i_e #A \n", - "current_fb = current_ef-i_f #A\n", - "#voltage at different points are\n", - "V_b = V_f - current_fb*r_fb #V\n", - "V_c = V_a - current_ac*r_ac #V\n", - "V_d = V_c - current_cd*r_cd #V\n", - "V_e = V_d - current_de*r_de #V \n", - "\n", - "print \"Current supplied by feeder at point A is\",round(current_ac,2),\"A and that by point B is\",round(abs(current_fb),2),\"A.\"\n", - "print \"Voltage at point B is = \",round(V_b,2),\"V.\"\n", - "print \"Voltage at point C is = \",round(V_c,2),\"V.\"\n", - "print \"Voltage at point D is = \",round(V_d,2),\"V.\"\n", - "print \"Voltage at point E is = \",round(V_e,2),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.12 ,Page No :- 1585" - ] - }, - { - "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The current supplied at P is = 143.75 A.\n", - "The current supplied at Q is = 116.25 A.\n", - "Power dissipated in distributor is = 847.34 W.\n" - ] - } - ], - "source": [ - "#A two-wire d.c sdistributor PQ,800 metre long is loaded as under:\n", - "#Distance from P(metres): 100 250 500 600 700\n", - "#Loads in amperes: 20 80 50 70 40\n", - "#The feeding point at P is maintained at 248V and that at Q at 245V.The total resistance of\n", - "#the distributor(lead and return) is 0.1 ohm.Find (a)the current supplied at P and Q and\n", - "#(b)the power dissipated in the distributor.\n", - "##################################################################################################\n", - "\n", - "#Given\n", - "V_p = 248.0 #V\n", - "V_q = 245.0 #V\n", - "res = 0.1/800 #ohm/m \n", - "#loads and their positions\n", - "i1 = 20.0 #A\n", - "i2 = 80.0 #A\n", - "i3 = 50.0 #A\n", - "i4 = 70.0 #A\n", - "i5 = 40.0 #A\n", - "l1 = 100.0 #m\n", - "l2 = 250.0-100.0 #m\n", - "l3 = 500.0 -250.0 #m\n", - "l4 = 600.0-500.0 #m\n", - "l5 = 700.0-600.0 #m\n", - "l6 = 800.0-700.0 #m\n", - "#drop accross the distributor :- 1/8000(100i + 150(i-20) + 250(i-100)+ 100(i-150)+100(i-220)+100(i-260) )=3\n", - "current_i = ((V_p-V_q)/res + l2*i1+l3*(i1+i2)+l4*(i1+i2+i3)+l5*(i1+i2+i3+i4)+l6*(i1+i2+i3+i4+i5))/800.0\n", - "current_p = current_i #A\n", - "current_2 = current_p-i1 #A\n", - "current_3 = current_2-i2 #A\n", - "current_4 = current_3-i3 #A\n", - "current_5 = current_4-i4 #A\n", - "current_q = current_5-i5 #A\n", - "#Power loss = sum(I^2R)\n", - "loss = res*(current_p*current_p*l1 + current_2*current_2*l2 + current_3*current_3*l3 + current_4*current_4*l4 + current_5*current_5*l5 + current_q*current_q*l6)\n", - "print \"The current supplied at P is = \",round(current_p,2),\"A.\"\n", - "print \"The current supplied at Q is = \",round(abs(current_q),2),\"A.\"\n", - "print \"Power dissipated in distributor is =\",round(loss,2),\"W.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.13 ,Page No :- 1586" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The point of minimum potential is D and minimum potential is = 231.76 V.\n", - "Current fed at the end A is = 366.0 A.\n", - "Current fed at the end B is = 454.0 A.\n" - ] - } - ], - "source": [ - "#The two conductors of a d.c distributor cable 1000m long have a total resistance of 0.1 ohm.\n", - "#The ends A and B are fed at 240V.The cable is uniformly loaded at 0.5 A per metre length\n", - "#and has concentrated loads of 120A,60A,100A and 40A at points distant 200,400,700 and 900m.\n", - "#respectively from the end A.Calculate (i)the point of minimum potential on the distributor\n", - "#(ii)the value of minimum potential and (iii) currents fed at the ends A and B.\n", - "###############################################################################################\n", - "\n", - "#Given\n", - "V_a = 240.0 #V\n", - "V_b = 240.0 #V\n", - "res = 0.1/1000 #ohm/m\n", - "#concentrated loads and their positions\n", - "i_c = 120.0 #A\n", - "i_d = 60.0 #A\n", - "i_e = 100.0 #A\n", - "i_f = 40.0 #A\n", - "l_ac = 200.0 #m\n", - "l_cd = 400.0-200.0 #m\n", - "l_de = 700.0-400.0 #m\n", - "l_ef = 900.0-700.0 #m\n", - "l_fb = 1000.0-900.0 #m\n", - "#Uniform loading\n", - "cur_uni = 0.5 #A/m\n", - "#Equation for drop from A to B -> (1/10000)*(200i + 200(i-120)+ 300(i-180)+200(i-280)+100(i-320))=0\n", - "current_i = (l_cd*i_c + l_de*(i_c+i_d)+l_ef*(i_c+i_d+i_e)+l_fb*(i_c+i_d+i_e+i_f))/1000\n", - "\n", - "#point of minimum potential\n", - "current_ac = current_i #A\n", - "current_cd = current_ac-i_c #A\n", - "current_de = current_cd-i_d #A\n", - "current_ef = current_de-i_e #A\n", - "current_fb = current_ef-i_f #A\n", - "\n", - "if current_cd>0:\n", - " if current_de<0:\n", - " point = \"D\"\n", - "#As from figure it is inferred that point of minimum potential is D.\n", - "#Therefore,uniform load from point A to D(supplied from A)\n", - "cur_uni_A = cur_uni*(l_ac + l_cd) #A\n", - "cur_A = cur_uni_A + current_ac #A\n", - "#Therefore,uniform load from point B to D(supplied from B)\n", - "cur_uni_B = cur_uni*(l_de + l_ef + l_fb) #A\n", - "cur_B = cur_uni_B + abs(current_fb) #A\n", - "\n", - "#drop at D due to concentrated load(from A)\n", - "drop_con = res*(current_ac*l_ac + current_cd*l_cd)\n", - "#drop at D due to uniform load(from A)[formula-> irl^2/2]\n", - "drop_uni = cur_uni*res*(l_ac+l_cd)*(l_ac+l_cd)/2\n", - "#total drop is\n", - "drop_tot = drop_con + drop_uni\n", - "\n", - "#potential at D is\n", - "V_d = V_a - drop_tot\n", - "print \"The point of minimum potential is\",point,\"and minimum potential is = \",round(V_d,2),\"V.\"\n", - "print \"Current fed at the end A is = \",round(cur_A,2),\"A.\"\n", - "print \"Current fed at the end B is = \",round(cur_B,2),\"A.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.14 ,Page No :- 1587" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage V is = 8.62 V.\n", - "Cross-sectional Area A is = 2.78 cm^2.\n", - "Cross-sectional Area A1 is = 0.26 cm^2.\n", - "Cross-sectional Area A2 is = 2.24 cm^2.\n" - ] - } - ], - "source": [ - "#It is proposed to lay out a d.c distribution system comprising three sections-the first section consists\n", - "#of a cable from the sub-station to a point distant 800 metres from which two cables are taken,one 350 metres\n", - "#long supplying a load of 22kW and the other 1.5 kilometre long and supplying a load of 44kW.Calculate the\n", - "#cross-sectional area of each cable so that the total weight of copper required shall be minimum if the maximum\n", - "#drop of voltage along the cable is not to exceed 5% of the normal voltage of 440V at the consumer's premises.\n", - "#Take specific resistance of copper at working temperature equal to 2*10e-7 ohm-cm.\n", - "###################################################################################################################\n", - "\n", - "#Given\n", - "resistivity = 2*10e-7 #ohm-cm\n", - "dist = 800.0*100 #cm\n", - "#Current taken from 350m section\n", - "cur_1 = 22000.0/440\n", - "#Current taken from 1.5km section\n", - "cur_2 = 44000.0/440\n", - "#Therefore,current in first section\n", - "cur = cur_1 + cur_2\n", - "#Let us assume\n", - "#V->voltage drop accross first section\n", - "#R->resistance of the first section\n", - "#A->cross-sectional area of te first section\n", - "\n", - "from sympy import Eq, var, solve\n", - "var('V') \n", - "#Now , R = V/I\n", - "R = V/cur\n", - "# A = resistivity*l/R -> A = resistivity*l*I/V \n", - "A = resistivity*dist/R\n", - "#Max allowable drop\n", - "max_drop = (5.0/100)*440.0\n", - "#Voltage drop along other sections\n", - "vol_drop = max_drop - V\n", - "#Cross-sectional area of 350 m A = resistivity*l/R \n", - "A1 = resistivity*350.0*100*cur_1/(vol_drop)\n", - "#Cross-sectional area of 1.5km A = resistivity*l/R \n", - "A2 = resistivity*1500.0*100*cur_2/(vol_drop)\n", - "\n", - "\n", - "#Now,Total weight is propotional to total volume \n", - "W = 800.0*A + 350.0*A1+1500.0*A2\n", - "Diff = W.diff(V)\n", - "eq = Eq(Diff,0)\n", - "\n", - "V = solve(eq)\n", - "#We get 2 values of V of which Negative is not possible.Therefore,\n", - "V = float(V[1])\n", - "A = resistivity*dist*cur/V\n", - "vol_drop = max_drop - V\n", - "A1 = resistivity*350.0*100*cur_1/vol_drop\n", - "A2 = resistivity*1500.0*100*cur_2/vol_drop\n", - "print \"Voltage V is = \",round(V,2),\"V.\"\n", - "print \"Cross-sectional Area A is = \",round(A,2),\"cm^2.\"\n", - "print \"Cross-sectional Area A1 is = \",round(A1,2),\"cm^2.\"\n", - "print \"Cross-sectional Area A2 is = \",round(A2,2),\"cm^2.\"\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.15 ,,Page No :- 1588" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The point of minimum potential is at 261.74 m from A.\n", - "The minimum potential is = 247.34 V.\n" - ] - } - ], - "source": [ - "#A d.c two-wire distributor AB is 450m long and is fed at both ends at 250 volts.It is loaded as follows:20A at 60m from A,\n", - "#40A at 100m from A and a uniform loading of 1.5A/m from 200 to 450m from A.The resistance of each conductor is\n", - "#0.05ohm/km.Find the point of minimum potential and its potential.\n", - "####################################################################################################################\n", - "\n", - "#Given\n", - "V_a = 250.0 #V\n", - "V_b = 250.0 #V\n", - "res = 0.05/1000 #ohm/m\n", - "cur_uni = 1.5 #A/m (uniform loading)\n", - "#loads and positions\n", - "i_c = 20.0 #A\n", - "i_d = 40.0 #A\n", - "l_ac = 60.0 #m\n", - "l_cd = 40.0 #m\n", - "l_de = 100.0 #m\n", - "l_eb = 250.0 #m\n", - "\n", - "#Let us assume that point of minimum potential is D and let i be current in section CD.\n", - "#Therefore,current from B is (40-i).If r is resistance then\n", - "#(20+i)*60r + i*40r = (40-i)*350r + 1.5*r*250^2/2 [drop over AD = drop over BD as V_a = V_b]\n", - "\n", - "cur_i = (i_d*(l_de+l_eb)*res + cur_uni*res*l_eb*l_eb/2 - i_c*l_ac*res)/((l_ac+l_cd+l_de+l_eb)*res) #A\n", - "\n", - "#cur_i > 40 i.e 40-i is negative,it means D is not point of minimum potential.Let F be point of minimum potential(between DB)\n", - "#current in section DF is\n", - "cur_df = cur_i-i_d #A\n", - "\n", - "#distance EF\n", - "dist_ef = cur_df/cur_uni #m\n", - "\n", - "#distance of F from A is\n", - "dist = l_ac + l_cd + l_de + dist_ef #m\n", - "\n", - "#total drop over AF is [(20+i)*60r + i*40r+ (i-40)*161.7r - 1.5*r*61.7^2/2\n", - "drop_af = 2*res*((i_c+cur_i)*l_ac + cur_i*l_cd + cur_df*(l_de+dist_ef)-cur_uni*dist_ef*dist_ef/2) #V\n", - "#potential at F\n", - "V_f = V_a - drop_af #V\n", - "print \"The point of minimum potential is at\",round(dist,2),\"m from A.\"\n", - "print \"The minimum potential is = \",round(V_f,2),\"V.\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.16 ,Page No :- 1588" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current fed at A is = 225.0 A.\n", - "Current fed at B is = 475.0 A.\n", - "Point of minimum potential from B is = 475.0 metres.\n", - "Voltage at minimum potential is = 230.72 V.\n" - ] - } - ], - "source": [ - "#A two-wire d.c distributor AB,1000 metres long,is supplied from both ends,240V at A and 242V at B.There is a\n", - "#concentrated load of 200A at a distance of 400 metre from A and a uniformly distrubuted load of 1.0A/m between\n", - "#the mid-point and end B.Determine (i)the currents fed at A and B(ii)the point of minimum potential and\n", - "#(iii)voltage at this point.Take cable resistance as 0.005 ohm per 100 metre each core.\n", - "#####################################################################################################################\n", - "\n", - "#Given\n", - "#resistance per 100 metres\n", - "res = 2*0.005/100 #ohm/m\n", - "cur_uni = 1.0 #A/m\n", - "cur_con = 200.0 #A\n", - "len_uni = 500.0\n", - "#Let us assume that Ib current flows from point B.\n", - "#Considering a element dx in BD(500 metres) at a distance of X units(100 m each)\n", - "#voltage drop over dx = (1-100*x)*res*dx\n", - "#voltage drop over BD by integrating is = 0.05*Ib - 12.5\n", - "#voltage drop over DC = (Ib-500)*0.01\n", - "#voltage drop over CA = (Ib-700)*0.01*4\n", - "#total drop over AB = \n", - "tot_drop = 242.0-240.0\n", - "#summation of drops from AC + CD + DB\n", - "from sympy import Eq, var, solve\n", - "var('Ib') \n", - "sum = (Ib-500)*0.01 +(Ib-700)*0.01*4 + 0.05*Ib - 12.5\n", - "\n", - "eq = Eq(sum,tot_drop)\n", - "\n", - "Ib = solve(eq)\n", - "Ib = float(Ib[0])\n", - "#Total current\n", - "cur_tot = len_uni*cur_uni + cur_con\n", - "Ia = cur_tot - Ib #A\n", - "#Current in distributed load\n", - "cur_dis = Ia-cur_con #A\n", - "#point of minimum potential from D is\n", - "distD = cur_dis/cur_uni\n", - "#Therefore distance from B is\n", - "distB = len_uni-distD\n", - "#Therefore voltage drop is\n", - "from scipy.integrate import quad\n", - "\n", - "def integrand(x):\n", - " return (Ib-100*x)*res*100\n", - "\n", - "ans, err = quad(integrand, 0, (distB/100))\n", - "#Therefore potential of M is\n", - "pot_M = 242.0-ans #V\n", - "print \"Current fed at A is = \",Ia,\"A.\"\n", - "print \"Current fed at B is = \",Ib,\"A.\"\n", - "print \"Point of minimum potential from B is = \",distB,\"metres.\"\n", - "print \"Voltage at minimum potential is = \",round(pot_M,2),\"V.\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.17 ,Page No :- 1590" - ] - }, - { - "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage at B is = 236.9 V.\n", - "Voltage at C is = 235.98 V.\n", - "Voltage at D is = 237.45 V.\n" - ] - } - ], - "source": [ - "#A 400-metre ring distributor has loads as shown in Fig. 40.29(a) where distances are in metres.The resistance\n", - "#of each conductor is 0.2 ohm per 1000 metres and the loads tapped off at points B,C,D are as shown.If the\n", - "#distributor is fed at A,find voltages at B,C and D.\n", - "#################################################################################################################\n", - "\n", - "#Given\n", - "\n", - "res = 0.2/1000 #ohm/m\n", - "V_a = 240.0 #V\n", - "#loads and positions\n", - "i_b = 100.0 #A\n", - "i_c = 70.0 #A\n", - "i_d = 50.0 #A\n", - "l_ab = 60.0 #m\n", - "l_bc = 80.0 #m\n", - "l_cd = 90.0 #m\n", - "l_da = 70.0 #m\n", - "\n", - "#total drop ->70i + 90(i-50)+80(i-120)+60(i-220)=0\n", - "cur_i = (l_cd*i_d + l_bc*(i_d+i_c) + l_ab*(i_d+i_c+i_b))/(l_ab+l_bc+l_cd+l_da)\n", - "#drops in different sections\n", - "drop_da = 2*cur_i*l_da*res\n", - "drop_cd = 2*(cur_i-i_d)*l_cd*res\n", - "drop_bc = 2*abs(cur_i-i_d-i_c)*l_bc*res\n", - "drop_ab = 2*abs(cur_i-i_d-i_c-i_b)*l_ab*res\n", - "\n", - "#voltages at different points\n", - "V_d = V_a - drop_da\n", - "V_c = V_d - drop_cd\n", - "V_b = V_a - drop_ab\n", - "print \"Voltage at B is = \",round(V_b,2),\"V.\"\n", - "print \"Voltage at C is = \",round(V_c,2),\"V.\"\n", - "print \"Voltage at D is = \",round(V_d,2),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.18 ,Page No :- 1591" - ] - }, - { - "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage at B is = 394.2 V.\n", - "Voltage at C is = 393.42 V.\n", - "Current in section BC is = 43.33 A.\n" - ] - } - ], - "source": [ - "#In a direct current ring main,a voltage of 400V is maintained at A.At B,500 metres away from A,a load of 150A is taken\n", - "#and at C,300 metres from B,a load of 200A is taken.The distance between A and C is 700 metres.The resistance of each\n", - "#conductor of the mains is 0.03ohm per 1000 metres.Find the voltage at B and C and also find the current in the section BC.\n", - "##############################################################################################################################\n", - "\n", - "#Given\n", - "V_a = 400.0 #V\n", - "res = 0.03/1000 #ohm/m\n", - "#loads and positions\n", - "i_b = 150.0 #A\n", - "i_c = 200.0 #A\n", - "l_ab = 500.0 #m\n", - "l_bc = 300.0 #m\n", - "l_ca = 700.0 #m\n", - "\n", - "#total drop-> 500i + 300(i-150) + 700(i-350) = 0\n", - "cur_i = (l_bc*i_b + l_ca*(i_b+i_c))/(l_ab+l_bc+l_ca)\n", - "#current in different sections\n", - "cur_ab = cur_i\n", - "cur_bc = cur_i-i_b\n", - "cur_ca = abs(cur_bc-i_c)\n", - "#drops in different sections\n", - "drop_ab = 2*cur_ab*l_ab*res\n", - "drop_bc = 2*cur_bc*l_bc*res\n", - "#voltages in different sections\n", - "V_b = V_a-drop_ab\n", - "V_c = V_b-drop_bc\n", - "print \"Voltage at B is = \",round(V_b,2),\"V.\"\n", - "print \"Voltage at C is = \",round(V_c,2),\"V.\"\n", - "print \"Current in section BC is = \",round(cur_bc,2),\"A.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.19 ,Page No :- 1591" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current in AB,BC,CD,DE,EA is 29.04 A, 19.04 A, 0.96 A, 30.96 A, 40.96 A respectively.\n", - "\n", - "Voltage at B,C,D,E is 217.1 V, 216.14 V, 216.15 V, 216.93 V respectively\n", - "\n", - "Current in AB,BC,DE,CE,EA is 27.72 A, 17.72 A, 32.28 A, 9.76 A, 42.28 A respectively.\n", - "\n", - "Voltage at B,C,D,E is 217.23 V, 216.34 V, 216.02 V, 216.83 V respectively\n" - ] - } - ], - "source": [ - "#A d.c ring main ABCDE is fed at point A from a 220-V supply and the resistances(including both lead and return)\n", - "#of the various sections are as follows(in ohms):AB=0.1;BC=0.05;CD=0.01;DE=0.025 and EA=0.075.The main supplies\n", - "#loads of 10A at B; 20A at C; 30A at D and 10A at E.Find the magnitude and direction of the current flowing in each\n", - "#section and the voltage at each load point.\n", - "#If the points C and E are further linked together by a conductor of 0.05 ohm resistance and the output currents\n", - "#from the mains remain unchanged,find the new distribution of the current and voltage in the network.\n", - "#####################################################################################################################\n", - "\n", - "#Given\n", - "\n", - "V_a = 220.0 #V\n", - "#resistances of different sections\n", - "r_ab = 0.1 #ohm\n", - "r_bc = 0.05 #ohm\n", - "r_cd = 0.01 #ohm\n", - "r_de = 0.025 #ohm\n", - "r_ea = 0.075 #ohm\n", - "#loads\n", - "i_b = 10.0 #A\n", - "i_c = 20.0 #A\n", - "i_d = 30.0 #A\n", - "i_e = 10.0 #A\n", - "#total drop -> 0.1i + 0.05(i-10) + 0.01(i-30) + 0.025(i-60) + 0.075(i-70)=0\n", - "cur_i = (r_bc*i_b + r_cd*(i_b+i_c) + r_de*(i_b+i_c+i_d) + r_ea*(i_b+i_c+i_d+i_e))/(r_ab+r_bc+r_cd+r_de+r_ea)\n", - "#current in different sections\n", - "cur_ab = cur_i\n", - "cur_bc = cur_ab-i_b\n", - "cur_cd = cur_bc-i_c\n", - "cur_de = cur_cd-i_d\n", - "cur_ea = cur_de-i_e\n", - "\n", - "#drops in different sections\n", - "drop_ab = cur_ab*r_ab\n", - "drop_bc = cur_bc*r_bc\n", - "drop_de = abs(cur_de)*r_de\n", - "drop_ea = abs(cur_ea)*r_ea\n", - "#voltages at different points\n", - "V_b = V_a - drop_ab\n", - "V_c = V_b - drop_bc\n", - "V_e = V_a - drop_ea\n", - "V_d = V_e - drop_de\n", - "print \"Current in AB,BC,CD,DE,EA is\",round(cur_ab,2),\"A,\",round(cur_bc,2),\"A,\",round(abs(cur_cd),2),\"A,\",round(abs(cur_de),2),\"A,\",round(abs(cur_ea),2),\"A respectively.\" \n", - "print \"\"\n", - "print \"Voltage at B,C,D,E is\",round(V_b,2),\"V,\",round(V_c,2),\"V,\",round(V_d,2),\"V,\",round(V_e,2),\"V respectively\"\n", - "print \"\"\n", - "#part-2\n", - "#Potential difference between end points of interconnector(CE)\n", - "V_ce = V_e-V_c\n", - "#Resistance between CE ,as shown in figure\n", - "r1 = r_ab+r_bc+r_ea\n", - "r2 = r_de + r_cd\n", - "res_ce = r1*r2/(r1+r2)+ 0.05\n", - "\n", - "#Current in interconnector [I = V/R Ohm's Law]\n", - "cur_ce = V_ce/res_ce\n", - "#Current goes from E to C as E is at higher potential.\n", - "\n", - "#The current in other sections will also change.\n", - "#let us assume i1 along ED, voltage round the closed mesh EDC is zero.\n", - "#total drop -> -0.025*i1-0.01*(i1-30)+0.05*9.75 = 0\n", - "\n", - "cur_i1 = (0.05*cur_ce + r_cd*i_d)/(r_cd+r_de)\n", - "\n", - "current_ea = i_e+cur_i1+cur_ce\n", - "current_ab = (i_b+i_c+i_d+i_e)-current_ea\n", - "current_bc = current_ab-i_b\n", - "current_de = current_ea-i_e\n", - "#new drops\n", - "drop_ab = current_ab*r_ab\n", - "drop_bc = current_bc*r_bc\n", - "drop_ea = current_ea*r_ea\n", - "drop_de = current_de*r_de\n", - "\n", - "#new potentials\n", - "V_b = V_a - drop_ab\n", - "V_c = V_b - drop_bc\n", - "V_e = V_a - drop_ea\n", - "V_d = V_e - drop_de\n", - "\n", - "print \"Current in AB,BC,DE,CE,EA is\",round(current_ab,2),\"A,\",round(current_bc,2),\"A,\",round(current_de,2),\"A,\",round(cur_ce,2),\"A,\",round(current_ea,2),\"A respectively.\"\n", - "print \"\"\n", - "print \"Voltage at B,C,D,E is\",round(V_b,2),\"V,\",round(V_c,2),\"V,\",round(V_d,2),\"V,\",round(V_e,2),\"V respectively\" \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.20 ,Page No :- 1594" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage across 3 ohm load is = 244.9 V.\n", - "Voltage across 4 ohm load is = 247.9 V.\n" - ] - } - ], - "source": [ - "#In a 3-wire distribution system,the supply voltage is 250V on each side.The load on one side is a 3 ohm\n", - "#resistance and on the other, a 4 ohm resistance.The resistance of each of the 3 conductors is 0.05 ohm.\n", - "#Find the load voltages.\n", - "#########################################################################################################\n", - "\n", - "import numpy as np\n", - "#Given\n", - "#Resistances\n", - "res_1 = 3.0 #ohm\n", - "res_2 = 4.0 #ohm\n", - "res_con = 0.05 #ohm\n", - "V_sup = 250.0 #V\n", - "\n", - "#Let the assumed directions of unknown currents be as shown in figure.\n", - "#KVL for ABCD\n", - "# (3+0.05)x + 0.05(x-y) = 250 -------------- eqn 1\n", - "a = res_1 + 2*res_con\n", - "b = -(res_con)\n", - "#KVL for DCEFD\n", - "# 0.05(y-x) + (4+0.05)y = 250 -------------- eqn 2\n", - "c = res_2+ 2*res_con \n", - "#Solving eqn 1 and eqn2\n", - "m = [[a,b],[b,c]]\n", - "n = [V_sup,V_sup]\n", - "soln = np.linalg.solve(m,n) #soln is array with its elements[x,y]\n", - "#Calculating the load voltages\n", - "#V1 = 250-0.05*x-0.05(x-y)\n", - "vol1 = V_sup - res_con*soln[0]-res_con*(soln[0]-soln[1]) #V\n", - "#V2 = 250 + 0.05(x-y)- 0.05y\n", - "vol2 = V_sup + res_con*(soln[0]-soln[1]) - res_con*soln[1] #V\n", - "print \"Voltage across 3 ohm load is = \",round(vol1,1),\"V.\"\n", - "print \"Voltage across 4 ohm load is = \",round(vol2,1),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.21 ,Page No :- 1594" - ] - }, - { - "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Potential Difference across AB is = 248.62 V.\n", - "Potential Difference across QK is = 247.83 V.\n", - "Potential Difference across CD is = 248.4 V.\n", - "Potential Difference across FE is = 247.65 V.\n" - ] - } - ], - "source": [ - "#A 3-wire d.c distributor PQ,250 metres long,is supplied at end P at 500/250V and is loaded as under:\n", - "#Positive side: 20A 150 metres from P ; 30A 250 metres from P.\n", - "#Negative side: 24A 100 metres from P ; 36A 220 metres from P.\n", - "#The resistance of each outer wire is 0.02 ohm per 100 metres and the cross-section of the middle wire\n", - "#is one-half of the outer.Find the voltage across each load point.\n", - "##########################################################################################################\n", - "\n", - "#Given\n", - "V_PN = 250.0 #V\n", - "V_NR = 250.0 #V\n", - "res_out = 0.02/100 #ohm/m\n", - "res_mid = 2*res_out #ohm/m (Area of middle wire is half.As, R = rho*l/A .Therefore,Resistance doubles)\n", - "\n", - "#Given Currents\n", - "i_ab = 20.0 #A\n", - "i_qk = 30.0 #A\n", - "i_cd = 24.0 #A\n", - "i_fe = 36.0 #A\n", - "\n", - "#Currents in different sections\n", - "i_pa = i_ab+i_qk #A\n", - "i_aq = i_qk #A\n", - "i_fk = i_qk #A\n", - "i_bf = i_fe-i_qk #A\n", - "i_bc = i_ab-i_bf #A\n", - "i_cn = i_cd-i_bc #A\n", - "i_de = i_fe #A\n", - "i_dr = i_cd+i_fe #A\n", - "\n", - "\n", - "#lengths of different sections\n", - "l_pa = 150.0 #m\n", - "l_aq = 100.0 #m\n", - "l_kf = 250.0-220.0 #m\n", - "l_bc = 150.0-100.0 #m\n", - "l_bf = 220.0-150.0 #m\n", - "l_cn = 100.0 #m\n", - "l_de = 220.0-100.0 #m\n", - "l_dr = 100.0 #m\n", - "\n", - "#Resistances of different sections\n", - "r_pa = l_pa*res_out #ohm\n", - "r_aq = l_aq*res_out #ohm\n", - "r_kf = l_kf*res_mid #ohm\n", - "r_bc = l_bc*res_mid #ohm\n", - "r_bf = l_bf*res_mid #ohm\n", - "r_cn = l_cn*res_mid #ohm\n", - "r_de = l_de*res_out #ohm\n", - "r_dr = l_dr*res_out #ohm\n", - "\n", - "#Drop across different sections\n", - "drop_pa = r_pa*i_pa #V\n", - "drop_aq = r_aq*i_aq #V\n", - "drop_kf = r_kf*i_fk #V\n", - "drop_bc = r_bc*i_bc #V\n", - "drop_bf = r_bf*i_bf #V\n", - "drop_cn = r_cn*i_cn #V\n", - "drop_de = r_de*i_de #V\n", - "drop_dr = r_dr*i_dr #V\n", - "\n", - "#Voltages across different sections\n", - "vol_ab = V_PN - drop_pa - drop_bc + drop_cn #V\n", - "vol_qk = vol_ab - drop_aq - drop_kf + drop_bf #V\n", - "vol_cd = V_NR - drop_cn - drop_dr #V \n", - "vol_fe = vol_cd + drop_bc - drop_bf - drop_de #V\n", - "\n", - "print \"Potential Difference across AB is = \",round(vol_ab,2),\"V.\"\n", - "print \"Potential Difference across QK is = \",round(vol_qk,2),\"V.\"\n", - "print \"Potential Difference across CD is = \",round(vol_cd,2),\"V.\"\n", - "print \"Potential Difference across FE is = \",round(vol_fe,2),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.22 ,Page No :- 1597" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total load on main generator is = 155.0 kW.\n", - "Load on Balancer 1 is = 22.5 kW.\n", - "Load on Balancer 2 is = 27.5 kW.\n" - ] - } - ], - "source": [ - "#A d.c 3-wire system with 500-V between outers has lighting load of 100kW on the positive and 50kW on the\n", - "#negative side.If,at this loading,the balancer machines have each a loss of 2.5kW,Calculate the kW loading\n", - "#of each balancer machine and the total load on the system.\n", - "###########################################################################################################\n", - "\n", - "#Given\n", - "V_out = 500.0 #V\n", - "load_p = 100.0 #kW (positive side)\n", - "load_n = 50.0 #KW (negative side)\n", - "load_b = 2.5 #kW (balancer machine)\n", - "#total load on main generator\n", - "load_tot = load_p + load_n + 2*load_b #kW\n", - "#Output current of main generator\n", - "cur_out = load_tot*1000/V_out #W/V->A\n", - "#load current on positive side\n", - "cur_p = load_p*1000/(V_out/2) #A\n", - "#load current on negative side\n", - "cur_n = load_n*1000/(V_out/2) #A\n", - "#Current through neutral(Out of balance)\n", - "cur_o = cur_p-cur_n #A\n", - "\n", - "#Currents of balancer\n", - "cur_b1 = cur_p-cur_out #A\n", - "cur_b2 = cur_o - cur_b1 #A\n", - "\n", - "#Load on balancer\n", - "load_b1 = (V_out/2)*cur_b1/1000 #kW\n", - "load_b2 = (V_out/2)*cur_b2/1000 #kW\n", - "\n", - "print \"Total load on main generator is = \",round(load_tot,2),\"kW.\"\n", - "print \"Load on Balancer 1 is = \",round(load_b1,2),\"kW.\"\n", - "print \"Load on Balancer 2 is = \",round(load_b2,2),\"kW.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.23 ,Page No :- 1598" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total load on main generator is = 1216.0 kW.\n", - "Current through Balancer 1 is = 168.0 A.\n", - "Current through Balancer 2 is = 232.0 A.\n" - ] - } - ], - "source": [ - "#In a 500/250-V d.c 3-wire system,there is a current of 2000A on the +ve side, 1600A on the negative side\n", - "#and a load of 300 kW across the outers.The loss in each balancer set is 8 kW.Calculate the current in each\n", - "#armature of the balancer set and total load on the main generator.\n", - "#############################################################################################################\n", - "\n", - "#Given\n", - "V_out = 500.0 #V\n", - "cur_p = 2000.0 #A (current on positive side)\n", - "cur_n = 1600.0 #A (current on negative side)\n", - "load_ext = 300.0 #kW (across outers)\n", - "load_b = 8.0 #kW (loss in balancer set)\n", - "#loading on positive side\n", - "load_p = (cur_p*(V_out/2))/1000 #kW\n", - "#loading on negative side\n", - "load_n = (cur_n*(V_out/2))/1000 #kW\n", - "#Total loading on main generator\n", - "load_tot = load_p + load_n + 2*load_b + load_ext #kW\n", - "\n", - "#current on main generator -> I = W/V\n", - "cur_tot = load_tot*1000/V_out #A\n", - "\n", - "#current through neutral(out of balance)\n", - "cur_o = cur_p-cur_n #A\n", - "\n", - "#current through external resistance\n", - "cur_ext = load_ext*1000/V_out #A\n", - "\n", - "#current through balancer sets\n", - "cur_b1 = (cur_p+cur_ext)-cur_tot #A\n", - "cur_b2 = cur_o - cur_b1 #A\n", - "\n", - "print \"Total load on main generator is = \",round(load_tot,2),\"kW.\"\n", - "print \"Current through Balancer 1 is = \",round(cur_b1,2),\"A.\"\n", - "print \"Current through Balancer 2 is = \",round(cur_b2,2),\"A.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.24 ,Page No :- 1598" - ] - }, - { - "cell_type": "code", - "execution_count": 60, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current supplied by generator is = 7000.0 A.\n", - "Current in positive side is = 6000.0 A.\n", - "Current in negative side is = 8000.0 A.\n", - "Current in neutral is = 2000.0 A.\n", - "Current through armature 1 is = 1000.0 A.\n", - "Current through armature 2 is = 1000.0 A.\n" - ] - } - ], - "source": [ - "#On a 3-wire d.c distribution system with 500V between outers,there is a load of 1500kW on the positive\n", - "#side and 2000 kW on the negative side.Calculate the current in the neutral and in each of the balancer\n", - "#armatures and the total current supplied by the generator.Neglect losses.\n", - "##########################################################################################################\n", - "\n", - "#Given\n", - "V_out = 500.0 #V\n", - "load_p = 1500.0 #kW (load on positive side)\n", - "load_n = 2000.0 #kW (load on negative side)\n", - "#total loading on main generator\n", - "load_tot = load_p + load_n #kW\n", - "#current supplied by generator\n", - "cur_tot = load_tot*1000/V_out #A\n", - "#current on positive side\n", - "cur_p = load_p*1000/(V_out/2) #A\n", - "#current on negative side\n", - "cur_n = load_n*1000/(V_out/2) #A\n", - "#current in neutral(out of balance)\n", - "cur_o = abs(cur_p-cur_n) #A\n", - "#current through armatures\n", - "cur_b1 = cur_tot-cur_p #A\n", - "cur_b2 = cur_o-cur_b1 #A\n", - "\n", - "print \"Current supplied by generator is = \",cur_tot,\"A.\"\n", - "print \"Current in positive side is = \",cur_p,\"A.\"\n", - "print \"Current in negative side is = \",cur_n,\"A.\"\n", - "print \"Current in neutral is = \",cur_o,\"A.\"\n", - "print \"Current through armature 1 is = \",cur_b1,\"A.\"\n", - "print \"Current through armature 2 is = \",cur_b2,\"A.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.25 ,Page No :- 1599" - ] - }, - { - "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Current in balancer set 1 is = 22.0 A.\n", - "Current in balancer set 2 is = 28.0 A.\n", - "Output of main generator is = 119.5 kW.\n" - ] - } - ], - "source": [ - "#A 125/250 V,3-wire distributor has an out-of-balance current of 50 A and larger load of 500 A.The balancer\n", - "#set has a loss of 375 W in each machine.Calculate the current in each of the balancer machines and output\n", - "#of main generator.\n", - "############################################################################################################\n", - "\n", - "#Given\n", - "V_out = 250.0 #V\n", - "#Currents\n", - "cur_p = 500.0 #A\n", - "cur_o = 50.0 #A\n", - "cur_n = cur_p - cur_o #A\n", - "#larger Load\n", - "load_p = cur_p*(V_out/2)/1000 #kW\n", - "#smaller Load\n", - "load_n = cur_n*(V_out/2)/1000 #kW\n", - "#Balancer loss\n", - "loss_b = 2*375.0/1000 #kW\n", - "#total load on generator\n", - "load_tot = load_p + load_n + loss_b\n", - "#current from main generator -> VI = W\n", - "cur_tot = load_tot*1000/V_out #A\n", - "\n", - "#Current in balancer sets\n", - "cur_b1 = cur_p - cur_tot #A\n", - "cur_b2 = cur_o - cur_b1 #A\n", - "print \"Current in balancer set 1 is = \",cur_b1,\"A.\"\n", - "print \"Current in balancer set 2 is = \",cur_b2,\"A.\"\n", - "print \"Output of main generator is = \",load_tot,\"kW.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.26 ,Page No :- 1599" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total load on main generator is = 1210.0 kW.\n", - "Load on Balancer set 1 is = 20.0 kW.\n", - "Load on balancer set 2 is = 30.0 kW.\n" - ] - } - ], - "source": [ - "#The load on d.c 3-wire system with 500 V between outers consists of lighting current of 1500 A on the\n", - "#positive side and 1300 A on the negative side while motors connected across the outers absorb 500kW.\n", - "#Assuming that at this loading,the balancer machines have each a loss of 5kW,calculate the load on the\n", - "#main generator and on each of the balancer machines.\n", - "##########################################################################################################\n", - "\n", - "#Given\n", - "cur_p = 1500.0 #A\n", - "cur_n = 1300.0 #A\n", - "V_out = 500.0 #V\n", - "load_ext = 500.0 #kW\n", - "loss_b = 2*5.0 #kW\n", - "\n", - "#current through external load\n", - "cur_ext = load_ext*1000/V_out #A\n", - "#larger load\n", - "load_p = cur_p*(V_out/2)/1000 #kW\n", - "#smaller load\n", - "load_n = cur_n*(V_out/2)/1000 #kW\n", - "#total load on generator\n", - "load_tot = load_p + load_n + loss_b + load_ext #kW\n", - "#current from generator -> VI = W\n", - "cur_tot = load_tot*1000/V_out #A\n", - "#current through neutral(out of balance)\n", - "cur_o = cur_p-cur_n #A\n", - "#current through balancer sets\n", - "cur_b1 = (cur_p+cur_ext)-cur_tot #A\n", - "cur_b2 = cur_o-cur_b1 #A\n", - "#load of balancer sets\n", - "load_b1 = cur_b1*(V_out/2)/1000 #kW\n", - "load_b2 = cur_b2*(V_out/2)/1000 #kW\n", - "\n", - "print \"Total load on main generator is = \",load_tot,\"kW.\"\n", - "print \"Load on Balancer set 1 is = \",load_b1,\"kW.\"\n", - "print \"Load on balancer set 2 is = \",load_b2,\"kW.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.27 ,Page No :- 1599" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage across Balancer 1 is = 230.0 A.\n", - "Voltage across Balancer 2 is = 250.0 A.\n", - "Load current on main generator is = 1110.0 A.\n" - ] - } - ], - "source": [ - "#A d.c 3-wire system with 480 V across outers supplies 1200 A on the positive and 1000 A on the negative side.\n", - "#The balancer machines have each an armature resistances of 0.1W and take 10 A on no-load.Find\n", - "#(a)the voltage across each balancer and\n", - "#(b)the total load on the main generator and the current loading of each balancer machine.\n", - "#The balancer field windings are in series across the outers\n", - "################################################################################################################\n", - "\n", - "#Given\n", - "V_out = 480.0 #V\n", - "#currents\n", - "cur_p = 1200.0 #A\n", - "cur_n = 1000.0 #A\n", - "cur_o = cur_p - cur_n #A (out of balance)\n", - "#armature resistance \n", - "res_arm = 0.1 #ohm\n", - "#no-load current\n", - "cur_nold = 10.0 #A\n", - "\n", - "#Let us assume current Im flows through mtoring machine,then (200-Im) flows through generating machine.\n", - "#Let Vg and Vm be potential difference of 2 machines.\n", - "\n", - "#Total losses in sets = no-load losses + Cu losses in two machines\n", - "#loss_set = V_out*cur_nold + 0.1*Im^2+ 0.1*(200-Im)^2\n", - "#Vm*Im = Vg*Ig + loss_set\n", - "#Now, Vm = Eb+Im*Ra Vg = Eb-Ig*Ra\n", - "Eb = V_out/2-res_arm*cur_nold\n", - "\n", - "#Therefore, Vm = 239 + Im*0.1 and Vg = 239 - (200-Im)*0.1\n", - "#Hence,Equation is \n", - "#(239+0.1*Im)*Im = [239 - (200-Im)*0.1]*(200-Im) + loss_set\n", - "#Simplified -> 239Im = 239*(200-Im)+4800\n", - "\n", - "#Solving this equation\n", - "from sympy import Eq, var, solve\n", - "var('Im') \n", - "eq = Eq(Eb*(2*Im-cur_o),V_out*cur_nold)\n", - "Im = solve(eq)\n", - "Im = int(Im[0])\n", - "Ig = cur_o-Im\n", - "#Voltage across balancers\n", - "\n", - "Vm = Eb + Im*res_arm #V\n", - "Vg = Eb - Ig*res_arm #V \n", - "\n", - "#Load on main generator\n", - "cur_load = cur_p - Ig #A\n", - "print \"Voltage across Balancer 1 is = \",round(Vg,2),\"A.\"\n", - "print \"Voltage across Balancer 2 is = \",round(Vm,2),\"A.\"\n", - "print \"Load current on main generator is = \",round(cur_load,2),\"A.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.28 ,Page No :- 1600" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Voltage on positive side is = 283.0 V.\n", - "Voltage on negative side is = 177.0 V.\n" - ] - } - ], - "source": [ - "#A d.c 3-wire system with 460V between outers supplies 250kW on the positive and 400kW on the negative side,\n", - "#the voltages being balanced.Calculate the voltage on the positive and negative side,the voltages being balanced.\n", - "#Calculate the voltage on the positive and negative sides repectively,if the neutral wire becomes disconnected\n", - "#from balancer set.\n", - "#################################################################################################################\n", - "\n", - "#Given\n", - "V_mid = 230.0 #V\n", - "V_out = 460.0 #V\n", - "#loads\n", - "load_p = 250.0 #kW\n", - "load_n = 400.0 #kW\n", - "#resistance on positive side -> (V^2/R) = W\n", - "res_p = (V_mid*V_mid)/(load_p*1000) #ohm\n", - "\n", - "#resistance on negative side -> (V^2/R) = W\n", - "res_n = (V_mid*V_mid)/(load_n*1000) #ohm\n", - "\n", - "#Voltages after disconnecting balancer set\n", - "vol_p = (res_p/(res_p+res_n))*V_out #V\n", - "vol_n = V_out - vol_p #V\n", - "\n", - "print \"Voltage on positive side is = \",round(vol_p),\"V.\"\n", - "print \"Voltage on negative side is = \",round(vol_n),\"V.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "EXAMPLE 40.29 ,Page No :- 1601" - ] - }, - { - "cell_type": "code", - "execution_count": 66, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Terminal potential difference of the booster is = 180.0 V.\n", - "Output of booster is = 21.6 kW.\n" - ] - } - ], - "source": [ - "#A 2-wire system has the voltage at the supply end maintained at 500.The line is 3 km long.If the full-load\n", - "#current is 120 A,what must be the booster voltage and output in order that the far end voltage may also be 500 V.\n", - "#Take the resistance of the cable at the working temperature as 0.5ohm/kilometre.\n", - "####################################################################################################################\n", - "\n", - "#Total resistance of line\n", - "res_tot = 0.5*3 #ohm\n", - "#Full load current\n", - "cur_full = 120.0 #A\n", - "\n", - "#drop in the line-> V=IR\n", - "drop = res_tot*cur_full #V\n", - "\n", - "#Output of booster ->VI = W\n", - "output = drop*cur_full/1000 #kW\n", - "\n", - "print \"Terminal potential difference of the booster is = \",drop,\"V.\"\n", - "print \"Output of booster is = \",round(output,2),\"kW.\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.11" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ShivaAmruthavakkula/ShivaAmruthavakkula_version_backup/chapter1.ipynb b/sample_notebooks/ShivaAmruthavakkula/ShivaAmruthavakkula_version_backup/chapter1.ipynb new file mode 100755 index 00000000..37ee420b --- /dev/null +++ b/sample_notebooks/ShivaAmruthavakkula/ShivaAmruthavakkula_version_backup/chapter1.ipynb @@ -0,0 +1,448 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the divergence of the beam is 8.05960631817e-05 in radians\n", + "the divergence of the beam is 0.00461781426568 in degrees\n" + ] + } + ], + "source": [ + "'''Example 1.1.1 :Divergence of a beam '''\n", + "\n", + "import math\n", + "\n", + " #decalring variables\n", + "Lambda=633*(10**-9) #wavelength of laser\n", + "s=10*10**-3 #spot size of the laser\n", + "w=s/2 # waist radius\n", + "\n", + "#calculations\n", + "\n", + "theta_radians=(4*Lambda)/(math.pi*(2*w))\n", + "num=math.pi*(w)\n", + "theta_degrees=math.degrees(theta_radians)\n", + "\n", + "#results\n", + "print \"the divergence of the beam is\",theta_radians,\"in radians\"\n", + "print \"the divergence of the beam is\",theta_degrees,\"in degrees\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Materials EpsilonR squareroot(EpsilonR)\n", + "\n", + "------------------------------------------\n", + "\n", + "silicon \t11.9 \t3.44963766213 \n", + "\n", + "Diamond \t5.7 \t2.38746727726 \n", + "\n", + "GaAs \t13.1 \t3.61939221417 \n", + "\n", + "SiO2 \t3.84 \t1.95959179423 \n", + "\n", + "Water \t80 \t8.94427191 \n", + "\n" + ] + } + ], + "source": [ + "'''Example 1.2.1: relative permittivity and refractive index n'''\n", + "\n", + "\n", + "import math\n", + "\n", + "numbers=[0,1,2,3,4]\n", + "\n", + "#declaring array variables\n", + "materials=['silicon','Diamond','GaAs ','SiO2 ','Water '] #declaring the materials\n", + "relative_permittivity=[11.9,5.7,13.1,3.84,80] #declaring the relative permittivity at low frequencies\n", + "\n", + "#calculations\n", + "refractive_index=[] #declaring result set \n", + "for i in relative_permittivity:\n", + " t=math.sqrt(i)\n", + " refractive_index.append(t)\n", + " \n", + "#Results and Table\n", + "print \"Materials EpsilonR squareroot(EpsilonR)\\n\"\n", + "print \"------------------------------------------\\n\"\n", + "for j in numbers:\n", + " print materials[j],\"\\t\",relative_permittivity[j],\"\\t\",refractive_index[j],\"\\n\"" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The phase velocity is 206896551.724\n", + "The group velocity is 205479452.055\n" + ] + } + ], + "source": [ + "'''Example 1.3.2:Group and phase velocities'''\n", + "\n", + "import math\n", + "\n", + "#declaring variables\n", + "Lambda=1*10**-6 #wavelength of light\n", + "n=1.450 #refractive index\n", + "c=3*10**8 #velocity of light in free space\n", + "group_index=1.46 #Group index(available from graph)\n", + "\n", + "#calculations\n", + "phase_velocity=c/n #calculation of phase velocity\n", + "group_velocity=c/group_index #calculation of group velocity\n", + "\n", + "#results\n", + "\n", + "print \"The phase velocity is \",phase_velocity\n", + "print \"The group velocity is \",group_velocity" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Elctric field and Magnetic field of air are 86.7926073205 and 2.89308691068e-07 respectively\n", + "The Elctric field and Magnetic field of glass are 72.0773372269 and 3.48373796597e-07 respectively\n" + ] + } + ], + "source": [ + "'''Example 1.4.1: Electric and magnetic fields in light'''\n", + "\n", + "import math\n", + "\n", + "#Declaring variables\n", + "Irradiance=1*10**-3*10**4 #Declaring irradiance in standard units\n", + "ng=1.45 #declaring refractive index of glass\n", + "c=3*10**8 #declaring velocity of light\n", + "n=1 #Refractive index of free space\n", + "e=8.85*10**-12\n", + "\n", + "#calculations of magnitude of electrical and magnetic fields in air\n", + "El_air=math.sqrt((2*Irradiance)/(c*e*n)) #Electric field calculation(air)\n", + "B_air=(n*El_air)/c #Magnetic field calculation(air)\n", + "\n", + "#calculations of magnitude of electrical and magnetic fields in glass\n", + "El_glass=math.sqrt((2*Irradiance)/(c*e*ng)) #Electric field calculation(glass) \n", + "B_glass=(ng*El_glass)/c #magnetic field calculation(glass) \n", + "\n", + "#Results\n", + "print \"The Elctric field and Magnetic field of air are \",El_air,\"and\",B_air,\"respectively\"\n", + "print \"The Elctric field and Magnetic field of glass are \",El_glass,\"and\",B_glass,\"respectively\"" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A\n", + "the crirical angle is equal to 0.986206896552 \n", + "\n", + "B\n", + "The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is 116.45255621 degrees\n", + "The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is -62.1314255434 degrees\n", + "The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is 180.0 degrees\n", + "The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is -2.84217094304e-14 degrees \n", + "\n", + "C\n", + "The penetration depth of medium 2 at incident angle of 85 degrees is 7.80048054638e-07 meters\n", + "The penetration depth of medium 2 at incident angle of 90 degrees is 6.63145596216e-07 meters\n" + ] + } + ], + "source": [ + "'''Example 1.6.2'''\n", + "import math\n", + "\n", + "#declaration of variables\n", + "\n", + "n1=1.450 #refractive index of first medium\n", + "n2=1.430 #refractive index of second medium\n", + "Lambda=1*10**-6 #wavelength of light at standard units\n", + "theta_i1=85 #declaration of incidence angle 1\n", + "theta_i2=90 #declaration of incidence angle 2\n", + "\n", + "#Calculation of minimum incidence angle\n", + "theta_c=n2/n1 #calculation of critical angle\n", + "\n", + "#Calculation of phase change in medium 1 at incident angle 85 with perpendicular electrical component\n", + "tanphi_pp_85m1=math.sqrt(math.pow(math.sin(math.radians(theta_i1)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i1))\n", + "phi_pp_85im1=2*math.degrees(math.atan(tanphi_pp_85m1))\n", + "\n", + "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n", + "tanphi_prll_85m1=math.pow((n1/n2),2)*tanphi_pp_85m1\n", + "phi_prll_85m1=2*(math.degrees(math.atan(tanphi_prll_85m1)))-math.degrees(math.pi)\n", + "phi_prll_inv_85m1=180+phi_prll_85m1\n", + "\n", + "#Calculation of phase change in medium 1 at incident angle 90 with perpendicular electrical component\n", + "tanphi_pp_90m1=math.sqrt(math.pow(math.sin(math.radians(theta_i2)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i2))\n", + "phi_pp_90m1=2*math.degrees(math.atan(tanphi_pp_90m1))\n", + "\n", + "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n", + "tanphi_prll_90m1=math.pow((n1/n2),2)*tanphi_pp_90m1\n", + "phi_prll_90m1=2*(math.degrees(math.atan(tanphi_prll_90m1)))-math.degrees(math.pi)\n", + "phi_prll_inv_90m1=180+phi_prll_90m1\n", + "\n", + "#Calculation of penetration depth in medium 2 at incident angle 85\n", + "alpha_85=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i1)),2))-1))\n", + "delta_85=1/alpha_85\n", + "\n", + "#calculation of penetration depth in medium 2 at incident angle 90\n", + "alpha_90=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i2)),2))-1))\n", + "delta_90=1/alpha_90\n", + "\n", + "#Results\n", + "print \"A\"\n", + "print \"the crirical angle is equal to \",theta_c,\"\\n\"\n", + "print \"B\"\n", + "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_85im1,\"degrees\"\n", + "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is\",phi_prll_85m1,\"degrees\"\n", + "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_90m1,\"degrees\"\n", + "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is\",phi_prll_90m1,\"degrees \\n\"\n", + "print \"C\"\n", + "print \"The penetration depth of medium 2 at incident angle of 85 degrees is \",delta_85,\"meters\"\n", + "print \"The penetration depth of medium 2 at incident angle of 90 degrees is \",delta_90,\"meters\"" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A\n", + "the reflection coefficient when light travels from air to glass is -0.2\n", + "the reflectance when light passes from air to glass is 0.04\n", + "The phase change of the reflected light is \n", + "180\n", + "B\n", + "the reflection coefficient when light travels from glass to air is 0.2\n", + "the reflectance when light passes from glass to air is 0.04\n", + "The phase change of the reflected light is \n", + "180\n", + "C\n", + "The polarisation angle is 56.309932474\n" + ] + } + ], + "source": [ + "'''Example 1.6.3: Reflection at normal Incidence.Internal and external reflection'''\n", + "import math\n", + "\n", + "#declaration of variables\n", + "nglass=1.5\n", + "nair=1\n", + "\n", + "#declaration of phase change\n", + "def phasechange(r):\n", + " if r<0:\n", + " return 180\n", + " else:\n", + " return 0 \n", + "#Calculation of reflection coefficient and intensity from air to glass\n", + "r_coeffag=(nair-nglass)/(nair+nglass) #reflection coefficient\n", + "Rag=math.pow(r_coeffag,2) #Reflectance\n", + "pag=phasechange(r_coeffag)\n", + "\n", + "\n", + "#Calculation of relection and intensity from glass to aie\n", + "r_coeffga=(nglass-nair)/(nglass+nair)\n", + "Rga=math.pow(r_coeffga,2)\n", + "pga=phasechange(r_coeffga)\n", + "\n", + "#calculation of polarisation angle\n", + "theta_p=math.degrees(math.atan(nglass/nair))\n", + "\n", + "#Results\n", + "print \"A\"\n", + "print\"the reflection coefficient when light travels from air to glass is \",r_coeffag\n", + "print \"the reflectance when light passes from air to glass is \",Rag\n", + "print \"The phase change of the reflected light is \\n\",pag\n", + "print \"B\"\n", + "print\"the reflection coefficient when light travels from glass to air is \",r_coeffga\n", + "print \"the reflectance when light passes from glass to air is \",Rga\n", + "print \"The phase change of the reflected light is \\n\",pag\n", + "\n", + "print \"C\"\n", + "print \"The polarisation angle is \",theta_p" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the reflectance of the Silicon is 0.308641975309\n", + "the refractive index of coating must be 1.87082869339\n", + "the thickness of the coating is 9.21052631579e-08 meters\n" + ] + } + ], + "source": [ + "'''Example 1.6.4: Antireflection coatings on solarcells'''\n", + "import math\n", + "\n", + "#Declaration of variables\n", + "nair=1\n", + "nsi=3.5\n", + "ncoating=1.9\n", + "Lambda=700*10**-9\n", + "\n", + "#declaration of phase change\n", + "def phasechange(r):\n", + " if r<0:\n", + " return 180\n", + " else:\n", + " return 0 \n", + "\n", + "#Calculation of reflectance at Silicon\n", + "rsi=((nair-nsi)/(nair+nsi))\n", + "Rsi=math.pow(rsi,2)\n", + "psi=phasechange(rsi)\n", + "\n", + "#calculation of refractive index of coating\n", + "ncoating_theoritical=math.sqrt(nair*nsi)\n", + "\n", + "#calculation of thickness\n", + "d=Lambda/(4*ncoating)\n", + "\n", + "#results\n", + "print \"the reflectance of the Silicon is \",Rsi\n", + "print \"the refractive index of coating must be \",ncoating_theoritical\n", + "print \"the thickness of the coating is \",d,\" meters\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# '''Example 1.7.1: Resonator modes and spectral width'''\n", + "import math\n", + "\n", + "#declaration of variables\n", + "L=100*10**-6\n", + "R=0.9\n", + "Lambda=900*10**-9\n", + "c=3*10**8\n", + "\n", + "#Calculation of seperation of modes\n", + "delta_vm=c/(2*L)\n", + "\n", + "#calculation of finesse\n", + "F=((math.pi)*math.sqrt(R))/(1-R)\n", + "\n", + "#calculation of modewidth\n", + "del_vm=delta_vm/F\n", + "\n", + "#calculation of mode frequency\n", + "vm=c/Lambda\n", + "\n", + "#calculation of spectral width\n", + "del_lambda=(c/math.pow(vm,2))*del_vm\n", + "\n", + "#Results\n", + "print \"The seperation of modes is \",delta_vm,\" Hertz\"\n", + "print \"The spectral width is\", del_lambda,\" meters\"" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "celltoolbar": "Edit Metadata", + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb b/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb deleted file mode 100755 index 37ee420b..00000000 --- a/sample_notebooks/ShivaAmruthavakkula/chapter1.ipynb +++ /dev/null @@ -1,448 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the divergence of the beam is 8.05960631817e-05 in radians\n", - "the divergence of the beam is 0.00461781426568 in degrees\n" - ] - } - ], - "source": [ - "'''Example 1.1.1 :Divergence of a beam '''\n", - "\n", - "import math\n", - "\n", - " #decalring variables\n", - "Lambda=633*(10**-9) #wavelength of laser\n", - "s=10*10**-3 #spot size of the laser\n", - "w=s/2 # waist radius\n", - "\n", - "#calculations\n", - "\n", - "theta_radians=(4*Lambda)/(math.pi*(2*w))\n", - "num=math.pi*(w)\n", - "theta_degrees=math.degrees(theta_radians)\n", - "\n", - "#results\n", - "print \"the divergence of the beam is\",theta_radians,\"in radians\"\n", - "print \"the divergence of the beam is\",theta_degrees,\"in degrees\"\n" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Materials EpsilonR squareroot(EpsilonR)\n", - "\n", - "------------------------------------------\n", - "\n", - "silicon \t11.9 \t3.44963766213 \n", - "\n", - "Diamond \t5.7 \t2.38746727726 \n", - "\n", - "GaAs \t13.1 \t3.61939221417 \n", - "\n", - "SiO2 \t3.84 \t1.95959179423 \n", - "\n", - "Water \t80 \t8.94427191 \n", - "\n" - ] - } - ], - "source": [ - "'''Example 1.2.1: relative permittivity and refractive index n'''\n", - "\n", - "\n", - "import math\n", - "\n", - "numbers=[0,1,2,3,4]\n", - "\n", - "#declaring array variables\n", - "materials=['silicon','Diamond','GaAs ','SiO2 ','Water '] #declaring the materials\n", - "relative_permittivity=[11.9,5.7,13.1,3.84,80] #declaring the relative permittivity at low frequencies\n", - "\n", - "#calculations\n", - "refractive_index=[] #declaring result set \n", - "for i in relative_permittivity:\n", - " t=math.sqrt(i)\n", - " refractive_index.append(t)\n", - " \n", - "#Results and Table\n", - "print \"Materials EpsilonR squareroot(EpsilonR)\\n\"\n", - "print \"------------------------------------------\\n\"\n", - "for j in numbers:\n", - " print materials[j],\"\\t\",relative_permittivity[j],\"\\t\",refractive_index[j],\"\\n\"" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The phase velocity is 206896551.724\n", - "The group velocity is 205479452.055\n" - ] - } - ], - "source": [ - "'''Example 1.3.2:Group and phase velocities'''\n", - "\n", - "import math\n", - "\n", - "#declaring variables\n", - "Lambda=1*10**-6 #wavelength of light\n", - "n=1.450 #refractive index\n", - "c=3*10**8 #velocity of light in free space\n", - "group_index=1.46 #Group index(available from graph)\n", - "\n", - "#calculations\n", - "phase_velocity=c/n #calculation of phase velocity\n", - "group_velocity=c/group_index #calculation of group velocity\n", - "\n", - "#results\n", - "\n", - "print \"The phase velocity is \",phase_velocity\n", - "print \"The group velocity is \",group_velocity" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Elctric field and Magnetic field of air are 86.7926073205 and 2.89308691068e-07 respectively\n", - "The Elctric field and Magnetic field of glass are 72.0773372269 and 3.48373796597e-07 respectively\n" - ] - } - ], - "source": [ - "'''Example 1.4.1: Electric and magnetic fields in light'''\n", - "\n", - "import math\n", - "\n", - "#Declaring variables\n", - "Irradiance=1*10**-3*10**4 #Declaring irradiance in standard units\n", - "ng=1.45 #declaring refractive index of glass\n", - "c=3*10**8 #declaring velocity of light\n", - "n=1 #Refractive index of free space\n", - "e=8.85*10**-12\n", - "\n", - "#calculations of magnitude of electrical and magnetic fields in air\n", - "El_air=math.sqrt((2*Irradiance)/(c*e*n)) #Electric field calculation(air)\n", - "B_air=(n*El_air)/c #Magnetic field calculation(air)\n", - "\n", - "#calculations of magnitude of electrical and magnetic fields in glass\n", - "El_glass=math.sqrt((2*Irradiance)/(c*e*ng)) #Electric field calculation(glass) \n", - "B_glass=(ng*El_glass)/c #magnetic field calculation(glass) \n", - "\n", - "#Results\n", - "print \"The Elctric field and Magnetic field of air are \",El_air,\"and\",B_air,\"respectively\"\n", - "print \"The Elctric field and Magnetic field of glass are \",El_glass,\"and\",B_glass,\"respectively\"" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A\n", - "the crirical angle is equal to 0.986206896552 \n", - "\n", - "B\n", - "The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is 116.45255621 degrees\n", - "The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is -62.1314255434 degrees\n", - "The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is 180.0 degrees\n", - "The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is -2.84217094304e-14 degrees \n", - "\n", - "C\n", - "The penetration depth of medium 2 at incident angle of 85 degrees is 7.80048054638e-07 meters\n", - "The penetration depth of medium 2 at incident angle of 90 degrees is 6.63145596216e-07 meters\n" - ] - } - ], - "source": [ - "'''Example 1.6.2'''\n", - "import math\n", - "\n", - "#declaration of variables\n", - "\n", - "n1=1.450 #refractive index of first medium\n", - "n2=1.430 #refractive index of second medium\n", - "Lambda=1*10**-6 #wavelength of light at standard units\n", - "theta_i1=85 #declaration of incidence angle 1\n", - "theta_i2=90 #declaration of incidence angle 2\n", - "\n", - "#Calculation of minimum incidence angle\n", - "theta_c=n2/n1 #calculation of critical angle\n", - "\n", - "#Calculation of phase change in medium 1 at incident angle 85 with perpendicular electrical component\n", - "tanphi_pp_85m1=math.sqrt(math.pow(math.sin(math.radians(theta_i1)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i1))\n", - "phi_pp_85im1=2*math.degrees(math.atan(tanphi_pp_85m1))\n", - "\n", - "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n", - "tanphi_prll_85m1=math.pow((n1/n2),2)*tanphi_pp_85m1\n", - "phi_prll_85m1=2*(math.degrees(math.atan(tanphi_prll_85m1)))-math.degrees(math.pi)\n", - "phi_prll_inv_85m1=180+phi_prll_85m1\n", - "\n", - "#Calculation of phase change in medium 1 at incident angle 90 with perpendicular electrical component\n", - "tanphi_pp_90m1=math.sqrt(math.pow(math.sin(math.radians(theta_i2)),2)-math.pow((n2/n1),2))/math.cos(math.radians(theta_i2))\n", - "phi_pp_90m1=2*math.degrees(math.atan(tanphi_pp_90m1))\n", - "\n", - "#Calculation of phase change in medium 1 at incident angle 85 with parallel electrical component\n", - "tanphi_prll_90m1=math.pow((n1/n2),2)*tanphi_pp_90m1\n", - "phi_prll_90m1=2*(math.degrees(math.atan(tanphi_prll_90m1)))-math.degrees(math.pi)\n", - "phi_prll_inv_90m1=180+phi_prll_90m1\n", - "\n", - "#Calculation of penetration depth in medium 2 at incident angle 85\n", - "alpha_85=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i1)),2))-1))\n", - "delta_85=1/alpha_85\n", - "\n", - "#calculation of penetration depth in medium 2 at incident angle 90\n", - "alpha_90=(2*math.pi*n2/Lambda)*(math.sqrt((math.pow((n1/n2),2)*math.pow(math.sin(math.radians(theta_i2)),2))-1))\n", - "delta_90=1/alpha_90\n", - "\n", - "#Results\n", - "print \"A\"\n", - "print \"the crirical angle is equal to \",theta_c,\"\\n\"\n", - "print \"B\"\n", - "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_85im1,\"degrees\"\n", - "print \"The phase change in medium 1 at incident angle=85 degrees with electrical component parallel to the plane of incidence is\",phi_prll_85m1,\"degrees\"\n", - "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component perpendicular to the plane of incidence is\",phi_pp_90m1,\"degrees\"\n", - "print \"The phase change in medium 1 at incident angle=90 degrees with electrical component parallel to the plane of incidence is\",phi_prll_90m1,\"degrees \\n\"\n", - "print \"C\"\n", - "print \"The penetration depth of medium 2 at incident angle of 85 degrees is \",delta_85,\"meters\"\n", - "print \"The penetration depth of medium 2 at incident angle of 90 degrees is \",delta_90,\"meters\"" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A\n", - "the reflection coefficient when light travels from air to glass is -0.2\n", - "the reflectance when light passes from air to glass is 0.04\n", - "The phase change of the reflected light is \n", - "180\n", - "B\n", - "the reflection coefficient when light travels from glass to air is 0.2\n", - "the reflectance when light passes from glass to air is 0.04\n", - "The phase change of the reflected light is \n", - "180\n", - "C\n", - "The polarisation angle is 56.309932474\n" - ] - } - ], - "source": [ - "'''Example 1.6.3: Reflection at normal Incidence.Internal and external reflection'''\n", - "import math\n", - "\n", - "#declaration of variables\n", - "nglass=1.5\n", - "nair=1\n", - "\n", - "#declaration of phase change\n", - "def phasechange(r):\n", - " if r<0:\n", - " return 180\n", - " else:\n", - " return 0 \n", - "#Calculation of reflection coefficient and intensity from air to glass\n", - "r_coeffag=(nair-nglass)/(nair+nglass) #reflection coefficient\n", - "Rag=math.pow(r_coeffag,2) #Reflectance\n", - "pag=phasechange(r_coeffag)\n", - "\n", - "\n", - "#Calculation of relection and intensity from glass to aie\n", - "r_coeffga=(nglass-nair)/(nglass+nair)\n", - "Rga=math.pow(r_coeffga,2)\n", - "pga=phasechange(r_coeffga)\n", - "\n", - "#calculation of polarisation angle\n", - "theta_p=math.degrees(math.atan(nglass/nair))\n", - "\n", - "#Results\n", - "print \"A\"\n", - "print\"the reflection coefficient when light travels from air to glass is \",r_coeffag\n", - "print \"the reflectance when light passes from air to glass is \",Rag\n", - "print \"The phase change of the reflected light is \\n\",pag\n", - "print \"B\"\n", - "print\"the reflection coefficient when light travels from glass to air is \",r_coeffga\n", - "print \"the reflectance when light passes from glass to air is \",Rga\n", - "print \"The phase change of the reflected light is \\n\",pag\n", - "\n", - "print \"C\"\n", - "print \"The polarisation angle is \",theta_p" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the reflectance of the Silicon is 0.308641975309\n", - "the refractive index of coating must be 1.87082869339\n", - "the thickness of the coating is 9.21052631579e-08 meters\n" - ] - } - ], - "source": [ - "'''Example 1.6.4: Antireflection coatings on solarcells'''\n", - "import math\n", - "\n", - "#Declaration of variables\n", - "nair=1\n", - "nsi=3.5\n", - "ncoating=1.9\n", - "Lambda=700*10**-9\n", - "\n", - "#declaration of phase change\n", - "def phasechange(r):\n", - " if r<0:\n", - " return 180\n", - " else:\n", - " return 0 \n", - "\n", - "#Calculation of reflectance at Silicon\n", - "rsi=((nair-nsi)/(nair+nsi))\n", - "Rsi=math.pow(rsi,2)\n", - "psi=phasechange(rsi)\n", - "\n", - "#calculation of refractive index of coating\n", - "ncoating_theoritical=math.sqrt(nair*nsi)\n", - "\n", - "#calculation of thickness\n", - "d=Lambda/(4*ncoating)\n", - "\n", - "#results\n", - "print \"the reflectance of the Silicon is \",Rsi\n", - "print \"the refractive index of coating must be \",ncoating_theoritical\n", - "print \"the thickness of the coating is \",d,\" meters\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# '''Example 1.7.1: Resonator modes and spectral width'''\n", - "import math\n", - "\n", - "#declaration of variables\n", - "L=100*10**-6\n", - "R=0.9\n", - "Lambda=900*10**-9\n", - "c=3*10**8\n", - "\n", - "#Calculation of seperation of modes\n", - "delta_vm=c/(2*L)\n", - "\n", - "#calculation of finesse\n", - "F=((math.pi)*math.sqrt(R))/(1-R)\n", - "\n", - "#calculation of modewidth\n", - "del_vm=delta_vm/F\n", - "\n", - "#calculation of mode frequency\n", - "vm=c/Lambda\n", - "\n", - "#calculation of spectral width\n", - "del_lambda=(c/math.pow(vm,2))*del_vm\n", - "\n", - "#Results\n", - "print \"The seperation of modes is \",delta_vm,\" Hertz\"\n", - "print \"The spectral width is\", del_lambda,\" meters\"" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "celltoolbar": "Edit Metadata", - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ShubhamDahiphale/ShubhamDahiphale_version_backup/chapter_1.ipynb b/sample_notebooks/ShubhamDahiphale/ShubhamDahiphale_version_backup/chapter_1.ipynb new file mode 100644 index 00000000..87ae9b81 --- /dev/null +++ b/sample_notebooks/ShubhamDahiphale/ShubhamDahiphale_version_backup/chapter_1.ipynb @@ -0,0 +1,193 @@ +{ + "metadata": { + "name": "chapter 1.ipynb" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1:Coplanar Concurrent Force System" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1,Page No.3" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration of Variables\n", + "\n", + "F1=1200 #N #Force1\n", + "F2=400 #N #Force2\n", + "\n", + "#Calculations\n", + "\n", + "theta=arctan(300*400**-1)*(180*pi**-1)\n", + "\n", + "#Components of F1\n", + "F1x=-F1*sin(theta*180**-1*pi) #N\n", + "F1y=-F1*cos(theta*180**-1*pi) #N\n", + "\n", + "#Components of F2\n", + "F2x=F2*cos(theta*180**-1*pi) #N\n", + "F2y=-F2*sin(theta*180**-1*pi) #N\n", + "\n", + "#Results\n", + "print\"Components of F1 is:F1x\",round(F1x,2),\"N\"\n", + "print\" :F1y\",round(F1y,2),\"N\"\n", + "print\"Components of F1 is:F2x\",round(F2x,2),\"N\"\n", + "print\" :F2y\",round(F2y,2),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Components of F1 is:F1x -720.0 N\n", + " :F1y -960.0 N\n", + "Components of F1 is:F2x 320.0 N\n", + " :F2y -240.0 N\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 1,Page No.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration of Variables\n", + "\n", + "#Forces\n", + "F1=300 #N\n", + "F2=390 #N\n", + "F3=400 #N\n", + "\n", + "#Angles\n", + "theta1=30 #Degree\n", + "theta2=arctan(12*5**-1)*(180*pi**-1) #Degree\n", + "theta3=40 #Degree\n", + "\n", + "#Calculations\n", + "\n", + "#Components of F1\n", + "F1x=F1*cos(theta1*pi*180**-1) #N\n", + "F1y=-F1*sin(theta1*pi*180**-1) #N\n", + "\n", + "#Components of F2\n", + "F2x=-F2*cos(theta2*pi*180**-1) #N\n", + "F2y=F2*sin(theta2*pi*180**-1) #N\n", + "\n", + "#Components of F3\n", + "F3x=-F3*cos(theta3*pi*180**-1) #N\n", + "F3y=-F3*sin(theta3*pi*180**-1) #N\n", + "\n", + "#Result\n", + "print\"Components of F1 is:F1x\",round(F1x,2),\"N\"\n", + "print\" :F1y\",round(F1y,2),\"N\"\n", + "print\"Components of F2 is:F2x\",round(F2x,2),\"N\"\n", + "print\" :F2y\",round(F2y,2),\"N\"\n", + "print\"Components of F3 is:F2x\",round(F3x,2),\"N\"\n", + "print\" :F3y\",round(F3y,2),\"N\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Components of F1 is:F1x 259.81 N\n", + " :F1y -150.0 N\n", + "Components of F2 is:F2x -150.0 N\n", + " :F2y 360.0 N\n", + "Components of F3 is:F2x -306.42 N\n", + " :F3y -257.12 N\n" + ] + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Problem 3,Page No.4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Declaration of Variables\n", + "\n", + "#Forces\n", + "F1=20 #N\n", + "F2=60 #N\n", + "\n", + "theta1=20 #Degree\n", + "theta2=25 #Degree\n", + "\n", + "#Calculations\n", + "\n", + "#Resultant\n", + "\n", + "R=(F1**2+F2**2+2*F1*F2*cos(theta2*pi*180**-1))**0.5 #N\n", + "\n", + "X=(F1*(sin(theta2*180**-1*pi)))\n", + "Y=((F1+F2*(cos(theta2*pi*180**-1))))\n", + "alpha=arctan(X*Y**-1)*(180*pi**-1)\n", + "\n", + "#Inclination with x axis\n", + "alpha2=theta1+alpha\n", + "\n", + "#Result\n", + "print\"Resultant of two forces is\",round(alpha2,2),\"degree\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resultant of two forces is 26.48 degree\n" + ] + } + ], + "prompt_number": 28 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ShubhamDahiphale/chapter_1.ipynb b/sample_notebooks/ShubhamDahiphale/chapter_1.ipynb deleted file mode 100644 index 87ae9b81..00000000 --- a/sample_notebooks/ShubhamDahiphale/chapter_1.ipynb +++ /dev/null @@ -1,193 +0,0 @@ -{ - "metadata": { - "name": "chapter 1.ipynb" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1:Coplanar Concurrent Force System" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1,Page No.3" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration of Variables\n", - "\n", - "F1=1200 #N #Force1\n", - "F2=400 #N #Force2\n", - "\n", - "#Calculations\n", - "\n", - "theta=arctan(300*400**-1)*(180*pi**-1)\n", - "\n", - "#Components of F1\n", - "F1x=-F1*sin(theta*180**-1*pi) #N\n", - "F1y=-F1*cos(theta*180**-1*pi) #N\n", - "\n", - "#Components of F2\n", - "F2x=F2*cos(theta*180**-1*pi) #N\n", - "F2y=-F2*sin(theta*180**-1*pi) #N\n", - "\n", - "#Results\n", - "print\"Components of F1 is:F1x\",round(F1x,2),\"N\"\n", - "print\" :F1y\",round(F1y,2),\"N\"\n", - "print\"Components of F1 is:F2x\",round(F2x,2),\"N\"\n", - "print\" :F2y\",round(F2y,2),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Components of F1 is:F1x -720.0 N\n", - " :F1y -960.0 N\n", - "Components of F1 is:F2x 320.0 N\n", - " :F2y -240.0 N\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 1,Page No.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration of Variables\n", - "\n", - "#Forces\n", - "F1=300 #N\n", - "F2=390 #N\n", - "F3=400 #N\n", - "\n", - "#Angles\n", - "theta1=30 #Degree\n", - "theta2=arctan(12*5**-1)*(180*pi**-1) #Degree\n", - "theta3=40 #Degree\n", - "\n", - "#Calculations\n", - "\n", - "#Components of F1\n", - "F1x=F1*cos(theta1*pi*180**-1) #N\n", - "F1y=-F1*sin(theta1*pi*180**-1) #N\n", - "\n", - "#Components of F2\n", - "F2x=-F2*cos(theta2*pi*180**-1) #N\n", - "F2y=F2*sin(theta2*pi*180**-1) #N\n", - "\n", - "#Components of F3\n", - "F3x=-F3*cos(theta3*pi*180**-1) #N\n", - "F3y=-F3*sin(theta3*pi*180**-1) #N\n", - "\n", - "#Result\n", - "print\"Components of F1 is:F1x\",round(F1x,2),\"N\"\n", - "print\" :F1y\",round(F1y,2),\"N\"\n", - "print\"Components of F2 is:F2x\",round(F2x,2),\"N\"\n", - "print\" :F2y\",round(F2y,2),\"N\"\n", - "print\"Components of F3 is:F2x\",round(F3x,2),\"N\"\n", - "print\" :F3y\",round(F3y,2),\"N\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Components of F1 is:F1x 259.81 N\n", - " :F1y -150.0 N\n", - "Components of F2 is:F2x -150.0 N\n", - " :F2y 360.0 N\n", - "Components of F3 is:F2x -306.42 N\n", - " :F3y -257.12 N\n" - ] - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Problem 3,Page No.4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Declaration of Variables\n", - "\n", - "#Forces\n", - "F1=20 #N\n", - "F2=60 #N\n", - "\n", - "theta1=20 #Degree\n", - "theta2=25 #Degree\n", - "\n", - "#Calculations\n", - "\n", - "#Resultant\n", - "\n", - "R=(F1**2+F2**2+2*F1*F2*cos(theta2*pi*180**-1))**0.5 #N\n", - "\n", - "X=(F1*(sin(theta2*180**-1*pi)))\n", - "Y=((F1+F2*(cos(theta2*pi*180**-1))))\n", - "alpha=arctan(X*Y**-1)*(180*pi**-1)\n", - "\n", - "#Inclination with x axis\n", - "alpha2=theta1+alpha\n", - "\n", - "#Result\n", - "print\"Resultant of two forces is\",round(alpha2,2),\"degree\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resultant of two forces is 26.48 degree\n" - ] - } - ], - "prompt_number": 28 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SoumenGanguly/ncert.ipynb b/sample_notebooks/SoumenGanguly/ncert.ipynb new file mode 100755 index 00000000..30efaf66 --- /dev/null +++ b/sample_notebooks/SoumenGanguly/ncert.ipynb @@ -0,0 +1,355 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Chapter 1: Sets\n", + "========" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 1, Page 03:\n", + "----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Therefore, the solution set of the given equation can be written in roaster form as {-2,1}\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "coeff = [1,1,-2]\n", + "\n", + "#Calculations\n", + "roots_array = np.roots(coeff)\n", + "\n", + "#Result\n", + "print \"Therefore, the solution set of the given equation can be written in roaster form as {%d,%d}\"%(roots_array[0],roots_array[1])\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 2, Page 03:\n", + "---------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The required numbers are 1,2,3,4,5,6\n", + "So, the given set in the roster form is {1,2,3,4,5,6}\n" + ] + } + ], + "source": [ + "#Variable declaration\n", + "pos_integer = []\n", + "\n", + "#Calculations\n", + "for i in range(1,1000): #1000 is taken as the upper limit of a positive integer\n", + " if i**2<40:\n", + " pos_integer.append(i)\n", + " \n", + "#Result\n", + "print \"The required numbers are %d,%d,%d,%d,%d,%d\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", + "print \"So, the given set in the roster form is {%d,%d,%d,%d,%d,%d}\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 12, Page 14:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The union of the two given arrays is \n", + "[ 2 4 6 8 10 12]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [2,4,6,8]\n", + "b = [6,8,10,12]\n", + "\n", + "#Calculations\n", + "union_array = np.union1d(a,b)\n", + "\n", + "#Result\n", + "print \"The union of the two given arrays is \"\n", + "print union_array" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 13, Page 14:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A U B = ['a' 'e' 'i' 'o' 'u']\n", + "A = ['a', 'e', 'i', 'o', 'u']\n", + "Thus, A U B = A\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = ['a','e','i','o','u']\n", + "b = ['a','i','u']\n", + "\n", + "#Calculations\n", + "union_array = np.union1d(a,b)\n", + "\n", + "#Result\n", + "print \"A U B = %s\"%(union_array)\n", + "print \"A = %s\"%(a)\n", + "print \"Thus, A U B = A\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 15, Page 15:\n", + "----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A intersection B = [6 8]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [2,4,6,8]\n", + "b = [6,8,10,12]\n", + "\n", + "#Calculations\n", + "intersect_array = np.intersect1d(a,b)\n", + "\n", + "#Result\n", + "print \"A intersection B = %s\"%(intersect_array)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 18, Page 17:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A - B = [1 3 5]\n", + "B - A = [8]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "a = [1,2,3,4,5,6]\n", + "b = [2,4,6,8]\n", + "\n", + "#Calculations\n", + "diff_a = np.setdiff1d(a,b)\n", + "diff_b = np.setdiff1d(b,a)\n", + "\n", + "#Result\n", + "print \"A - B = %s\"%(diff_a)\n", + "print \"B - A = %s\"%(diff_b)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 20, Page 19:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A' = [ 2 4 6 8 10]\n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "u = [1,2,3,4,5,6,7,8,9,10]\n", + "a = [1,3,5,7,9]\n", + "\n", + "#Calculations\n", + "complement_a = np.setdiff1d(u,a)\n", + "\n", + "#Result\n", + "print \"A' = %s\"%(complement_a)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Example 22, Page 19:\n", + "-----------------------" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A' = [1 4 5 6]\n", + "B' = [1 2 6]\n", + "A' intersection B' = [1 6]\n", + "A U B = [2 3 4 5]\n", + "(A U B)' = [1 6]\n", + "Therefore, (A U B)' = A' intersection B' \n" + ] + } + ], + "source": [ + "import numpy as np\n", + "\n", + "#Variable declaration\n", + "u = [1,2,3,4,5,6]\n", + "a = [2,3]\n", + "b = [3,4,5]\n", + "\n", + "#Calculations\n", + "complement_a = np.setdiff1d(u,a)\n", + "complement_b = np.setdiff1d(u,b)\n", + "intersect_ab = np.intersect1d(complement_a,complement_b)\n", + "union_ab = np.union1d(a,b)\n", + "complement_union_ab = np.setdiff1d(u,union_ab)\n", + "\n", + "#Result\n", + "print \"A' = %s\"%(complement_a)\n", + "print \"B' = %s\"%(complement_b)\n", + "print \"A' intersection B' = %s\"%(intersect_ab)\n", + "print \"A U B = %s\"%(union_ab)\n", + "print \"(A U B)' = %s\"%(complement_union_ab)\n", + "print \"Therefore, (A U B)\\' = A\\' intersection B\\' \"\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.8" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb b/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb deleted file mode 100755 index 30efaf66..00000000 --- a/sample_notebooks/SoumenGanguly/ncert_Maths.ipynb +++ /dev/null @@ -1,355 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Chapter 1: Sets\n", - "========" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 1, Page 03:\n", - "----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Therefore, the solution set of the given equation can be written in roaster form as {-2,1}\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "coeff = [1,1,-2]\n", - "\n", - "#Calculations\n", - "roots_array = np.roots(coeff)\n", - "\n", - "#Result\n", - "print \"Therefore, the solution set of the given equation can be written in roaster form as {%d,%d}\"%(roots_array[0],roots_array[1])\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 2, Page 03:\n", - "---------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The required numbers are 1,2,3,4,5,6\n", - "So, the given set in the roster form is {1,2,3,4,5,6}\n" - ] - } - ], - "source": [ - "#Variable declaration\n", - "pos_integer = []\n", - "\n", - "#Calculations\n", - "for i in range(1,1000): #1000 is taken as the upper limit of a positive integer\n", - " if i**2<40:\n", - " pos_integer.append(i)\n", - " \n", - "#Result\n", - "print \"The required numbers are %d,%d,%d,%d,%d,%d\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", - "print \"So, the given set in the roster form is {%d,%d,%d,%d,%d,%d}\"%(pos_integer[0],pos_integer[1],pos_integer[2],pos_integer[3],pos_integer[4],pos_integer[5])\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 12, Page 14:\n", - "-----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The union of the two given arrays is \n", - "[ 2 4 6 8 10 12]\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "a = [2,4,6,8]\n", - "b = [6,8,10,12]\n", - "\n", - "#Calculations\n", - "union_array = np.union1d(a,b)\n", - "\n", - "#Result\n", - "print \"The union of the two given arrays is \"\n", - "print union_array" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 13, Page 14:\n", - "-----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A U B = ['a' 'e' 'i' 'o' 'u']\n", - "A = ['a', 'e', 'i', 'o', 'u']\n", - "Thus, A U B = A\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "a = ['a','e','i','o','u']\n", - "b = ['a','i','u']\n", - "\n", - "#Calculations\n", - "union_array = np.union1d(a,b)\n", - "\n", - "#Result\n", - "print \"A U B = %s\"%(union_array)\n", - "print \"A = %s\"%(a)\n", - "print \"Thus, A U B = A\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 15, Page 15:\n", - "----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A intersection B = [6 8]\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "a = [2,4,6,8]\n", - "b = [6,8,10,12]\n", - "\n", - "#Calculations\n", - "intersect_array = np.intersect1d(a,b)\n", - "\n", - "#Result\n", - "print \"A intersection B = %s\"%(intersect_array)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 18, Page 17:\n", - "-----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A - B = [1 3 5]\n", - "B - A = [8]\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "a = [1,2,3,4,5,6]\n", - "b = [2,4,6,8]\n", - "\n", - "#Calculations\n", - "diff_a = np.setdiff1d(a,b)\n", - "diff_b = np.setdiff1d(b,a)\n", - "\n", - "#Result\n", - "print \"A - B = %s\"%(diff_a)\n", - "print \"B - A = %s\"%(diff_b)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 20, Page 19:\n", - "-----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A' = [ 2 4 6 8 10]\n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "u = [1,2,3,4,5,6,7,8,9,10]\n", - "a = [1,3,5,7,9]\n", - "\n", - "#Calculations\n", - "complement_a = np.setdiff1d(u,a)\n", - "\n", - "#Result\n", - "print \"A' = %s\"%(complement_a)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "Example 22, Page 19:\n", - "-----------------------" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A' = [1 4 5 6]\n", - "B' = [1 2 6]\n", - "A' intersection B' = [1 6]\n", - "A U B = [2 3 4 5]\n", - "(A U B)' = [1 6]\n", - "Therefore, (A U B)' = A' intersection B' \n" - ] - } - ], - "source": [ - "import numpy as np\n", - "\n", - "#Variable declaration\n", - "u = [1,2,3,4,5,6]\n", - "a = [2,3]\n", - "b = [3,4,5]\n", - "\n", - "#Calculations\n", - "complement_a = np.setdiff1d(u,a)\n", - "complement_b = np.setdiff1d(u,b)\n", - "intersect_ab = np.intersect1d(complement_a,complement_b)\n", - "union_ab = np.union1d(a,b)\n", - "complement_union_ab = np.setdiff1d(u,union_ab)\n", - "\n", - "#Result\n", - "print \"A' = %s\"%(complement_a)\n", - "print \"B' = %s\"%(complement_b)\n", - "print \"A' intersection B' = %s\"%(intersect_ab)\n", - "print \"A U B = %s\"%(union_ab)\n", - "print \"(A U B)' = %s\"%(complement_union_ab)\n", - "print \"Therefore, (A U B)\\' = A\\' intersection B\\' \"\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.8" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up.ipynb b/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up.ipynb deleted file mode 100755 index d3bdda01..00000000 --- a/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up.ipynb +++ /dev/null @@ -1,1779 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:64b755d597a2016634dadbbc81a598a60446119cc89f4f94fd9140b5bc077b77" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11: Object Initialization and clean up" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- bag.cpp, Page-392" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25\n", - "def show(self):\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS\n", - " __ItemCount=int\n", - " def SetEmpty(self):\n", - " self.ItemCount=0\n", - " def put(self,item):\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show\n", - "bag=Bag() #object of class Bag\n", - "bag.SetEmpty() #initialize the object\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag.put(item)\n", - " print \"Items in bag:\",\n", - " bag.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Items in bag: 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- newbag.cpp, Page-395" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25 #size of array contents\n", - "def show(self):\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS #int 1D array\n", - " __ItemCount=int\n", - " def __init__(self): #Constructor\n", - " self.ItemCount=0\n", - " def put(self,item): #member function defined inside the class\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show #member function defined outside the class\n", - "bag=Bag() #object of class Bag\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag.put(item)\n", - " print \"Items in bag:\",\n", - " bag.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Items in bag: 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test1.cpp, Page-396" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " print \"Constructor of class test called\"\n", - "class Test:\n", - " __init__=__init__ #Constructor\n", - "G=Test()\n", - "def func():\n", - " L=Test()\n", - " print \"Here's function func()\"\n", - "X=Test()\n", - "print \"main() function\"\n", - "func()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class test called\n", - "Constructor of class test called\n", - "main() function\n", - "Constructor of class test called\n", - "Here's function func()\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- giftbag.cpp, Page- 398" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25\n", - "def show(self):\n", - " if self.ItemCount:\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - " else:\n", - " print \"Nil\"\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS\n", - " __ItemCount=int\n", - " def __init__(self, item=None): #parameterized constructor: Python does not support overloading of functions\n", - " if isinstance(item, int):\n", - " self._Bag__contents[0]=item\n", - " self.ItemCount=1\n", - " else:\n", - " self.ItemCount=0\n", - " def put(self,item):\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show\n", - "bag1=Bag()\n", - "bag2=Bag(4) #object created using the parameterized constructor\n", - "print \"Gifted bag1 initially has:\",\n", - "bag1.show()\n", - "print \"Gifted bag2 initially has:\",\n", - "bag2.show()\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag2.put(item)\n", - " print \"Items in bag2:\",\n", - " bag2.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gifted bag1 initially has: Nil\n", - "Gifted bag2 initially has: 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1 2 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test.cpp, Page-400 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " print \"Constructor of class Test called\"\n", - "def __del__(self):\n", - " print \"Destructor of class Test called\"\n", - "class Test:\n", - " __init__=__init__ #Constructor\n", - " __del__=__del__ #Destructor\n", - "x=Test()\n", - "print \"Terminating main\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Test called\n", - "Destructor of class Test called\n", - "Terminating main\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-count.cpp, Page-401" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "nobjects=0\n", - "nobj_alive=0\n", - "class MyClass:\n", - " def __init__(self):\n", - " global nobjects #using the global nobjects\n", - " global nobj_alive #using the global nobj_alive\n", - " nobjects+=1\n", - " nobj_alive+=1\n", - " def __del__(self):\n", - " global nobj_alive #using the global nobjects\n", - " nobj_alive-=1\n", - " def show(self):\n", - " global nobjects\n", - " global nobj_alive\n", - " print \"Total number of objects created: \", nobjects\n", - " print \"Number of objects currently alive: \", nobj_alive\n", - "obj1=MyClass()\n", - "obj1.show()\n", - "def func():\n", - " obj1=MyClass()\n", - " obj2=MyClass()\n", - " obj2.show()\n", - " del obj1\n", - " del obj2\n", - "func()\n", - "obj1.show()\n", - "obj2=MyClass()\n", - "obj3=MyClass()\n", - "obj2.show()\n", - "del obj1\n", - "del obj2\n", - "del obj3" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total number of objects created: 1\n", - "Number of objects currently alive: 1\n", - "Total number of objects created: 3\n", - "Number of objects currently alive: 3\n", - "Total number of objects created: 3\n", - "Number of objects currently alive: 1\n", - "Total number of objects created: 5\n", - "Number of objects currently alive: 3\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example-account.cpp, Page- 403" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MoneyTransfer(self, acc , amount):\n", - " self._AccClass__balance=self._AccClass__balance-amount\n", - " acc._AccClass__balance=acc._AccClass__balance + amount\n", - "class AccClass:\n", - " __accno=int\n", - " __balance=float\n", - " def __init__(self, an=None, bal=0.0):\n", - " if isinstance(an, int):\n", - " self.accno=an\n", - " self.__balance=bal\n", - " else:\n", - " self.accno=raw_input(\"Enter account number for acc1 object: \")\n", - " self.__balance=float(raw_input(\"Enter the balance: \"))\n", - " def display(self):\n", - " print \"Acoount number is: \", self.accno\n", - " print \"Balance is: \", self.__balance\n", - " MoneyTransfer=MoneyTransfer\n", - "acc1=AccClass()\n", - "acc2=AccClass(10)\n", - "acc3=AccClass(20, 750.5)\n", - "print \"Acoount information...\"\n", - "acc1.display()\n", - "acc2.display()\n", - "acc3.display()\n", - "trans_money=float(raw_input(\"How much money is to be transferred from acc3 to acc1: \"))\n", - "acc3.MoneyTransfer(acc1, trans_money)\n", - "print \"Updated information about accounts...\"\n", - "acc1.display()\n", - "acc2.display()\n", - "acc3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter account number for acc1 object: 1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the balance: 100\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Acoount information...\n", - "Acoount number is: 1\n", - "Balance is: 100.0\n", - "Acoount number is: 10\n", - "Balance is: 0.0\n", - "Acoount number is: 20\n", - "Balance is: 750.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How much money is to be transferred from acc3 to acc1: 200\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Updated information about accounts...\n", - "Acoount number is: 1\n", - "Balance is: 300.0\n", - "Acoount number is: 10\n", - "Balance is: 0.0\n", - "Acoount number is: 20\n", - "Balance is: 550.5\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test2.cpp. Page- 405" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self, NameIn=None):\n", - " if isinstance(NameIn, str):\n", - " self.name=NameIn\n", - " print \"Test Object \", NameIn, \" created\"\n", - " else:\n", - " self.name=\"unnamed\"\n", - " print \"Test object 'unnamed' created\"\n", - "def __del__(self):\n", - " print \"Test Object \", self.name, \" destroyed\"\n", - " del self.name\n", - "class Test:\n", - " __name=[str]\n", - " __init__=__init__\n", - " __del__=__del__\n", - "g=Test(\"global\")\n", - "def func():\n", - " l=Test(\"func\")\n", - " print \"here's function func()\"\n", - "x=Test(\"main\")\n", - "func()\n", - "print \"main() function - termination\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Test Object global created\n", - "Test Object global destroyed\n", - "Test Object main created\n", - "Test Object main destroyed\n", - "Test Object func created\n", - "here's function func()\n", - "Test Object func destroyed\n", - "main() function - termination\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-complex1.cpp, Page- 407" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "def add (self, c2):\n", - " temp=Complex()\n", - " temp._Complex__real=self._Complex__real+c2._Complex__real\n", - " temp._Complex__imag=self._Complex__imag+c2._Complex__imag\n", - " return temp\n", - "class Complex:\n", - " __real=float\n", - " __imag=float\n", - " def __init__(self, real_in=None, imag_in=0.0):\n", - " if isinstance(real_in, float):\n", - " self.__real=real_in\n", - " self.__imag=imag_in\n", - " else:\n", - " self.__real=self.__imag=0.0\n", - " def show(self, msg):\n", - " print msg, \n", - " print self.__real,\n", - " if self.__imag<0:\n", - " print \"-i\",\n", - " else:\n", - " print \"+i\",\n", - " print math.fabs(self.__imag) #print absolute value\n", - " add=add\n", - "c1=Complex(1.5,2.0)\n", - "c2=Complex(2.2)\n", - "c3=Complex()\n", - "c1.show(\"c1=\")\n", - "c2.show(\"c2=\")\n", - "c3=c1.add(c2)\n", - "c3.show(\"c3=c1.add(c2):\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c1= 1.5 +i 2.0\n", - "c2= 2.2 +i 0.0\n", - "c3=c1.add(c2): 3.7 +i 2.0\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- noname.cpp, Page- 410" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class nameless:\n", - " __a=int\n", - " def __init__(self):\n", - " print \"Constructor\"\n", - " def __del__(self):\n", - " print \"Destructor\"\n", - "nameless() #nameless object created\n", - "n1=nameless()\n", - "n2=nameless()\n", - "print \"Program terminates\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor\n", - "Destructor\n", - "Constructor\n", - "Destructor\n", - "Constructor\n", - "Destructor\n", - "Program terminates\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-name.cpp, Page-411" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def show(self, msg):\n", - " print msg\n", - " print \"First Name: \", self._name__first\n", - " if self._name__middle[0]:\n", - " print \"Middle Name: \", self._name__middle\n", - " if self._name__last[0]:\n", - " print \"Last Name: \", self._name__last\n", - "class name:\n", - " __first=[None]*15\n", - " __middle=[None]*15\n", - " __last=[None]*15\n", - " def __init__(self, FirstName=None, MiddleName=None, LastName=None):\n", - " if isinstance(LastName, str):\n", - " self.__last=LastName\n", - " self.__middle=MiddleName\n", - " self.__first=FirstName\n", - " elif isinstance(MiddleName, str):\n", - " self.__middle=MiddleName\n", - " self.__first=FirstName\n", - " elif isinstance(FirstName, str):\n", - " self.__first=FirstName\n", - " else:\n", - " self.__last='\\0' #initialized to NULL\n", - " self.__middle='\\0'\n", - " self.__first='\\0'\n", - " show=show\n", - "n1=name()\n", - "n2=name()\n", - "n3=name()\n", - "n1=name(\"Rajkumar\")\n", - "n2=name(\"Savithri\", \"S\")\n", - "n3=name(\"Veugopal\", \"K\", \"R\")\n", - "n1.show(\"First prson details...\")\n", - "n2.show(\"Second prson details...\")\n", - "n3.show(\"Third prson details...\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "First prson details...\n", - "First Name: Rajkumar\n", - "Second prson details...\n", - "First Name: Savithri\n", - "Middle Name: S\n", - "Third prson details...\n", - "First Name: Veugopal\n", - "Middle Name: K\n", - "Last Name: R\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-vector1.cpp, Page-413" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def read(self):\n", - " for i in range(self._vector__sz):\n", - " print \"Enter vector [\", i, \"]? \",\n", - " self._vector__v[i]=int(raw_input())\n", - "def show_sum(self):\n", - " Sum=0\n", - " for i in range(self._vector__sz):\n", - " Sum+=self._vector__v[i]\n", - " print \"Vector sum= \", Sum\n", - "class vector:\n", - " __v=[int] #array of type integer\n", - " __sz=int\n", - " def __init__(self, size):\n", - " self.__sz= size\n", - " self.__v=[int]*size #dynamically allocating size to integer array\n", - " def __del__(self):\n", - " del self.__v\n", - " read=read\n", - " show_sum=show_sum\n", - "count = int\n", - "count=int(raw_input(\"How many elements are there in the vector: \"))\n", - "v1= vector(count)\n", - "v1.read()\n", - "v1.show_sum()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many elements are there in the vector: 5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter vector [ 0 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 1 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 2 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 3 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 4 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Vector sum= 15\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-vector2.cpp, Page-415" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def show(self):\n", - " for i in range(self._vector__size):\n", - " print self.elem(i), \", \",\n", - "class vector:\n", - " __v=[int]\n", - " __size=int\n", - " def __init__(self, vector_size):\n", - " if isinstance(vector_size, int):\n", - " self.__size= vector_size\n", - " self.__v=[int]*vector_size\n", - " else:\n", - " print \"Copy construcor invoked\"\n", - " self.__size=vector_size.__size\n", - " self.__v=[int]*vector_size.__size\n", - " for i in range(vector_size.__size):\n", - " self.__v[i]=vector_size.__v[i]\n", - " def elem(self,i):\n", - " if i>=self.__size:\n", - " print \"Error: Out of Range\"\n", - " return -1\n", - " return self.__v[i]\n", - " def __del__(self):\n", - " del self.__v\n", - " show=show\n", - "v1=vector(5)\n", - "v2=vector(5)\n", - "for i in range(5):\n", - " if v2.elem(i)!=-1:\n", - " v2._vector__v[i]=i+1\n", - "v1=v2\n", - "v3=vector(v2)\n", - "print \"Vector v1: \",\n", - "v1.show()\n", - "print \"\\nvector v2: \",\n", - "v2.show()\n", - "print \"\\nvector v3: \",\n", - "v3.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Copy construcor invoked\n", - "Vector v1: 1 , 2 , 3 , 4 , 5 , \n", - "vector v2: 1 , 2 , 3 , 4 , 5 , \n", - "vector v3: 1 , 2 , 3 , 4 , 5 , \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-matrix.cpp, Page-418" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "TRUE=1\n", - "FALSE=0\n", - "def __del__(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " del self._matrix__p[i]\n", - " del self._matrix__p\n", - "def add(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", - " print \"Error: invalid matrix order for addition\"\n", - " return\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " self._matrix__p[i][j]=a._matrix__p[i][j]+b._matrix__p[i][j]\n", - "def sub(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", - " print \"Error: invalid matrix order for subtraction\"\n", - " return\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " self._matrix__p[i][j]=a._matrix__p[i][j]-b._matrix__p[i][j]\n", - "def mul(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxCol!=b._matrix__MaxRow):\n", - " print \"Error: invalid matrix order for multiplication\"\n", - " return\n", - " for i in range(a._matrix__MaxRow):\n", - " for j in range(b._matrix__MaxCol):\n", - " self._matrix__p[i][j]=0\n", - " for k in range(a._matrix__MaxCol):\n", - " self._matrix__p[i][j]+=a._matrix__p[i][j]*b._matrix__p[i][j]\n", - "def eql(self, b):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " if self._matrix__p[i][i]!=b._matrix__p[i][j]:\n", - " return 0\n", - " return 1\n", - "def read(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " print \"Matrix[\", i, \",\",j,\"] =? \",\n", - " self._matrix__p[i][j]=int(raw_input())\n", - "def show(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " print self._matrix__p[i][j], \" \",\n", - " print \"\"\n", - "class matrix:\n", - " __MaxRow=int\n", - " __MaxCol=int\n", - " __p=[int]\n", - " def __init__(self, row=0, col=0):\n", - " self.__MaxRow=row\n", - " self.__MaxCol=col\n", - " if row>0:\n", - " self.__p=[[int]*self.__MaxCol]*self.__MaxRow\n", - " __del__=__del__\n", - " read=read\n", - " show=show\n", - " add=add\n", - " sub=sub\n", - " mul=mul\n", - " eql=eql\n", - "print \"Enter Matrix A details...\"\n", - "m=int(raw_input(\"How many rows? \"))\n", - "n=int(raw_input(\"How many columns? \"))\n", - "a=matrix(m,n)\n", - "a.read()\n", - "print \"Enter Matrix B details...\"\n", - "p=int(raw_input(\"How many rows? \"))\n", - "q=int(raw_input(\"How many columns? \"))\n", - "b=matrix(p,q)\n", - "b.read()\n", - "print \"Matrix A is...\"\n", - "a.show()\n", - "print \"Matrix B is...\"\n", - "b.show()\n", - "c=matrix(m,n)\n", - "c.add(a,b)\n", - "print \"C=A+B...\"\n", - "c.show()\n", - "d=matrix(m,n)\n", - "d.sub(a,b)\n", - "print \"D=A-B...\"\n", - "d.show()\n", - "e=matrix(m,q)\n", - "e.mul(a,b)\n", - "print \"E=A*B...\"\n", - "e.show()\n", - "print \"(Is matrix A equal to matrix B)? \",\n", - "if(a.eql(b)):\n", - " print \"Yes\"\n", - "else:\n", - " print \"No\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Matrix A details...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many rows? 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many columns? 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Matrix[ 0 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter Matrix B details...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many rows? 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many columns? 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Matrix[ 0 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix A is...\n", - "2 2 2 \n", - "2 2 2 \n", - "2 2 2 \n", - "Matrix B is...\n", - "1 1 1 \n", - "1 1 1 \n", - "1 1 1 \n", - "C=A+B...\n", - "3 3 3 \n", - "3 3 3 \n", - "3 3 3 \n", - "D=A-B...\n", - "1 1 1 \n", - "1 1 1 \n", - "1 1 1 \n", - "E=A*B...\n", - "6 6 6 \n", - "6 6 6 \n", - "6 6 6 \n", - "(Is matrix A equal to matrix B)? No\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-person.cpp, Page-423" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self, NameIn, AddressIn, PhoneIn):\n", - " self._Person__name=NameIn\n", - " self._Person__address=AddressIn\n", - " self._Person__phone=PhoneIn\n", - "#inline\n", - "def __del__(self):\n", - " del self._Person__name\n", - " del self._Person__address\n", - " del self._Person__phone\n", - "def getname(self):\n", - " return self._Person__name\n", - "def getaddress(self):\n", - " return self._Person__address\n", - "def getphone(self):\n", - " return self._Person__phone\n", - "def changename(self, NameIn):\n", - " if(self._Person__name):\n", - " del self._Person__name\n", - " self._Person__name=NameIn\n", - "class Person:\n", - " __name=[str]\n", - " __address=[str]\n", - " __phone=[str]\n", - " __init__=__init__\n", - " __del__=__del__\n", - " getname=getname\n", - " getaddress=getaddress\n", - " getphone=getphone\n", - " changename=changename\n", - "def printperson(p):\n", - " if(p.getname()):\n", - " print \"Name: \", p.getname()\n", - " if(p.getaddress()):\n", - " print \"Address: \", p.getaddress()\n", - " if(p.getphone()):\n", - " print \"Phone: \", p.getphone()\n", - "me=Person(\"Rajkumar\", \"E-mail: raj@cdabc.erne.in\", \"91-080-5584271\")\n", - "printperson(me)\n", - "you=Person(\"XYZ\", \"-not sure-\", \"-not sure-\")\n", - "print \"You XYZ by default...\"\n", - "printperson(you)\n", - "you.changename(\"ABC\")\n", - "print \"You changed XYZ to ABC...\"\n", - "printperson(you)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Rajkumar\n", - "Address: E-mail: raj@cdabc.erne.in\n", - "Phone: 91-080-5584271\n", - "You XYZ by default...\n", - "Name: XYZ\n", - "Address: -not sure-\n", - "Phone: -not sure-\n", - "You changed XYZ to ABC...\n", - "Name: ABC\n", - "Address: -not sure-\n", - "Phone: -not sure-\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-graph.cpp, Page-425" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " if(self._Graphics__nobjects[0]==False):\n", - " self._Graphics__setgraphicsmode()\n", - " self._Graphics__nobjects[0]+=1\n", - "def __del__(self):\n", - " self._Graphics__nobjects[0]-=1\n", - " if(self._Graphics__nobjects[0]==False):\n", - " self._Graphics__settextmode()\n", - "class Graphics:\n", - " __nobjects=[0]\n", - " def __setgraphicsmode(self):\n", - " pass\n", - " def __settextmode(self):\n", - " pass\n", - " __init__=__init__\n", - " __del__=__del__\n", - " def getcount(self):\n", - " return self.__nobjects[0]\n", - "def my_func():\n", - " obj=Graphics()\n", - " print \"No. of Graphics' objects while in my_func=\", obj.getcount()\n", - "obj1=Graphics()\n", - "print \"No. of Graphics' objects before in my_func=\", obj1.getcount()\n", - "my_func()\n", - "print \"No. of Graphics' objects after in my_func=\", obj1.getcount()\n", - "obj2=Graphics()\n", - "obj3=Graphics()\n", - "obj4=Graphics()\n", - "print \"Value of static member nobjects after all 3 more objects...\"\n", - "print \"In obj1= \", obj1.getcount()\n", - "print \"In obj2= \", obj2.getcount()\n", - "print \"In obj3= \", obj3.getcount()\n", - "print \"In obj4= \", obj4.getcount()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No. of Graphics' objects before in my_func= 1\n", - "No. of Graphics' objects while in my_func= 2\n", - "No. of Graphics' objects after in my_func= 1\n", - "Value of static member nobjects after all 3 more objects...\n", - "In obj1= 4\n", - "In obj2= 4\n", - "In obj3= 4\n", - "In obj4= 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example Page-428" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def distance(self, a, b):\n", - " self.x=a.x-b.x\n", - " self.y=a.y-b.y\n", - "def display(self):\n", - " print \"x= \",self.x\n", - " print \"y= \", self.y\n", - "class point:\n", - " __x=int\n", - " __y=int\n", - " def __init__(self, a=None, b=None):\n", - " if isinstance(a, int):\n", - " self.x=a\n", - " self.y=b\n", - " else:\n", - " self.x=self.y=0\n", - " def __del__(self):\n", - " pass\n", - " distance=distance\n", - " display=display\n", - "p1=point(40,18)\n", - "p2=point(12,9)\n", - "p3=point()\n", - "p3.distance(p1,p2)\n", - "print \"Coordinates of P1: \"\n", - "p1.display()\n", - "print \"Coordinates of P2: \"\n", - "p2.display()\n", - "print \"distance between P1 and P2: \"\n", - "p3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Coordinates of P1: \n", - "x= 40\n", - "y= 18\n", - "Coordinates of P2: \n", - "x= 12\n", - "y= 9\n", - "distance between P1 and P2: \n", - "x= 28\n", - "y= 9\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example Page-430" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def display(self):\n", - " print \"a =\", self.a,\n", - " print \"b =\", self.b\n", - "class data:\n", - " __a=int\n", - " __b=float\n", - " def __init__(self, x=None, y=None):\n", - " if isinstance(x, int):\n", - " self.a=x\n", - " self.b=y\n", - " elif isinstance(x, data):\n", - " self.a=x.a\n", - " self.b=x.b\n", - " else:\n", - " self.a=0\n", - " self.b=0\n", - " display=display\n", - "d1=data()\n", - "d2=data(12,9.9)\n", - "d3=data(d2)\n", - "print \"For default constructor: \"\n", - "d1.display()\n", - "print\"For parameterized constructor: \"\n", - "d2.display()\n", - "print \"For Copy Constructor: \"\n", - "d3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "For default constructor: \n", - "a = 0 b = 0\n", - "For parameterized constructor: \n", - "a = 12 b = 9.9\n", - "For Copy Constructor: \n", - "a = 12 b = 9.9\n" - ] - } - ], - "prompt_number": 1 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb b/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb deleted file mode 100755 index d3bdda01..00000000 --- a/sample_notebooks/SrutiGoyal/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb +++ /dev/null @@ -1,1779 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:64b755d597a2016634dadbbc81a598a60446119cc89f4f94fd9140b5bc077b77" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11: Object Initialization and clean up" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- bag.cpp, Page-392" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25\n", - "def show(self):\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS\n", - " __ItemCount=int\n", - " def SetEmpty(self):\n", - " self.ItemCount=0\n", - " def put(self,item):\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show\n", - "bag=Bag() #object of class Bag\n", - "bag.SetEmpty() #initialize the object\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag.put(item)\n", - " print \"Items in bag:\",\n", - " bag.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Items in bag: 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- newbag.cpp, Page-395" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25 #size of array contents\n", - "def show(self):\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS #int 1D array\n", - " __ItemCount=int\n", - " def __init__(self): #Constructor\n", - " self.ItemCount=0\n", - " def put(self,item): #member function defined inside the class\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show #member function defined outside the class\n", - "bag=Bag() #object of class Bag\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag.put(item)\n", - " print \"Items in bag:\",\n", - " bag.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Items in bag: 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag: 1 3 2 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test1.cpp, Page-396" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " print \"Constructor of class test called\"\n", - "class Test:\n", - " __init__=__init__ #Constructor\n", - "G=Test()\n", - "def func():\n", - " L=Test()\n", - " print \"Here's function func()\"\n", - "X=Test()\n", - "print \"main() function\"\n", - "func()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class test called\n", - "Constructor of class test called\n", - "main() function\n", - "Constructor of class test called\n", - "Here's function func()\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- giftbag.cpp, Page- 398" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "MAX_ITEMS=25\n", - "def show(self):\n", - " if self.ItemCount:\n", - " for i in range(self.ItemCount):\n", - " print self._Bag__contents[i],\n", - " else:\n", - " print \"Nil\"\n", - "class Bag:\n", - " __contents=[int]*MAX_ITEMS\n", - " __ItemCount=int\n", - " def __init__(self, item=None): #parameterized constructor: Python does not support overloading of functions\n", - " if isinstance(item, int):\n", - " self._Bag__contents[0]=item\n", - " self.ItemCount=1\n", - " else:\n", - " self.ItemCount=0\n", - " def put(self,item):\n", - " self._Bag__contents[self.ItemCount]=item\n", - " self.ItemCount+=1\n", - " show=show\n", - "bag1=Bag()\n", - "bag2=Bag(4) #object created using the parameterized constructor\n", - "print \"Gifted bag1 initially has:\",\n", - "bag1.show()\n", - "print \"Gifted bag2 initially has:\",\n", - "bag2.show()\n", - "while 1:\n", - " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", - " if item==0:\n", - " break\n", - " bag2.put(item)\n", - " print \"Items in bag2:\",\n", - " bag2.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Gifted bag1 initially has: Nil\n", - "Gifted bag2 initially has: 4" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1 2" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Items in bag2: 4 1 2 3" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "Enter Item Number to be put into the bag <0-no item>: 0\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test.cpp, Page-400 " - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " print \"Constructor of class Test called\"\n", - "def __del__(self):\n", - " print \"Destructor of class Test called\"\n", - "class Test:\n", - " __init__=__init__ #Constructor\n", - " __del__=__del__ #Destructor\n", - "x=Test()\n", - "print \"Terminating main\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor of class Test called\n", - "Destructor of class Test called\n", - "Terminating main\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-count.cpp, Page-401" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "nobjects=0\n", - "nobj_alive=0\n", - "class MyClass:\n", - " def __init__(self):\n", - " global nobjects #using the global nobjects\n", - " global nobj_alive #using the global nobj_alive\n", - " nobjects+=1\n", - " nobj_alive+=1\n", - " def __del__(self):\n", - " global nobj_alive #using the global nobjects\n", - " nobj_alive-=1\n", - " def show(self):\n", - " global nobjects\n", - " global nobj_alive\n", - " print \"Total number of objects created: \", nobjects\n", - " print \"Number of objects currently alive: \", nobj_alive\n", - "obj1=MyClass()\n", - "obj1.show()\n", - "def func():\n", - " obj1=MyClass()\n", - " obj2=MyClass()\n", - " obj2.show()\n", - " del obj1\n", - " del obj2\n", - "func()\n", - "obj1.show()\n", - "obj2=MyClass()\n", - "obj3=MyClass()\n", - "obj2.show()\n", - "del obj1\n", - "del obj2\n", - "del obj3" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Total number of objects created: 1\n", - "Number of objects currently alive: 1\n", - "Total number of objects created: 3\n", - "Number of objects currently alive: 3\n", - "Total number of objects created: 3\n", - "Number of objects currently alive: 1\n", - "Total number of objects created: 5\n", - "Number of objects currently alive: 3\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Example-account.cpp, Page- 403" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def MoneyTransfer(self, acc , amount):\n", - " self._AccClass__balance=self._AccClass__balance-amount\n", - " acc._AccClass__balance=acc._AccClass__balance + amount\n", - "class AccClass:\n", - " __accno=int\n", - " __balance=float\n", - " def __init__(self, an=None, bal=0.0):\n", - " if isinstance(an, int):\n", - " self.accno=an\n", - " self.__balance=bal\n", - " else:\n", - " self.accno=raw_input(\"Enter account number for acc1 object: \")\n", - " self.__balance=float(raw_input(\"Enter the balance: \"))\n", - " def display(self):\n", - " print \"Acoount number is: \", self.accno\n", - " print \"Balance is: \", self.__balance\n", - " MoneyTransfer=MoneyTransfer\n", - "acc1=AccClass()\n", - "acc2=AccClass(10)\n", - "acc3=AccClass(20, 750.5)\n", - "print \"Acoount information...\"\n", - "acc1.display()\n", - "acc2.display()\n", - "acc3.display()\n", - "trans_money=float(raw_input(\"How much money is to be transferred from acc3 to acc1: \"))\n", - "acc3.MoneyTransfer(acc1, trans_money)\n", - "print \"Updated information about accounts...\"\n", - "acc1.display()\n", - "acc2.display()\n", - "acc3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter account number for acc1 object: 1\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter the balance: 100\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Acoount information...\n", - "Acoount number is: 1\n", - "Balance is: 100.0\n", - "Acoount number is: 10\n", - "Balance is: 0.0\n", - "Acoount number is: 20\n", - "Balance is: 750.5\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How much money is to be transferred from acc3 to acc1: 200\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Updated information about accounts...\n", - "Acoount number is: 1\n", - "Balance is: 300.0\n", - "Acoount number is: 10\n", - "Balance is: 0.0\n", - "Acoount number is: 20\n", - "Balance is: 550.5\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-test2.cpp. Page- 405" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self, NameIn=None):\n", - " if isinstance(NameIn, str):\n", - " self.name=NameIn\n", - " print \"Test Object \", NameIn, \" created\"\n", - " else:\n", - " self.name=\"unnamed\"\n", - " print \"Test object 'unnamed' created\"\n", - "def __del__(self):\n", - " print \"Test Object \", self.name, \" destroyed\"\n", - " del self.name\n", - "class Test:\n", - " __name=[str]\n", - " __init__=__init__\n", - " __del__=__del__\n", - "g=Test(\"global\")\n", - "def func():\n", - " l=Test(\"func\")\n", - " print \"here's function func()\"\n", - "x=Test(\"main\")\n", - "func()\n", - "print \"main() function - termination\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Test Object global created\n", - "Test Object global destroyed\n", - "Test Object main created\n", - "Test Object main destroyed\n", - "Test Object func created\n", - "here's function func()\n", - "Test Object func destroyed\n", - "main() function - termination\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-complex1.cpp, Page- 407" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "def add (self, c2):\n", - " temp=Complex()\n", - " temp._Complex__real=self._Complex__real+c2._Complex__real\n", - " temp._Complex__imag=self._Complex__imag+c2._Complex__imag\n", - " return temp\n", - "class Complex:\n", - " __real=float\n", - " __imag=float\n", - " def __init__(self, real_in=None, imag_in=0.0):\n", - " if isinstance(real_in, float):\n", - " self.__real=real_in\n", - " self.__imag=imag_in\n", - " else:\n", - " self.__real=self.__imag=0.0\n", - " def show(self, msg):\n", - " print msg, \n", - " print self.__real,\n", - " if self.__imag<0:\n", - " print \"-i\",\n", - " else:\n", - " print \"+i\",\n", - " print math.fabs(self.__imag) #print absolute value\n", - " add=add\n", - "c1=Complex(1.5,2.0)\n", - "c2=Complex(2.2)\n", - "c3=Complex()\n", - "c1.show(\"c1=\")\n", - "c2.show(\"c2=\")\n", - "c3=c1.add(c2)\n", - "c3.show(\"c3=c1.add(c2):\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "c1= 1.5 +i 2.0\n", - "c2= 2.2 +i 0.0\n", - "c3=c1.add(c2): 3.7 +i 2.0\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example- noname.cpp, Page- 410" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class nameless:\n", - " __a=int\n", - " def __init__(self):\n", - " print \"Constructor\"\n", - " def __del__(self):\n", - " print \"Destructor\"\n", - "nameless() #nameless object created\n", - "n1=nameless()\n", - "n2=nameless()\n", - "print \"Program terminates\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Constructor\n", - "Destructor\n", - "Constructor\n", - "Destructor\n", - "Constructor\n", - "Destructor\n", - "Program terminates\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-name.cpp, Page-411" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def show(self, msg):\n", - " print msg\n", - " print \"First Name: \", self._name__first\n", - " if self._name__middle[0]:\n", - " print \"Middle Name: \", self._name__middle\n", - " if self._name__last[0]:\n", - " print \"Last Name: \", self._name__last\n", - "class name:\n", - " __first=[None]*15\n", - " __middle=[None]*15\n", - " __last=[None]*15\n", - " def __init__(self, FirstName=None, MiddleName=None, LastName=None):\n", - " if isinstance(LastName, str):\n", - " self.__last=LastName\n", - " self.__middle=MiddleName\n", - " self.__first=FirstName\n", - " elif isinstance(MiddleName, str):\n", - " self.__middle=MiddleName\n", - " self.__first=FirstName\n", - " elif isinstance(FirstName, str):\n", - " self.__first=FirstName\n", - " else:\n", - " self.__last='\\0' #initialized to NULL\n", - " self.__middle='\\0'\n", - " self.__first='\\0'\n", - " show=show\n", - "n1=name()\n", - "n2=name()\n", - "n3=name()\n", - "n1=name(\"Rajkumar\")\n", - "n2=name(\"Savithri\", \"S\")\n", - "n3=name(\"Veugopal\", \"K\", \"R\")\n", - "n1.show(\"First prson details...\")\n", - "n2.show(\"Second prson details...\")\n", - "n3.show(\"Third prson details...\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "First prson details...\n", - "First Name: Rajkumar\n", - "Second prson details...\n", - "First Name: Savithri\n", - "Middle Name: S\n", - "Third prson details...\n", - "First Name: Veugopal\n", - "Middle Name: K\n", - "Last Name: R\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-vector1.cpp, Page-413" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def read(self):\n", - " for i in range(self._vector__sz):\n", - " print \"Enter vector [\", i, \"]? \",\n", - " self._vector__v[i]=int(raw_input())\n", - "def show_sum(self):\n", - " Sum=0\n", - " for i in range(self._vector__sz):\n", - " Sum+=self._vector__v[i]\n", - " print \"Vector sum= \", Sum\n", - "class vector:\n", - " __v=[int] #array of type integer\n", - " __sz=int\n", - " def __init__(self, size):\n", - " self.__sz= size\n", - " self.__v=[int]*size #dynamically allocating size to integer array\n", - " def __del__(self):\n", - " del self.__v\n", - " read=read\n", - " show_sum=show_sum\n", - "count = int\n", - "count=int(raw_input(\"How many elements are there in the vector: \"))\n", - "v1= vector(count)\n", - "v1.read()\n", - "v1.show_sum()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many elements are there in the vector: 5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter vector [ 0 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 1 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 2 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 3 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "4\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter vector [ 4 ]? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "5\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Vector sum= 15\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-vector2.cpp, Page-415" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def show(self):\n", - " for i in range(self._vector__size):\n", - " print self.elem(i), \", \",\n", - "class vector:\n", - " __v=[int]\n", - " __size=int\n", - " def __init__(self, vector_size):\n", - " if isinstance(vector_size, int):\n", - " self.__size= vector_size\n", - " self.__v=[int]*vector_size\n", - " else:\n", - " print \"Copy construcor invoked\"\n", - " self.__size=vector_size.__size\n", - " self.__v=[int]*vector_size.__size\n", - " for i in range(vector_size.__size):\n", - " self.__v[i]=vector_size.__v[i]\n", - " def elem(self,i):\n", - " if i>=self.__size:\n", - " print \"Error: Out of Range\"\n", - " return -1\n", - " return self.__v[i]\n", - " def __del__(self):\n", - " del self.__v\n", - " show=show\n", - "v1=vector(5)\n", - "v2=vector(5)\n", - "for i in range(5):\n", - " if v2.elem(i)!=-1:\n", - " v2._vector__v[i]=i+1\n", - "v1=v2\n", - "v3=vector(v2)\n", - "print \"Vector v1: \",\n", - "v1.show()\n", - "print \"\\nvector v2: \",\n", - "v2.show()\n", - "print \"\\nvector v3: \",\n", - "v3.show()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Copy construcor invoked\n", - "Vector v1: 1 , 2 , 3 , 4 , 5 , \n", - "vector v2: 1 , 2 , 3 , 4 , 5 , \n", - "vector v3: 1 , 2 , 3 , 4 , 5 , \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-matrix.cpp, Page-418" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "TRUE=1\n", - "FALSE=0\n", - "def __del__(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " del self._matrix__p[i]\n", - " del self._matrix__p\n", - "def add(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", - " print \"Error: invalid matrix order for addition\"\n", - " return\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " self._matrix__p[i][j]=a._matrix__p[i][j]+b._matrix__p[i][j]\n", - "def sub(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", - " print \"Error: invalid matrix order for subtraction\"\n", - " return\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " self._matrix__p[i][j]=a._matrix__p[i][j]-b._matrix__p[i][j]\n", - "def mul(self, a, b):\n", - " self._matrix__MaxRow=a._matrix__MaxRow\n", - " self._matrix__MaxCol=a._matrix__MaxCol\n", - " if (a._matrix__MaxCol!=b._matrix__MaxRow):\n", - " print \"Error: invalid matrix order for multiplication\"\n", - " return\n", - " for i in range(a._matrix__MaxRow):\n", - " for j in range(b._matrix__MaxCol):\n", - " self._matrix__p[i][j]=0\n", - " for k in range(a._matrix__MaxCol):\n", - " self._matrix__p[i][j]+=a._matrix__p[i][j]*b._matrix__p[i][j]\n", - "def eql(self, b):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " if self._matrix__p[i][i]!=b._matrix__p[i][j]:\n", - " return 0\n", - " return 1\n", - "def read(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " print \"Matrix[\", i, \",\",j,\"] =? \",\n", - " self._matrix__p[i][j]=int(raw_input())\n", - "def show(self):\n", - " for i in range(self._matrix__MaxRow):\n", - " for j in range(self._matrix__MaxCol):\n", - " print self._matrix__p[i][j], \" \",\n", - " print \"\"\n", - "class matrix:\n", - " __MaxRow=int\n", - " __MaxCol=int\n", - " __p=[int]\n", - " def __init__(self, row=0, col=0):\n", - " self.__MaxRow=row\n", - " self.__MaxCol=col\n", - " if row>0:\n", - " self.__p=[[int]*self.__MaxCol]*self.__MaxRow\n", - " __del__=__del__\n", - " read=read\n", - " show=show\n", - " add=add\n", - " sub=sub\n", - " mul=mul\n", - " eql=eql\n", - "print \"Enter Matrix A details...\"\n", - "m=int(raw_input(\"How many rows? \"))\n", - "n=int(raw_input(\"How many columns? \"))\n", - "a=matrix(m,n)\n", - "a.read()\n", - "print \"Enter Matrix B details...\"\n", - "p=int(raw_input(\"How many rows? \"))\n", - "q=int(raw_input(\"How many columns? \"))\n", - "b=matrix(p,q)\n", - "b.read()\n", - "print \"Matrix A is...\"\n", - "a.show()\n", - "print \"Matrix B is...\"\n", - "b.show()\n", - "c=matrix(m,n)\n", - "c.add(a,b)\n", - "print \"C=A+B...\"\n", - "c.show()\n", - "d=matrix(m,n)\n", - "d.sub(a,b)\n", - "print \"D=A-B...\"\n", - "d.show()\n", - "e=matrix(m,q)\n", - "e.mul(a,b)\n", - "print \"E=A*B...\"\n", - "e.show()\n", - "print \"(Is matrix A equal to matrix B)? \",\n", - "if(a.eql(b)):\n", - " print \"Yes\"\n", - "else:\n", - " print \"No\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Enter Matrix A details...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many rows? 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many columns? 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Matrix[ 0 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "2\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Enter Matrix B details...\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many rows? 3\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "How many columns? 3\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Matrix[ 0 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 0 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 1 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 0 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 1 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix[ 2 , 2 ] =? " - ] - }, - { - "name": "stdout", - "output_type": "stream", - "stream": "stdout", - "text": [ - "1\n" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Matrix A is...\n", - "2 2 2 \n", - "2 2 2 \n", - "2 2 2 \n", - "Matrix B is...\n", - "1 1 1 \n", - "1 1 1 \n", - "1 1 1 \n", - "C=A+B...\n", - "3 3 3 \n", - "3 3 3 \n", - "3 3 3 \n", - "D=A-B...\n", - "1 1 1 \n", - "1 1 1 \n", - "1 1 1 \n", - "E=A*B...\n", - "6 6 6 \n", - "6 6 6 \n", - "6 6 6 \n", - "(Is matrix A equal to matrix B)? No\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-person.cpp, Page-423" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self, NameIn, AddressIn, PhoneIn):\n", - " self._Person__name=NameIn\n", - " self._Person__address=AddressIn\n", - " self._Person__phone=PhoneIn\n", - "#inline\n", - "def __del__(self):\n", - " del self._Person__name\n", - " del self._Person__address\n", - " del self._Person__phone\n", - "def getname(self):\n", - " return self._Person__name\n", - "def getaddress(self):\n", - " return self._Person__address\n", - "def getphone(self):\n", - " return self._Person__phone\n", - "def changename(self, NameIn):\n", - " if(self._Person__name):\n", - " del self._Person__name\n", - " self._Person__name=NameIn\n", - "class Person:\n", - " __name=[str]\n", - " __address=[str]\n", - " __phone=[str]\n", - " __init__=__init__\n", - " __del__=__del__\n", - " getname=getname\n", - " getaddress=getaddress\n", - " getphone=getphone\n", - " changename=changename\n", - "def printperson(p):\n", - " if(p.getname()):\n", - " print \"Name: \", p.getname()\n", - " if(p.getaddress()):\n", - " print \"Address: \", p.getaddress()\n", - " if(p.getphone()):\n", - " print \"Phone: \", p.getphone()\n", - "me=Person(\"Rajkumar\", \"E-mail: raj@cdabc.erne.in\", \"91-080-5584271\")\n", - "printperson(me)\n", - "you=Person(\"XYZ\", \"-not sure-\", \"-not sure-\")\n", - "print \"You XYZ by default...\"\n", - "printperson(you)\n", - "you.changename(\"ABC\")\n", - "print \"You changed XYZ to ABC...\"\n", - "printperson(you)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Name: Rajkumar\n", - "Address: E-mail: raj@cdabc.erne.in\n", - "Phone: 91-080-5584271\n", - "You XYZ by default...\n", - "Name: XYZ\n", - "Address: -not sure-\n", - "Phone: -not sure-\n", - "You changed XYZ to ABC...\n", - "Name: ABC\n", - "Address: -not sure-\n", - "Phone: -not sure-\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example-graph.cpp, Page-425" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def __init__(self):\n", - " if(self._Graphics__nobjects[0]==False):\n", - " self._Graphics__setgraphicsmode()\n", - " self._Graphics__nobjects[0]+=1\n", - "def __del__(self):\n", - " self._Graphics__nobjects[0]-=1\n", - " if(self._Graphics__nobjects[0]==False):\n", - " self._Graphics__settextmode()\n", - "class Graphics:\n", - " __nobjects=[0]\n", - " def __setgraphicsmode(self):\n", - " pass\n", - " def __settextmode(self):\n", - " pass\n", - " __init__=__init__\n", - " __del__=__del__\n", - " def getcount(self):\n", - " return self.__nobjects[0]\n", - "def my_func():\n", - " obj=Graphics()\n", - " print \"No. of Graphics' objects while in my_func=\", obj.getcount()\n", - "obj1=Graphics()\n", - "print \"No. of Graphics' objects before in my_func=\", obj1.getcount()\n", - "my_func()\n", - "print \"No. of Graphics' objects after in my_func=\", obj1.getcount()\n", - "obj2=Graphics()\n", - "obj3=Graphics()\n", - "obj4=Graphics()\n", - "print \"Value of static member nobjects after all 3 more objects...\"\n", - "print \"In obj1= \", obj1.getcount()\n", - "print \"In obj2= \", obj2.getcount()\n", - "print \"In obj3= \", obj3.getcount()\n", - "print \"In obj4= \", obj4.getcount()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No. of Graphics' objects before in my_func= 1\n", - "No. of Graphics' objects while in my_func= 2\n", - "No. of Graphics' objects after in my_func= 1\n", - "Value of static member nobjects after all 3 more objects...\n", - "In obj1= 4\n", - "In obj2= 4\n", - "In obj3= 4\n", - "In obj4= 4\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example Page-428" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def distance(self, a, b):\n", - " self.x=a.x-b.x\n", - " self.y=a.y-b.y\n", - "def display(self):\n", - " print \"x= \",self.x\n", - " print \"y= \", self.y\n", - "class point:\n", - " __x=int\n", - " __y=int\n", - " def __init__(self, a=None, b=None):\n", - " if isinstance(a, int):\n", - " self.x=a\n", - " self.y=b\n", - " else:\n", - " self.x=self.y=0\n", - " def __del__(self):\n", - " pass\n", - " distance=distance\n", - " display=display\n", - "p1=point(40,18)\n", - "p2=point(12,9)\n", - "p3=point()\n", - "p3.distance(p1,p2)\n", - "print \"Coordinates of P1: \"\n", - "p1.display()\n", - "print \"Coordinates of P2: \"\n", - "p2.display()\n", - "print \"distance between P1 and P2: \"\n", - "p3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Coordinates of P1: \n", - "x= 40\n", - "y= 18\n", - "Coordinates of P2: \n", - "x= 12\n", - "y= 9\n", - "distance between P1 and P2: \n", - "x= 28\n", - "y= 9\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example Page-430" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "def display(self):\n", - " print \"a =\", self.a,\n", - " print \"b =\", self.b\n", - "class data:\n", - " __a=int\n", - " __b=float\n", - " def __init__(self, x=None, y=None):\n", - " if isinstance(x, int):\n", - " self.a=x\n", - " self.b=y\n", - " elif isinstance(x, data):\n", - " self.a=x.a\n", - " self.b=x.b\n", - " else:\n", - " self.a=0\n", - " self.b=0\n", - " display=display\n", - "d1=data()\n", - "d2=data(12,9.9)\n", - "d3=data(d2)\n", - "print \"For default constructor: \"\n", - "d1.display()\n", - "print\"For parameterized constructor: \"\n", - "d2.display()\n", - "print \"For Copy Constructor: \"\n", - "d3.display()" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "For default constructor: \n", - "a = 0 b = 0\n", - "For parameterized constructor: \n", - "a = 12 b = 9.9\n", - "For Copy Constructor: \n", - "a = 12 b = 9.9\n" - ] - } - ], - "prompt_number": 1 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and.ipynb b/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and.ipynb new file mode 100755 index 00000000..d3bdda01 --- /dev/null +++ b/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and.ipynb @@ -0,0 +1,1779 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:64b755d597a2016634dadbbc81a598a60446119cc89f4f94fd9140b5bc077b77" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11: Object Initialization and clean up" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- bag.cpp, Page-392" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25\n", + "def show(self):\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS\n", + " __ItemCount=int\n", + " def SetEmpty(self):\n", + " self.ItemCount=0\n", + " def put(self,item):\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show\n", + "bag=Bag() #object of class Bag\n", + "bag.SetEmpty() #initialize the object\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag.put(item)\n", + " print \"Items in bag:\",\n", + " bag.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Items in bag: 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- newbag.cpp, Page-395" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25 #size of array contents\n", + "def show(self):\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS #int 1D array\n", + " __ItemCount=int\n", + " def __init__(self): #Constructor\n", + " self.ItemCount=0\n", + " def put(self,item): #member function defined inside the class\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show #member function defined outside the class\n", + "bag=Bag() #object of class Bag\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag.put(item)\n", + " print \"Items in bag:\",\n", + " bag.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Items in bag: 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test1.cpp, Page-396" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " print \"Constructor of class test called\"\n", + "class Test:\n", + " __init__=__init__ #Constructor\n", + "G=Test()\n", + "def func():\n", + " L=Test()\n", + " print \"Here's function func()\"\n", + "X=Test()\n", + "print \"main() function\"\n", + "func()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class test called\n", + "Constructor of class test called\n", + "main() function\n", + "Constructor of class test called\n", + "Here's function func()\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- giftbag.cpp, Page- 398" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25\n", + "def show(self):\n", + " if self.ItemCount:\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + " else:\n", + " print \"Nil\"\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS\n", + " __ItemCount=int\n", + " def __init__(self, item=None): #parameterized constructor: Python does not support overloading of functions\n", + " if isinstance(item, int):\n", + " self._Bag__contents[0]=item\n", + " self.ItemCount=1\n", + " else:\n", + " self.ItemCount=0\n", + " def put(self,item):\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show\n", + "bag1=Bag()\n", + "bag2=Bag(4) #object created using the parameterized constructor\n", + "print \"Gifted bag1 initially has:\",\n", + "bag1.show()\n", + "print \"Gifted bag2 initially has:\",\n", + "bag2.show()\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag2.put(item)\n", + " print \"Items in bag2:\",\n", + " bag2.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gifted bag1 initially has: Nil\n", + "Gifted bag2 initially has: 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1 2 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test.cpp, Page-400 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " print \"Constructor of class Test called\"\n", + "def __del__(self):\n", + " print \"Destructor of class Test called\"\n", + "class Test:\n", + " __init__=__init__ #Constructor\n", + " __del__=__del__ #Destructor\n", + "x=Test()\n", + "print \"Terminating main\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Test called\n", + "Destructor of class Test called\n", + "Terminating main\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-count.cpp, Page-401" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "nobjects=0\n", + "nobj_alive=0\n", + "class MyClass:\n", + " def __init__(self):\n", + " global nobjects #using the global nobjects\n", + " global nobj_alive #using the global nobj_alive\n", + " nobjects+=1\n", + " nobj_alive+=1\n", + " def __del__(self):\n", + " global nobj_alive #using the global nobjects\n", + " nobj_alive-=1\n", + " def show(self):\n", + " global nobjects\n", + " global nobj_alive\n", + " print \"Total number of objects created: \", nobjects\n", + " print \"Number of objects currently alive: \", nobj_alive\n", + "obj1=MyClass()\n", + "obj1.show()\n", + "def func():\n", + " obj1=MyClass()\n", + " obj2=MyClass()\n", + " obj2.show()\n", + " del obj1\n", + " del obj2\n", + "func()\n", + "obj1.show()\n", + "obj2=MyClass()\n", + "obj3=MyClass()\n", + "obj2.show()\n", + "del obj1\n", + "del obj2\n", + "del obj3" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total number of objects created: 1\n", + "Number of objects currently alive: 1\n", + "Total number of objects created: 3\n", + "Number of objects currently alive: 3\n", + "Total number of objects created: 3\n", + "Number of objects currently alive: 1\n", + "Total number of objects created: 5\n", + "Number of objects currently alive: 3\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example-account.cpp, Page- 403" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MoneyTransfer(self, acc , amount):\n", + " self._AccClass__balance=self._AccClass__balance-amount\n", + " acc._AccClass__balance=acc._AccClass__balance + amount\n", + "class AccClass:\n", + " __accno=int\n", + " __balance=float\n", + " def __init__(self, an=None, bal=0.0):\n", + " if isinstance(an, int):\n", + " self.accno=an\n", + " self.__balance=bal\n", + " else:\n", + " self.accno=raw_input(\"Enter account number for acc1 object: \")\n", + " self.__balance=float(raw_input(\"Enter the balance: \"))\n", + " def display(self):\n", + " print \"Acoount number is: \", self.accno\n", + " print \"Balance is: \", self.__balance\n", + " MoneyTransfer=MoneyTransfer\n", + "acc1=AccClass()\n", + "acc2=AccClass(10)\n", + "acc3=AccClass(20, 750.5)\n", + "print \"Acoount information...\"\n", + "acc1.display()\n", + "acc2.display()\n", + "acc3.display()\n", + "trans_money=float(raw_input(\"How much money is to be transferred from acc3 to acc1: \"))\n", + "acc3.MoneyTransfer(acc1, trans_money)\n", + "print \"Updated information about accounts...\"\n", + "acc1.display()\n", + "acc2.display()\n", + "acc3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter account number for acc1 object: 1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the balance: 100\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Acoount information...\n", + "Acoount number is: 1\n", + "Balance is: 100.0\n", + "Acoount number is: 10\n", + "Balance is: 0.0\n", + "Acoount number is: 20\n", + "Balance is: 750.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How much money is to be transferred from acc3 to acc1: 200\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Updated information about accounts...\n", + "Acoount number is: 1\n", + "Balance is: 300.0\n", + "Acoount number is: 10\n", + "Balance is: 0.0\n", + "Acoount number is: 20\n", + "Balance is: 550.5\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test2.cpp. Page- 405" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self, NameIn=None):\n", + " if isinstance(NameIn, str):\n", + " self.name=NameIn\n", + " print \"Test Object \", NameIn, \" created\"\n", + " else:\n", + " self.name=\"unnamed\"\n", + " print \"Test object 'unnamed' created\"\n", + "def __del__(self):\n", + " print \"Test Object \", self.name, \" destroyed\"\n", + " del self.name\n", + "class Test:\n", + " __name=[str]\n", + " __init__=__init__\n", + " __del__=__del__\n", + "g=Test(\"global\")\n", + "def func():\n", + " l=Test(\"func\")\n", + " print \"here's function func()\"\n", + "x=Test(\"main\")\n", + "func()\n", + "print \"main() function - termination\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Test Object global created\n", + "Test Object global destroyed\n", + "Test Object main created\n", + "Test Object main destroyed\n", + "Test Object func created\n", + "here's function func()\n", + "Test Object func destroyed\n", + "main() function - termination\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-complex1.cpp, Page- 407" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "def add (self, c2):\n", + " temp=Complex()\n", + " temp._Complex__real=self._Complex__real+c2._Complex__real\n", + " temp._Complex__imag=self._Complex__imag+c2._Complex__imag\n", + " return temp\n", + "class Complex:\n", + " __real=float\n", + " __imag=float\n", + " def __init__(self, real_in=None, imag_in=0.0):\n", + " if isinstance(real_in, float):\n", + " self.__real=real_in\n", + " self.__imag=imag_in\n", + " else:\n", + " self.__real=self.__imag=0.0\n", + " def show(self, msg):\n", + " print msg, \n", + " print self.__real,\n", + " if self.__imag<0:\n", + " print \"-i\",\n", + " else:\n", + " print \"+i\",\n", + " print math.fabs(self.__imag) #print absolute value\n", + " add=add\n", + "c1=Complex(1.5,2.0)\n", + "c2=Complex(2.2)\n", + "c3=Complex()\n", + "c1.show(\"c1=\")\n", + "c2.show(\"c2=\")\n", + "c3=c1.add(c2)\n", + "c3.show(\"c3=c1.add(c2):\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c1= 1.5 +i 2.0\n", + "c2= 2.2 +i 0.0\n", + "c3=c1.add(c2): 3.7 +i 2.0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- noname.cpp, Page- 410" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class nameless:\n", + " __a=int\n", + " def __init__(self):\n", + " print \"Constructor\"\n", + " def __del__(self):\n", + " print \"Destructor\"\n", + "nameless() #nameless object created\n", + "n1=nameless()\n", + "n2=nameless()\n", + "print \"Program terminates\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor\n", + "Destructor\n", + "Constructor\n", + "Destructor\n", + "Constructor\n", + "Destructor\n", + "Program terminates\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-name.cpp, Page-411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def show(self, msg):\n", + " print msg\n", + " print \"First Name: \", self._name__first\n", + " if self._name__middle[0]:\n", + " print \"Middle Name: \", self._name__middle\n", + " if self._name__last[0]:\n", + " print \"Last Name: \", self._name__last\n", + "class name:\n", + " __first=[None]*15\n", + " __middle=[None]*15\n", + " __last=[None]*15\n", + " def __init__(self, FirstName=None, MiddleName=None, LastName=None):\n", + " if isinstance(LastName, str):\n", + " self.__last=LastName\n", + " self.__middle=MiddleName\n", + " self.__first=FirstName\n", + " elif isinstance(MiddleName, str):\n", + " self.__middle=MiddleName\n", + " self.__first=FirstName\n", + " elif isinstance(FirstName, str):\n", + " self.__first=FirstName\n", + " else:\n", + " self.__last='\\0' #initialized to NULL\n", + " self.__middle='\\0'\n", + " self.__first='\\0'\n", + " show=show\n", + "n1=name()\n", + "n2=name()\n", + "n3=name()\n", + "n1=name(\"Rajkumar\")\n", + "n2=name(\"Savithri\", \"S\")\n", + "n3=name(\"Veugopal\", \"K\", \"R\")\n", + "n1.show(\"First prson details...\")\n", + "n2.show(\"Second prson details...\")\n", + "n3.show(\"Third prson details...\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "First prson details...\n", + "First Name: Rajkumar\n", + "Second prson details...\n", + "First Name: Savithri\n", + "Middle Name: S\n", + "Third prson details...\n", + "First Name: Veugopal\n", + "Middle Name: K\n", + "Last Name: R\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-vector1.cpp, Page-413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def read(self):\n", + " for i in range(self._vector__sz):\n", + " print \"Enter vector [\", i, \"]? \",\n", + " self._vector__v[i]=int(raw_input())\n", + "def show_sum(self):\n", + " Sum=0\n", + " for i in range(self._vector__sz):\n", + " Sum+=self._vector__v[i]\n", + " print \"Vector sum= \", Sum\n", + "class vector:\n", + " __v=[int] #array of type integer\n", + " __sz=int\n", + " def __init__(self, size):\n", + " self.__sz= size\n", + " self.__v=[int]*size #dynamically allocating size to integer array\n", + " def __del__(self):\n", + " del self.__v\n", + " read=read\n", + " show_sum=show_sum\n", + "count = int\n", + "count=int(raw_input(\"How many elements are there in the vector: \"))\n", + "v1= vector(count)\n", + "v1.read()\n", + "v1.show_sum()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many elements are there in the vector: 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter vector [ 0 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 1 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 2 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 3 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 4 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Vector sum= 15\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-vector2.cpp, Page-415" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def show(self):\n", + " for i in range(self._vector__size):\n", + " print self.elem(i), \", \",\n", + "class vector:\n", + " __v=[int]\n", + " __size=int\n", + " def __init__(self, vector_size):\n", + " if isinstance(vector_size, int):\n", + " self.__size= vector_size\n", + " self.__v=[int]*vector_size\n", + " else:\n", + " print \"Copy construcor invoked\"\n", + " self.__size=vector_size.__size\n", + " self.__v=[int]*vector_size.__size\n", + " for i in range(vector_size.__size):\n", + " self.__v[i]=vector_size.__v[i]\n", + " def elem(self,i):\n", + " if i>=self.__size:\n", + " print \"Error: Out of Range\"\n", + " return -1\n", + " return self.__v[i]\n", + " def __del__(self):\n", + " del self.__v\n", + " show=show\n", + "v1=vector(5)\n", + "v2=vector(5)\n", + "for i in range(5):\n", + " if v2.elem(i)!=-1:\n", + " v2._vector__v[i]=i+1\n", + "v1=v2\n", + "v3=vector(v2)\n", + "print \"Vector v1: \",\n", + "v1.show()\n", + "print \"\\nvector v2: \",\n", + "v2.show()\n", + "print \"\\nvector v3: \",\n", + "v3.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Copy construcor invoked\n", + "Vector v1: 1 , 2 , 3 , 4 , 5 , \n", + "vector v2: 1 , 2 , 3 , 4 , 5 , \n", + "vector v3: 1 , 2 , 3 , 4 , 5 , \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-matrix.cpp, Page-418" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "TRUE=1\n", + "FALSE=0\n", + "def __del__(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " del self._matrix__p[i]\n", + " del self._matrix__p\n", + "def add(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", + " print \"Error: invalid matrix order for addition\"\n", + " return\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " self._matrix__p[i][j]=a._matrix__p[i][j]+b._matrix__p[i][j]\n", + "def sub(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", + " print \"Error: invalid matrix order for subtraction\"\n", + " return\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " self._matrix__p[i][j]=a._matrix__p[i][j]-b._matrix__p[i][j]\n", + "def mul(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxCol!=b._matrix__MaxRow):\n", + " print \"Error: invalid matrix order for multiplication\"\n", + " return\n", + " for i in range(a._matrix__MaxRow):\n", + " for j in range(b._matrix__MaxCol):\n", + " self._matrix__p[i][j]=0\n", + " for k in range(a._matrix__MaxCol):\n", + " self._matrix__p[i][j]+=a._matrix__p[i][j]*b._matrix__p[i][j]\n", + "def eql(self, b):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " if self._matrix__p[i][i]!=b._matrix__p[i][j]:\n", + " return 0\n", + " return 1\n", + "def read(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " print \"Matrix[\", i, \",\",j,\"] =? \",\n", + " self._matrix__p[i][j]=int(raw_input())\n", + "def show(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " print self._matrix__p[i][j], \" \",\n", + " print \"\"\n", + "class matrix:\n", + " __MaxRow=int\n", + " __MaxCol=int\n", + " __p=[int]\n", + " def __init__(self, row=0, col=0):\n", + " self.__MaxRow=row\n", + " self.__MaxCol=col\n", + " if row>0:\n", + " self.__p=[[int]*self.__MaxCol]*self.__MaxRow\n", + " __del__=__del__\n", + " read=read\n", + " show=show\n", + " add=add\n", + " sub=sub\n", + " mul=mul\n", + " eql=eql\n", + "print \"Enter Matrix A details...\"\n", + "m=int(raw_input(\"How many rows? \"))\n", + "n=int(raw_input(\"How many columns? \"))\n", + "a=matrix(m,n)\n", + "a.read()\n", + "print \"Enter Matrix B details...\"\n", + "p=int(raw_input(\"How many rows? \"))\n", + "q=int(raw_input(\"How many columns? \"))\n", + "b=matrix(p,q)\n", + "b.read()\n", + "print \"Matrix A is...\"\n", + "a.show()\n", + "print \"Matrix B is...\"\n", + "b.show()\n", + "c=matrix(m,n)\n", + "c.add(a,b)\n", + "print \"C=A+B...\"\n", + "c.show()\n", + "d=matrix(m,n)\n", + "d.sub(a,b)\n", + "print \"D=A-B...\"\n", + "d.show()\n", + "e=matrix(m,q)\n", + "e.mul(a,b)\n", + "print \"E=A*B...\"\n", + "e.show()\n", + "print \"(Is matrix A equal to matrix B)? \",\n", + "if(a.eql(b)):\n", + " print \"Yes\"\n", + "else:\n", + " print \"No\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Matrix A details...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many rows? 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many columns? 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Matrix[ 0 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter Matrix B details...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many rows? 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many columns? 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Matrix[ 0 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix A is...\n", + "2 2 2 \n", + "2 2 2 \n", + "2 2 2 \n", + "Matrix B is...\n", + "1 1 1 \n", + "1 1 1 \n", + "1 1 1 \n", + "C=A+B...\n", + "3 3 3 \n", + "3 3 3 \n", + "3 3 3 \n", + "D=A-B...\n", + "1 1 1 \n", + "1 1 1 \n", + "1 1 1 \n", + "E=A*B...\n", + "6 6 6 \n", + "6 6 6 \n", + "6 6 6 \n", + "(Is matrix A equal to matrix B)? No\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-person.cpp, Page-423" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self, NameIn, AddressIn, PhoneIn):\n", + " self._Person__name=NameIn\n", + " self._Person__address=AddressIn\n", + " self._Person__phone=PhoneIn\n", + "#inline\n", + "def __del__(self):\n", + " del self._Person__name\n", + " del self._Person__address\n", + " del self._Person__phone\n", + "def getname(self):\n", + " return self._Person__name\n", + "def getaddress(self):\n", + " return self._Person__address\n", + "def getphone(self):\n", + " return self._Person__phone\n", + "def changename(self, NameIn):\n", + " if(self._Person__name):\n", + " del self._Person__name\n", + " self._Person__name=NameIn\n", + "class Person:\n", + " __name=[str]\n", + " __address=[str]\n", + " __phone=[str]\n", + " __init__=__init__\n", + " __del__=__del__\n", + " getname=getname\n", + " getaddress=getaddress\n", + " getphone=getphone\n", + " changename=changename\n", + "def printperson(p):\n", + " if(p.getname()):\n", + " print \"Name: \", p.getname()\n", + " if(p.getaddress()):\n", + " print \"Address: \", p.getaddress()\n", + " if(p.getphone()):\n", + " print \"Phone: \", p.getphone()\n", + "me=Person(\"Rajkumar\", \"E-mail: raj@cdabc.erne.in\", \"91-080-5584271\")\n", + "printperson(me)\n", + "you=Person(\"XYZ\", \"-not sure-\", \"-not sure-\")\n", + "print \"You XYZ by default...\"\n", + "printperson(you)\n", + "you.changename(\"ABC\")\n", + "print \"You changed XYZ to ABC...\"\n", + "printperson(you)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Rajkumar\n", + "Address: E-mail: raj@cdabc.erne.in\n", + "Phone: 91-080-5584271\n", + "You XYZ by default...\n", + "Name: XYZ\n", + "Address: -not sure-\n", + "Phone: -not sure-\n", + "You changed XYZ to ABC...\n", + "Name: ABC\n", + "Address: -not sure-\n", + "Phone: -not sure-\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-graph.cpp, Page-425" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " if(self._Graphics__nobjects[0]==False):\n", + " self._Graphics__setgraphicsmode()\n", + " self._Graphics__nobjects[0]+=1\n", + "def __del__(self):\n", + " self._Graphics__nobjects[0]-=1\n", + " if(self._Graphics__nobjects[0]==False):\n", + " self._Graphics__settextmode()\n", + "class Graphics:\n", + " __nobjects=[0]\n", + " def __setgraphicsmode(self):\n", + " pass\n", + " def __settextmode(self):\n", + " pass\n", + " __init__=__init__\n", + " __del__=__del__\n", + " def getcount(self):\n", + " return self.__nobjects[0]\n", + "def my_func():\n", + " obj=Graphics()\n", + " print \"No. of Graphics' objects while in my_func=\", obj.getcount()\n", + "obj1=Graphics()\n", + "print \"No. of Graphics' objects before in my_func=\", obj1.getcount()\n", + "my_func()\n", + "print \"No. of Graphics' objects after in my_func=\", obj1.getcount()\n", + "obj2=Graphics()\n", + "obj3=Graphics()\n", + "obj4=Graphics()\n", + "print \"Value of static member nobjects after all 3 more objects...\"\n", + "print \"In obj1= \", obj1.getcount()\n", + "print \"In obj2= \", obj2.getcount()\n", + "print \"In obj3= \", obj3.getcount()\n", + "print \"In obj4= \", obj4.getcount()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No. of Graphics' objects before in my_func= 1\n", + "No. of Graphics' objects while in my_func= 2\n", + "No. of Graphics' objects after in my_func= 1\n", + "Value of static member nobjects after all 3 more objects...\n", + "In obj1= 4\n", + "In obj2= 4\n", + "In obj3= 4\n", + "In obj4= 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example Page-428" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def distance(self, a, b):\n", + " self.x=a.x-b.x\n", + " self.y=a.y-b.y\n", + "def display(self):\n", + " print \"x= \",self.x\n", + " print \"y= \", self.y\n", + "class point:\n", + " __x=int\n", + " __y=int\n", + " def __init__(self, a=None, b=None):\n", + " if isinstance(a, int):\n", + " self.x=a\n", + " self.y=b\n", + " else:\n", + " self.x=self.y=0\n", + " def __del__(self):\n", + " pass\n", + " distance=distance\n", + " display=display\n", + "p1=point(40,18)\n", + "p2=point(12,9)\n", + "p3=point()\n", + "p3.distance(p1,p2)\n", + "print \"Coordinates of P1: \"\n", + "p1.display()\n", + "print \"Coordinates of P2: \"\n", + "p2.display()\n", + "print \"distance between P1 and P2: \"\n", + "p3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Coordinates of P1: \n", + "x= 40\n", + "y= 18\n", + "Coordinates of P2: \n", + "x= 12\n", + "y= 9\n", + "distance between P1 and P2: \n", + "x= 28\n", + "y= 9\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example Page-430" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def display(self):\n", + " print \"a =\", self.a,\n", + " print \"b =\", self.b\n", + "class data:\n", + " __a=int\n", + " __b=float\n", + " def __init__(self, x=None, y=None):\n", + " if isinstance(x, int):\n", + " self.a=x\n", + " self.b=y\n", + " elif isinstance(x, data):\n", + " self.a=x.a\n", + " self.b=x.b\n", + " else:\n", + " self.a=0\n", + " self.b=0\n", + " display=display\n", + "d1=data()\n", + "d2=data(12,9.9)\n", + "d3=data(d2)\n", + "print \"For default constructor: \"\n", + "d1.display()\n", + "print\"For parameterized constructor: \"\n", + "d2.display()\n", + "print \"For Copy Constructor: \"\n", + "d3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For default constructor: \n", + "a = 0 b = 0\n", + "For parameterized constructor: \n", + "a = 12 b = 9.9\n", + "For Copy Constructor: \n", + "a = 12 b = 9.9\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb b/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb new file mode 100755 index 00000000..d3bdda01 --- /dev/null +++ b/sample_notebooks/SrutiGoyal/SrutiGoyal_version_backup/Chapter_11-_Object_Initialization_and_Clean-Up_1.ipynb @@ -0,0 +1,1779 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:64b755d597a2016634dadbbc81a598a60446119cc89f4f94fd9140b5bc077b77" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11: Object Initialization and clean up" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- bag.cpp, Page-392" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25\n", + "def show(self):\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS\n", + " __ItemCount=int\n", + " def SetEmpty(self):\n", + " self.ItemCount=0\n", + " def put(self,item):\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show\n", + "bag=Bag() #object of class Bag\n", + "bag.SetEmpty() #initialize the object\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag.put(item)\n", + " print \"Items in bag:\",\n", + " bag.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Items in bag: 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- newbag.cpp, Page-395" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25 #size of array contents\n", + "def show(self):\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS #int 1D array\n", + " __ItemCount=int\n", + " def __init__(self): #Constructor\n", + " self.ItemCount=0\n", + " def put(self,item): #member function defined inside the class\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show #member function defined outside the class\n", + "bag=Bag() #object of class Bag\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag.put(item)\n", + " print \"Items in bag:\",\n", + " bag.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Items in bag: 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag: 1 3 2 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test1.cpp, Page-396" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " print \"Constructor of class test called\"\n", + "class Test:\n", + " __init__=__init__ #Constructor\n", + "G=Test()\n", + "def func():\n", + " L=Test()\n", + " print \"Here's function func()\"\n", + "X=Test()\n", + "print \"main() function\"\n", + "func()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class test called\n", + "Constructor of class test called\n", + "main() function\n", + "Constructor of class test called\n", + "Here's function func()\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- giftbag.cpp, Page- 398" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "MAX_ITEMS=25\n", + "def show(self):\n", + " if self.ItemCount:\n", + " for i in range(self.ItemCount):\n", + " print self._Bag__contents[i],\n", + " else:\n", + " print \"Nil\"\n", + "class Bag:\n", + " __contents=[int]*MAX_ITEMS\n", + " __ItemCount=int\n", + " def __init__(self, item=None): #parameterized constructor: Python does not support overloading of functions\n", + " if isinstance(item, int):\n", + " self._Bag__contents[0]=item\n", + " self.ItemCount=1\n", + " else:\n", + " self.ItemCount=0\n", + " def put(self,item):\n", + " self._Bag__contents[self.ItemCount]=item\n", + " self.ItemCount+=1\n", + " show=show\n", + "bag1=Bag()\n", + "bag2=Bag(4) #object created using the parameterized constructor\n", + "print \"Gifted bag1 initially has:\",\n", + "bag1.show()\n", + "print \"Gifted bag2 initially has:\",\n", + "bag2.show()\n", + "while 1:\n", + " item=int(raw_input(\"\\nEnter Item Number to be put into the bag <0-no item>: \"))\n", + " if item==0:\n", + " break\n", + " bag2.put(item)\n", + " print \"Items in bag2:\",\n", + " bag2.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Gifted bag1 initially has: Nil\n", + "Gifted bag2 initially has: 4" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1 2" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Items in bag2: 4 1 2 3" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "Enter Item Number to be put into the bag <0-no item>: 0\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test.cpp, Page-400 " + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " print \"Constructor of class Test called\"\n", + "def __del__(self):\n", + " print \"Destructor of class Test called\"\n", + "class Test:\n", + " __init__=__init__ #Constructor\n", + " __del__=__del__ #Destructor\n", + "x=Test()\n", + "print \"Terminating main\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor of class Test called\n", + "Destructor of class Test called\n", + "Terminating main\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-count.cpp, Page-401" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "nobjects=0\n", + "nobj_alive=0\n", + "class MyClass:\n", + " def __init__(self):\n", + " global nobjects #using the global nobjects\n", + " global nobj_alive #using the global nobj_alive\n", + " nobjects+=1\n", + " nobj_alive+=1\n", + " def __del__(self):\n", + " global nobj_alive #using the global nobjects\n", + " nobj_alive-=1\n", + " def show(self):\n", + " global nobjects\n", + " global nobj_alive\n", + " print \"Total number of objects created: \", nobjects\n", + " print \"Number of objects currently alive: \", nobj_alive\n", + "obj1=MyClass()\n", + "obj1.show()\n", + "def func():\n", + " obj1=MyClass()\n", + " obj2=MyClass()\n", + " obj2.show()\n", + " del obj1\n", + " del obj2\n", + "func()\n", + "obj1.show()\n", + "obj2=MyClass()\n", + "obj3=MyClass()\n", + "obj2.show()\n", + "del obj1\n", + "del obj2\n", + "del obj3" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Total number of objects created: 1\n", + "Number of objects currently alive: 1\n", + "Total number of objects created: 3\n", + "Number of objects currently alive: 3\n", + "Total number of objects created: 3\n", + "Number of objects currently alive: 1\n", + "Total number of objects created: 5\n", + "Number of objects currently alive: 3\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Example-account.cpp, Page- 403" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def MoneyTransfer(self, acc , amount):\n", + " self._AccClass__balance=self._AccClass__balance-amount\n", + " acc._AccClass__balance=acc._AccClass__balance + amount\n", + "class AccClass:\n", + " __accno=int\n", + " __balance=float\n", + " def __init__(self, an=None, bal=0.0):\n", + " if isinstance(an, int):\n", + " self.accno=an\n", + " self.__balance=bal\n", + " else:\n", + " self.accno=raw_input(\"Enter account number for acc1 object: \")\n", + " self.__balance=float(raw_input(\"Enter the balance: \"))\n", + " def display(self):\n", + " print \"Acoount number is: \", self.accno\n", + " print \"Balance is: \", self.__balance\n", + " MoneyTransfer=MoneyTransfer\n", + "acc1=AccClass()\n", + "acc2=AccClass(10)\n", + "acc3=AccClass(20, 750.5)\n", + "print \"Acoount information...\"\n", + "acc1.display()\n", + "acc2.display()\n", + "acc3.display()\n", + "trans_money=float(raw_input(\"How much money is to be transferred from acc3 to acc1: \"))\n", + "acc3.MoneyTransfer(acc1, trans_money)\n", + "print \"Updated information about accounts...\"\n", + "acc1.display()\n", + "acc2.display()\n", + "acc3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter account number for acc1 object: 1\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the balance: 100\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Acoount information...\n", + "Acoount number is: 1\n", + "Balance is: 100.0\n", + "Acoount number is: 10\n", + "Balance is: 0.0\n", + "Acoount number is: 20\n", + "Balance is: 750.5\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How much money is to be transferred from acc3 to acc1: 200\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Updated information about accounts...\n", + "Acoount number is: 1\n", + "Balance is: 300.0\n", + "Acoount number is: 10\n", + "Balance is: 0.0\n", + "Acoount number is: 20\n", + "Balance is: 550.5\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-test2.cpp. Page- 405" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self, NameIn=None):\n", + " if isinstance(NameIn, str):\n", + " self.name=NameIn\n", + " print \"Test Object \", NameIn, \" created\"\n", + " else:\n", + " self.name=\"unnamed\"\n", + " print \"Test object 'unnamed' created\"\n", + "def __del__(self):\n", + " print \"Test Object \", self.name, \" destroyed\"\n", + " del self.name\n", + "class Test:\n", + " __name=[str]\n", + " __init__=__init__\n", + " __del__=__del__\n", + "g=Test(\"global\")\n", + "def func():\n", + " l=Test(\"func\")\n", + " print \"here's function func()\"\n", + "x=Test(\"main\")\n", + "func()\n", + "print \"main() function - termination\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Test Object global created\n", + "Test Object global destroyed\n", + "Test Object main created\n", + "Test Object main destroyed\n", + "Test Object func created\n", + "here's function func()\n", + "Test Object func destroyed\n", + "main() function - termination\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-complex1.cpp, Page- 407" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "def add (self, c2):\n", + " temp=Complex()\n", + " temp._Complex__real=self._Complex__real+c2._Complex__real\n", + " temp._Complex__imag=self._Complex__imag+c2._Complex__imag\n", + " return temp\n", + "class Complex:\n", + " __real=float\n", + " __imag=float\n", + " def __init__(self, real_in=None, imag_in=0.0):\n", + " if isinstance(real_in, float):\n", + " self.__real=real_in\n", + " self.__imag=imag_in\n", + " else:\n", + " self.__real=self.__imag=0.0\n", + " def show(self, msg):\n", + " print msg, \n", + " print self.__real,\n", + " if self.__imag<0:\n", + " print \"-i\",\n", + " else:\n", + " print \"+i\",\n", + " print math.fabs(self.__imag) #print absolute value\n", + " add=add\n", + "c1=Complex(1.5,2.0)\n", + "c2=Complex(2.2)\n", + "c3=Complex()\n", + "c1.show(\"c1=\")\n", + "c2.show(\"c2=\")\n", + "c3=c1.add(c2)\n", + "c3.show(\"c3=c1.add(c2):\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "c1= 1.5 +i 2.0\n", + "c2= 2.2 +i 0.0\n", + "c3=c1.add(c2): 3.7 +i 2.0\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example- noname.cpp, Page- 410" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class nameless:\n", + " __a=int\n", + " def __init__(self):\n", + " print \"Constructor\"\n", + " def __del__(self):\n", + " print \"Destructor\"\n", + "nameless() #nameless object created\n", + "n1=nameless()\n", + "n2=nameless()\n", + "print \"Program terminates\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Constructor\n", + "Destructor\n", + "Constructor\n", + "Destructor\n", + "Constructor\n", + "Destructor\n", + "Program terminates\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-name.cpp, Page-411" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def show(self, msg):\n", + " print msg\n", + " print \"First Name: \", self._name__first\n", + " if self._name__middle[0]:\n", + " print \"Middle Name: \", self._name__middle\n", + " if self._name__last[0]:\n", + " print \"Last Name: \", self._name__last\n", + "class name:\n", + " __first=[None]*15\n", + " __middle=[None]*15\n", + " __last=[None]*15\n", + " def __init__(self, FirstName=None, MiddleName=None, LastName=None):\n", + " if isinstance(LastName, str):\n", + " self.__last=LastName\n", + " self.__middle=MiddleName\n", + " self.__first=FirstName\n", + " elif isinstance(MiddleName, str):\n", + " self.__middle=MiddleName\n", + " self.__first=FirstName\n", + " elif isinstance(FirstName, str):\n", + " self.__first=FirstName\n", + " else:\n", + " self.__last='\\0' #initialized to NULL\n", + " self.__middle='\\0'\n", + " self.__first='\\0'\n", + " show=show\n", + "n1=name()\n", + "n2=name()\n", + "n3=name()\n", + "n1=name(\"Rajkumar\")\n", + "n2=name(\"Savithri\", \"S\")\n", + "n3=name(\"Veugopal\", \"K\", \"R\")\n", + "n1.show(\"First prson details...\")\n", + "n2.show(\"Second prson details...\")\n", + "n3.show(\"Third prson details...\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "First prson details...\n", + "First Name: Rajkumar\n", + "Second prson details...\n", + "First Name: Savithri\n", + "Middle Name: S\n", + "Third prson details...\n", + "First Name: Veugopal\n", + "Middle Name: K\n", + "Last Name: R\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-vector1.cpp, Page-413" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def read(self):\n", + " for i in range(self._vector__sz):\n", + " print \"Enter vector [\", i, \"]? \",\n", + " self._vector__v[i]=int(raw_input())\n", + "def show_sum(self):\n", + " Sum=0\n", + " for i in range(self._vector__sz):\n", + " Sum+=self._vector__v[i]\n", + " print \"Vector sum= \", Sum\n", + "class vector:\n", + " __v=[int] #array of type integer\n", + " __sz=int\n", + " def __init__(self, size):\n", + " self.__sz= size\n", + " self.__v=[int]*size #dynamically allocating size to integer array\n", + " def __del__(self):\n", + " del self.__v\n", + " read=read\n", + " show_sum=show_sum\n", + "count = int\n", + "count=int(raw_input(\"How many elements are there in the vector: \"))\n", + "v1= vector(count)\n", + "v1.read()\n", + "v1.show_sum()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many elements are there in the vector: 5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter vector [ 0 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 1 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 2 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 3 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "4\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter vector [ 4 ]? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "5\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Vector sum= 15\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-vector2.cpp, Page-415" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def show(self):\n", + " for i in range(self._vector__size):\n", + " print self.elem(i), \", \",\n", + "class vector:\n", + " __v=[int]\n", + " __size=int\n", + " def __init__(self, vector_size):\n", + " if isinstance(vector_size, int):\n", + " self.__size= vector_size\n", + " self.__v=[int]*vector_size\n", + " else:\n", + " print \"Copy construcor invoked\"\n", + " self.__size=vector_size.__size\n", + " self.__v=[int]*vector_size.__size\n", + " for i in range(vector_size.__size):\n", + " self.__v[i]=vector_size.__v[i]\n", + " def elem(self,i):\n", + " if i>=self.__size:\n", + " print \"Error: Out of Range\"\n", + " return -1\n", + " return self.__v[i]\n", + " def __del__(self):\n", + " del self.__v\n", + " show=show\n", + "v1=vector(5)\n", + "v2=vector(5)\n", + "for i in range(5):\n", + " if v2.elem(i)!=-1:\n", + " v2._vector__v[i]=i+1\n", + "v1=v2\n", + "v3=vector(v2)\n", + "print \"Vector v1: \",\n", + "v1.show()\n", + "print \"\\nvector v2: \",\n", + "v2.show()\n", + "print \"\\nvector v3: \",\n", + "v3.show()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Copy construcor invoked\n", + "Vector v1: 1 , 2 , 3 , 4 , 5 , \n", + "vector v2: 1 , 2 , 3 , 4 , 5 , \n", + "vector v3: 1 , 2 , 3 , 4 , 5 , \n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-matrix.cpp, Page-418" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "TRUE=1\n", + "FALSE=0\n", + "def __del__(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " del self._matrix__p[i]\n", + " del self._matrix__p\n", + "def add(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", + " print \"Error: invalid matrix order for addition\"\n", + " return\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " self._matrix__p[i][j]=a._matrix__p[i][j]+b._matrix__p[i][j]\n", + "def sub(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxRow!=b._matrix__MaxRow)|(a._matrix__MaxCol!=b._matrix__MaxCol):\n", + " print \"Error: invalid matrix order for subtraction\"\n", + " return\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " self._matrix__p[i][j]=a._matrix__p[i][j]-b._matrix__p[i][j]\n", + "def mul(self, a, b):\n", + " self._matrix__MaxRow=a._matrix__MaxRow\n", + " self._matrix__MaxCol=a._matrix__MaxCol\n", + " if (a._matrix__MaxCol!=b._matrix__MaxRow):\n", + " print \"Error: invalid matrix order for multiplication\"\n", + " return\n", + " for i in range(a._matrix__MaxRow):\n", + " for j in range(b._matrix__MaxCol):\n", + " self._matrix__p[i][j]=0\n", + " for k in range(a._matrix__MaxCol):\n", + " self._matrix__p[i][j]+=a._matrix__p[i][j]*b._matrix__p[i][j]\n", + "def eql(self, b):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " if self._matrix__p[i][i]!=b._matrix__p[i][j]:\n", + " return 0\n", + " return 1\n", + "def read(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " print \"Matrix[\", i, \",\",j,\"] =? \",\n", + " self._matrix__p[i][j]=int(raw_input())\n", + "def show(self):\n", + " for i in range(self._matrix__MaxRow):\n", + " for j in range(self._matrix__MaxCol):\n", + " print self._matrix__p[i][j], \" \",\n", + " print \"\"\n", + "class matrix:\n", + " __MaxRow=int\n", + " __MaxCol=int\n", + " __p=[int]\n", + " def __init__(self, row=0, col=0):\n", + " self.__MaxRow=row\n", + " self.__MaxCol=col\n", + " if row>0:\n", + " self.__p=[[int]*self.__MaxCol]*self.__MaxRow\n", + " __del__=__del__\n", + " read=read\n", + " show=show\n", + " add=add\n", + " sub=sub\n", + " mul=mul\n", + " eql=eql\n", + "print \"Enter Matrix A details...\"\n", + "m=int(raw_input(\"How many rows? \"))\n", + "n=int(raw_input(\"How many columns? \"))\n", + "a=matrix(m,n)\n", + "a.read()\n", + "print \"Enter Matrix B details...\"\n", + "p=int(raw_input(\"How many rows? \"))\n", + "q=int(raw_input(\"How many columns? \"))\n", + "b=matrix(p,q)\n", + "b.read()\n", + "print \"Matrix A is...\"\n", + "a.show()\n", + "print \"Matrix B is...\"\n", + "b.show()\n", + "c=matrix(m,n)\n", + "c.add(a,b)\n", + "print \"C=A+B...\"\n", + "c.show()\n", + "d=matrix(m,n)\n", + "d.sub(a,b)\n", + "print \"D=A-B...\"\n", + "d.show()\n", + "e=matrix(m,q)\n", + "e.mul(a,b)\n", + "print \"E=A*B...\"\n", + "e.show()\n", + "print \"(Is matrix A equal to matrix B)? \",\n", + "if(a.eql(b)):\n", + " print \"Yes\"\n", + "else:\n", + " print \"No\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Matrix A details...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many rows? 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many columns? 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Matrix[ 0 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "2\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Enter Matrix B details...\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many rows? 3\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "How many columns? 3\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Matrix[ 0 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 0 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 1 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 0 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 1 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix[ 2 , 2 ] =? " + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "1\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Matrix A is...\n", + "2 2 2 \n", + "2 2 2 \n", + "2 2 2 \n", + "Matrix B is...\n", + "1 1 1 \n", + "1 1 1 \n", + "1 1 1 \n", + "C=A+B...\n", + "3 3 3 \n", + "3 3 3 \n", + "3 3 3 \n", + "D=A-B...\n", + "1 1 1 \n", + "1 1 1 \n", + "1 1 1 \n", + "E=A*B...\n", + "6 6 6 \n", + "6 6 6 \n", + "6 6 6 \n", + "(Is matrix A equal to matrix B)? No\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-person.cpp, Page-423" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self, NameIn, AddressIn, PhoneIn):\n", + " self._Person__name=NameIn\n", + " self._Person__address=AddressIn\n", + " self._Person__phone=PhoneIn\n", + "#inline\n", + "def __del__(self):\n", + " del self._Person__name\n", + " del self._Person__address\n", + " del self._Person__phone\n", + "def getname(self):\n", + " return self._Person__name\n", + "def getaddress(self):\n", + " return self._Person__address\n", + "def getphone(self):\n", + " return self._Person__phone\n", + "def changename(self, NameIn):\n", + " if(self._Person__name):\n", + " del self._Person__name\n", + " self._Person__name=NameIn\n", + "class Person:\n", + " __name=[str]\n", + " __address=[str]\n", + " __phone=[str]\n", + " __init__=__init__\n", + " __del__=__del__\n", + " getname=getname\n", + " getaddress=getaddress\n", + " getphone=getphone\n", + " changename=changename\n", + "def printperson(p):\n", + " if(p.getname()):\n", + " print \"Name: \", p.getname()\n", + " if(p.getaddress()):\n", + " print \"Address: \", p.getaddress()\n", + " if(p.getphone()):\n", + " print \"Phone: \", p.getphone()\n", + "me=Person(\"Rajkumar\", \"E-mail: raj@cdabc.erne.in\", \"91-080-5584271\")\n", + "printperson(me)\n", + "you=Person(\"XYZ\", \"-not sure-\", \"-not sure-\")\n", + "print \"You XYZ by default...\"\n", + "printperson(you)\n", + "you.changename(\"ABC\")\n", + "print \"You changed XYZ to ABC...\"\n", + "printperson(you)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Name: Rajkumar\n", + "Address: E-mail: raj@cdabc.erne.in\n", + "Phone: 91-080-5584271\n", + "You XYZ by default...\n", + "Name: XYZ\n", + "Address: -not sure-\n", + "Phone: -not sure-\n", + "You changed XYZ to ABC...\n", + "Name: ABC\n", + "Address: -not sure-\n", + "Phone: -not sure-\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example-graph.cpp, Page-425" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def __init__(self):\n", + " if(self._Graphics__nobjects[0]==False):\n", + " self._Graphics__setgraphicsmode()\n", + " self._Graphics__nobjects[0]+=1\n", + "def __del__(self):\n", + " self._Graphics__nobjects[0]-=1\n", + " if(self._Graphics__nobjects[0]==False):\n", + " self._Graphics__settextmode()\n", + "class Graphics:\n", + " __nobjects=[0]\n", + " def __setgraphicsmode(self):\n", + " pass\n", + " def __settextmode(self):\n", + " pass\n", + " __init__=__init__\n", + " __del__=__del__\n", + " def getcount(self):\n", + " return self.__nobjects[0]\n", + "def my_func():\n", + " obj=Graphics()\n", + " print \"No. of Graphics' objects while in my_func=\", obj.getcount()\n", + "obj1=Graphics()\n", + "print \"No. of Graphics' objects before in my_func=\", obj1.getcount()\n", + "my_func()\n", + "print \"No. of Graphics' objects after in my_func=\", obj1.getcount()\n", + "obj2=Graphics()\n", + "obj3=Graphics()\n", + "obj4=Graphics()\n", + "print \"Value of static member nobjects after all 3 more objects...\"\n", + "print \"In obj1= \", obj1.getcount()\n", + "print \"In obj2= \", obj2.getcount()\n", + "print \"In obj3= \", obj3.getcount()\n", + "print \"In obj4= \", obj4.getcount()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No. of Graphics' objects before in my_func= 1\n", + "No. of Graphics' objects while in my_func= 2\n", + "No. of Graphics' objects after in my_func= 1\n", + "Value of static member nobjects after all 3 more objects...\n", + "In obj1= 4\n", + "In obj2= 4\n", + "In obj3= 4\n", + "In obj4= 4\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example Page-428" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def distance(self, a, b):\n", + " self.x=a.x-b.x\n", + " self.y=a.y-b.y\n", + "def display(self):\n", + " print \"x= \",self.x\n", + " print \"y= \", self.y\n", + "class point:\n", + " __x=int\n", + " __y=int\n", + " def __init__(self, a=None, b=None):\n", + " if isinstance(a, int):\n", + " self.x=a\n", + " self.y=b\n", + " else:\n", + " self.x=self.y=0\n", + " def __del__(self):\n", + " pass\n", + " distance=distance\n", + " display=display\n", + "p1=point(40,18)\n", + "p2=point(12,9)\n", + "p3=point()\n", + "p3.distance(p1,p2)\n", + "print \"Coordinates of P1: \"\n", + "p1.display()\n", + "print \"Coordinates of P2: \"\n", + "p2.display()\n", + "print \"distance between P1 and P2: \"\n", + "p3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Coordinates of P1: \n", + "x= 40\n", + "y= 18\n", + "Coordinates of P2: \n", + "x= 12\n", + "y= 9\n", + "distance between P1 and P2: \n", + "x= 28\n", + "y= 9\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example Page-430" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def display(self):\n", + " print \"a =\", self.a,\n", + " print \"b =\", self.b\n", + "class data:\n", + " __a=int\n", + " __b=float\n", + " def __init__(self, x=None, y=None):\n", + " if isinstance(x, int):\n", + " self.a=x\n", + " self.b=y\n", + " elif isinstance(x, data):\n", + " self.a=x.a\n", + " self.b=x.b\n", + " else:\n", + " self.a=0\n", + " self.b=0\n", + " display=display\n", + "d1=data()\n", + "d2=data(12,9.9)\n", + "d3=data(d2)\n", + "print \"For default constructor: \"\n", + "d1.display()\n", + "print\"For parameterized constructor: \"\n", + "d2.display()\n", + "print \"For Copy Constructor: \"\n", + "d3.display()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "For default constructor: \n", + "a = 0 b = 0\n", + "For parameterized constructor: \n", + "a = 12 b = 9.9\n", + "For Copy Constructor: \n", + "a = 12 b = 9.9\n" + ] + } + ], + "prompt_number": 1 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/SudheerBommisetty/Chapter_4_Op_Amps_as_AC_Amplifiers.ipynb b/sample_notebooks/SudheerBommisetty/Chapter_4_Op_Amps_as_AC_Amplifiers.ipynb deleted file mode 100755 index 42bcd226..00000000 --- a/sample_notebooks/SudheerBommisetty/Chapter_4_Op_Amps_as_AC_Amplifiers.ipynb +++ /dev/null @@ -1,363 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4 Op Amps as AC Amplifiers" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.1 page.no: 65" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1max= 140000.0\n", - "Xc1=R1/10 at F1\n", - "C1= 2.65258238486e-07 farad\n", - "C2= 8.16179195343e-07 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "# capacitor coupled voltage follower design \n", - "from math import pi\n", - "\n", - "Vbe =0.7\n", - "Ibmax =500*10**-9\n", - "R1max=0.1* Vbe/ Ibmax\n", - "print \"R1max= \",R1max\n", - "# assume R1=120Kohms\n", - "R1=120000\n", - "f1=50\n", - "print \"Xc1=R1/10 at F1\"\n", - "# C1=1/(2∗pi∗f1∗(R1/10))\n", - "C1=1/(2*pi*f1*(R1/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "Rl=3900\n", - "C2=1/(2*pi*f1*Rl)\n", - "print \"C2=\",C2,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.2 page.no: 66" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "C1= 3.18309886184e-08 farad\n", - "C2= 8.16179195343e-07 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "# capacitor coupled voltage follower design using BIFET \n", - "from math import pi\n", - "\n", - "R1 =1000000\n", - "f1=50\n", - "C1=1/(2*pi*f1*(R1/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "Rl=3900\n", - "C2=1/(2*pi*f1*Rl)\n", - "print \"C2=\",C2,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.3 page.no: 68" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "C1= 4.681027738e-07 farad\n", - "C2= 4.681027738e-07 farad\n", - "Zin= 3400068000 ohms\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "#capacitor coupled voltage follower design \n", - "from math import pi \n", - "\n", - "Vbe =0.7\n", - "Ibmax =500*10**-9\n", - "R1max=0.1* Vbe/ Ibmax\n", - "R1=R1max/2\n", - "R2=R1\n", - "R1=68000\n", - "f1=50\n", - "C1=1/(2*pi*f1*(R1/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "C2=C1\n", - "print \"C2=\",C2,\" farad\"\n", - "Rl=3900\n", - "M=50000\n", - "Zin=(1+M)*R1\n", - "print \"Zin= \",Zin,\"ohms\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.4 page.no: 69" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "C1= 1.10524266036e-07 farad\n", - "C2= 6.02859632924e-07 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "#capacitor coupled non inverting amplifier design \n", - "#lower cut off frequency for the circuit =120Hz\n", - "from math import pi\n", - "\n", - "Vbe =0.7\n", - "Ibmax =500*10**-9\n", - "R1max=0.1* Vbe/ Ibmax\n", - "R1=120000\n", - "f1=120\n", - "C1=1/(2*pi*f1*(R1/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "Rl=2200\n", - "C2=1/(2*pi*f1*Rl)\n", - "print \"C2=\",C2,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.5 page.no: 69" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1= 994974.874372\n", - "C2= 1.58359168376e-07 farad\n", - "C1=1000pF much larger than stray capacitance\n", - "C2= 6.63145596216e-07 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "#capacitor coupled non inverting high impedence follower design \n", - "#lower cut off frequency for the circuit =200Hz \n", - "from math import pi\n", - "\n", - "Vo=3\n", - "Vi=0.015\n", - "Av=Vo/Vi\n", - "R2 =1000000\n", - "R3=R2/(Av-1)\n", - "f1=200\n", - "R1=R2-R3\n", - "print\"R1=\",R1\n", - "C2=1/(2*pi*f1*(R3))\n", - "print \"C2=\",C2,\" farad\"\n", - "print \"C1=1000pF much larger than stray capacitance\"\n", - "Rl=12000\n", - "C2=1/(2*pi*f1*(Rl/10))\n", - "print \"C2=\",C2,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.6 page.no: 71" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "C1= 0.000159154943092 farad\n", - "C2= 6.36619772368e-05 farad\n", - "Cf= 3.38627538493e-07 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "#capacitor coupled inverting amplifier design \n", - "#frequency range for the circuit =10Hz to 1KHz\n", - "from math import pi\n", - "R1 =1000\n", - "f1=10\n", - "C1=1/(2*pi*f1*(R1/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "Rl=250\n", - "C2=1/(2*pi*f1*Rl)\n", - "print \"C2=\",C2,\" farad\"\n", - "R2=47000\n", - "Cf=1/(2*pi*f1*R2)\n", - "print \"Cf=\",Cf,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## exa 4.7 page.no: 72" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R1= 240000.0 ohms\n", - "R2= 240000.0 ohms\n", - "R4= 1000.0 ohms\n", - "R3= 99000.0 ohms\n", - "Rp= 114782.608696 ohms\n", - "C1= 1.84876954097e-07 farad\n", - "C2= 3.78940340695e-06 farad\n", - "C3= 2.12206590789e-06 farad\n", - "The circuit voltage should be normally between 9 to 18 volts\n" - ] - } - ], - "source": [ - "#capacitor coupled non design\n", - "from math import pi\n", - "\n", - "Av =100.\n", - "Vcc =24.\n", - "Vo=5.\n", - "#lower cut off frequency for the circuit =75Hz\n", - "Vbe=0.7\n", - "Ibmax =500*10**-9\n", - "#I2>>Ibmax\n", - "I2 =100* Ibmax\n", - "R1=(Vcc/2)/I2\n", - "print\"R1=\",R1,\" ohms\"\n", - "R2=(Vcc/2)/I2\n", - "print\"R2=\",R2,\" ohms\"\n", - "#assume R1=220Kohms\n", - "Vi=Vo/Av\n", - "R1=220000.\n", - "I4 =100* Ibmax\n", - "R4=Vi/I4\n", - "print\"R4=\",R4,\" ohms\"\n", - "R3=(Vo/I4)-R4\n", - "print\"R3=\",R3,\" ohms\"\n", - "Rp=(R1*R2)/(R1+R2)\n", - "print\"Rp=\",Rp,\" ohms\"\n", - "f1=75.\n", - "C1=1/(2*pi*f1*(Rp/10))\n", - "print \"C1=\",C1,\" farad\"\n", - "Rl=5600.\n", - "C2=1/(2*pi*f1*(Rl/10))\n", - "print \"C2=\",C2,\" farad\"\n", - "C3=1/(2*pi*f1*R4)\n", - "print \"C3=\",C3,\" farad\"\n", - "print \"The circuit voltage should be normally between 9 to 18 volts\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SudheerBommisetty/SudheerBommisetty_version_backup/Chapter_4_Op_Amps_as_AC.ipynb b/sample_notebooks/SudheerBommisetty/SudheerBommisetty_version_backup/Chapter_4_Op_Amps_as_AC.ipynb new file mode 100755 index 00000000..42bcd226 --- /dev/null +++ b/sample_notebooks/SudheerBommisetty/SudheerBommisetty_version_backup/Chapter_4_Op_Amps_as_AC.ipynb @@ -0,0 +1,363 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4 Op Amps as AC Amplifiers" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.1 page.no: 65" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1max= 140000.0\n", + "Xc1=R1/10 at F1\n", + "C1= 2.65258238486e-07 farad\n", + "C2= 8.16179195343e-07 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "# capacitor coupled voltage follower design \n", + "from math import pi\n", + "\n", + "Vbe =0.7\n", + "Ibmax =500*10**-9\n", + "R1max=0.1* Vbe/ Ibmax\n", + "print \"R1max= \",R1max\n", + "# assume R1=120Kohms\n", + "R1=120000\n", + "f1=50\n", + "print \"Xc1=R1/10 at F1\"\n", + "# C1=1/(2∗pi∗f1∗(R1/10))\n", + "C1=1/(2*pi*f1*(R1/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "Rl=3900\n", + "C2=1/(2*pi*f1*Rl)\n", + "print \"C2=\",C2,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.2 page.no: 66" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C1= 3.18309886184e-08 farad\n", + "C2= 8.16179195343e-07 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "# capacitor coupled voltage follower design using BIFET \n", + "from math import pi\n", + "\n", + "R1 =1000000\n", + "f1=50\n", + "C1=1/(2*pi*f1*(R1/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "Rl=3900\n", + "C2=1/(2*pi*f1*Rl)\n", + "print \"C2=\",C2,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.3 page.no: 68" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C1= 4.681027738e-07 farad\n", + "C2= 4.681027738e-07 farad\n", + "Zin= 3400068000 ohms\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "#capacitor coupled voltage follower design \n", + "from math import pi \n", + "\n", + "Vbe =0.7\n", + "Ibmax =500*10**-9\n", + "R1max=0.1* Vbe/ Ibmax\n", + "R1=R1max/2\n", + "R2=R1\n", + "R1=68000\n", + "f1=50\n", + "C1=1/(2*pi*f1*(R1/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "C2=C1\n", + "print \"C2=\",C2,\" farad\"\n", + "Rl=3900\n", + "M=50000\n", + "Zin=(1+M)*R1\n", + "print \"Zin= \",Zin,\"ohms\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.4 page.no: 69" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C1= 1.10524266036e-07 farad\n", + "C2= 6.02859632924e-07 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "#capacitor coupled non inverting amplifier design \n", + "#lower cut off frequency for the circuit =120Hz\n", + "from math import pi\n", + "\n", + "Vbe =0.7\n", + "Ibmax =500*10**-9\n", + "R1max=0.1* Vbe/ Ibmax\n", + "R1=120000\n", + "f1=120\n", + "C1=1/(2*pi*f1*(R1/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "Rl=2200\n", + "C2=1/(2*pi*f1*Rl)\n", + "print \"C2=\",C2,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.5 page.no: 69" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1= 994974.874372\n", + "C2= 1.58359168376e-07 farad\n", + "C1=1000pF much larger than stray capacitance\n", + "C2= 6.63145596216e-07 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "#capacitor coupled non inverting high impedence follower design \n", + "#lower cut off frequency for the circuit =200Hz \n", + "from math import pi\n", + "\n", + "Vo=3\n", + "Vi=0.015\n", + "Av=Vo/Vi\n", + "R2 =1000000\n", + "R3=R2/(Av-1)\n", + "f1=200\n", + "R1=R2-R3\n", + "print\"R1=\",R1\n", + "C2=1/(2*pi*f1*(R3))\n", + "print \"C2=\",C2,\" farad\"\n", + "print \"C1=1000pF much larger than stray capacitance\"\n", + "Rl=12000\n", + "C2=1/(2*pi*f1*(Rl/10))\n", + "print \"C2=\",C2,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.6 page.no: 71" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "C1= 0.000159154943092 farad\n", + "C2= 6.36619772368e-05 farad\n", + "Cf= 3.38627538493e-07 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "#capacitor coupled inverting amplifier design \n", + "#frequency range for the circuit =10Hz to 1KHz\n", + "from math import pi\n", + "R1 =1000\n", + "f1=10\n", + "C1=1/(2*pi*f1*(R1/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "Rl=250\n", + "C2=1/(2*pi*f1*Rl)\n", + "print \"C2=\",C2,\" farad\"\n", + "R2=47000\n", + "Cf=1/(2*pi*f1*R2)\n", + "print \"Cf=\",Cf,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## exa 4.7 page.no: 72" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R1= 240000.0 ohms\n", + "R2= 240000.0 ohms\n", + "R4= 1000.0 ohms\n", + "R3= 99000.0 ohms\n", + "Rp= 114782.608696 ohms\n", + "C1= 1.84876954097e-07 farad\n", + "C2= 3.78940340695e-06 farad\n", + "C3= 2.12206590789e-06 farad\n", + "The circuit voltage should be normally between 9 to 18 volts\n" + ] + } + ], + "source": [ + "#capacitor coupled non design\n", + "from math import pi\n", + "\n", + "Av =100.\n", + "Vcc =24.\n", + "Vo=5.\n", + "#lower cut off frequency for the circuit =75Hz\n", + "Vbe=0.7\n", + "Ibmax =500*10**-9\n", + "#I2>>Ibmax\n", + "I2 =100* Ibmax\n", + "R1=(Vcc/2)/I2\n", + "print\"R1=\",R1,\" ohms\"\n", + "R2=(Vcc/2)/I2\n", + "print\"R2=\",R2,\" ohms\"\n", + "#assume R1=220Kohms\n", + "Vi=Vo/Av\n", + "R1=220000.\n", + "I4 =100* Ibmax\n", + "R4=Vi/I4\n", + "print\"R4=\",R4,\" ohms\"\n", + "R3=(Vo/I4)-R4\n", + "print\"R3=\",R3,\" ohms\"\n", + "Rp=(R1*R2)/(R1+R2)\n", + "print\"Rp=\",Rp,\" ohms\"\n", + "f1=75.\n", + "C1=1/(2*pi*f1*(Rp/10))\n", + "print \"C1=\",C1,\" farad\"\n", + "Rl=5600.\n", + "C2=1/(2*pi*f1*(Rl/10))\n", + "print \"C2=\",C2,\" farad\"\n", + "C3=1/(2*pi*f1*R4)\n", + "print \"C3=\",C3,\" farad\"\n", + "print \"The circuit voltage should be normally between 9 to 18 volts\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/ch2.ipynb b/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/ch2.ipynb new file mode 100644 index 00000000..b2b163f6 --- /dev/null +++ b/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/ch2.ipynb @@ -0,0 +1,507 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 - Truncation Errors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example: 2.1 Page No:29" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of f at x=0 : 1.2\n", + "The value of f at x=1 due to zero order approximation : 1.2\n", + "Truncation error : -1.0\n", + "----------------------------------------------\n", + "The value of first derivative of f at x=0 : -0.4\n", + "The value of f at x=1 due to first order approximation : 0.8\n", + "Truncation error : -0.6\n", + "----------------------------------------------\n", + "The value of second derivative of f at x=0 : -1.8\n", + "The value of f at x=1 due to second order approximation : -0.1\n", + "Truncation error : 0.3\n", + "----------------------------------------------\n", + "The value of third derivative of f at x=0 : -0.9\n", + "The value of f at x=1 due to third order approximation : -0.25\n", + "Truncation error : 0.45\n", + "----------------------------------------------\n", + "The value of fourth derivative of f at x=0 : -2.4\n", + "The value of f at x=1 due to fourth order approximation : -0.35\n", + "Truncation error : 0.55\n" + ] + } + ], + "source": [ + "from math import factorial\n", + "from scipy.misc import derivative\n", + "def f(x):\n", + " y=-0.1*x**4-0.15*x**3-0.5*x**2-0.25*x+1.2#\n", + " return y\n", + "xi=0#\n", + "xf=1#\n", + "h=xf-xi#\n", + "fi=f(xi)##function value at xi\n", + "ffa=f(xf)##actual function value at xf\n", + "\n", + "#for n=0, i.e, zero order approximation\n", + "ff=fi#\n", + "Et_1=ffa-ff##truncation error at x=1\n", + "print \"The value of f at x=0 :\",fi\n", + "print \"The value of f at x=1 due to zero order approximation :\",ff\n", + "print \"Truncation error :\",Et_1\n", + "print \"----------------------------------------------\"\n", + "\n", + "#for n=1, i.e, first order approximation\n", + "def f1(x):\n", + " y=derivative(f,x)\n", + " return y\n", + "f1i=f1(xi)##value of first derivative of function at xi\n", + "f1f=fi+f1i*h##value of first derivative of function at xf\n", + "Et_2=ffa-f1f##truncation error at x=1\n", + "print \"The value of first derivative of f at x=0 :\",f1i\n", + "print \"The value of f at x=1 due to first order approximation :\",f1f\n", + "print \"Truncation error :\",Et_2\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=2, i.e, second order approximation\n", + "def f2(x):\n", + " y=derivative(f1,x)\n", + " return y\n", + "f2i=f2(xi)##value of second derivative of function at xi\n", + "f2f=f1f+f2i*(h**2)/factorial(2)##value of second derivative of function at xf\n", + "Et_3=ffa-f2f##truncation error at x=1\n", + "print \"The value of second derivative of f at x=0 :\",f2i\n", + "print \"The value of f at x=1 due to second order approximation :\",f2f\n", + "print \"Truncation error :\",Et_3\n", + "print \"----------------------------------------------\"\n", + "\n", + "#for n=3, i.e, third order approximation\n", + "def f3(x):\n", + " y=derivative(f2,x)\n", + " return y\n", + "f3i=f3(xi)##value of third derivative of function at xi\n", + "f3f=f2f+f3i*(h**3)/factorial(3)##value of third derivative of function at xf\n", + "Et_4=ffa-f3f##truncation error at x=1\n", + "print \"The value of third derivative of f at x=0 :\",f3i\n", + "print \"The value of f at x=1 due to third order approximation :\",f3f\n", + "print \"Truncation error :\", Et_4\n", + "print \"----------------------------------------------\"\n", + "\n", + "#for n=4, i.e, fourth order approximation\n", + "def f4(x):\n", + " y=derivative(f3,x)\n", + " return y\n", + "f4i=f4(xi)##value of fourth derivative of function at xi\n", + "f4f=f3f+f4i*(h**4)/factorial(4)##value of fourth derivative of function at xf\n", + "Et_5=ffa-f4f##truncation error at x=1\n", + "print \"The value of fourth derivative of f at x=0 :\",f4i\n", + "print \"The value of f at x=1 due to fourth order approximation :\",f4f\n", + "print \"Truncation error :\",Et_5" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2: Page No:32" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of f at x=1 due to zero order approximation : 0.707106781187\n", + "% relative error : -41.4213562373\n", + "----------------------------------------------\n", + "The value of f at x=1 due to first order approximation : 0.551333569463\n", + "% relative error : -10.2667138927\n", + "----------------------------------------------\n", + "The value of f at x=1 due to second order approximation : 0.534175415889\n", + "% relative error : -6.83508317772\n", + "----------------------------------------------\n", + "The value of f at x=1 due to third order approximation : 0.535435376789\n", + "% relative error : -7.08707535775\n", + "----------------------------------------------\n", + "The value of f at x=1 due to fourth order approximation : 0.535504768061\n", + "% relative error : -7.10095361216\n", + "----------------------------------------------\n", + "The value of f at x=1 due to fifth order approximation : 0.535501917392\n", + "% relative error : -7.10038347839\n", + "----------------------------------------------\n", + "The value of f at x=1 due to sixth order approximation : 0.535501819651\n", + "% relative error : -7.10036393016\n" + ] + } + ], + "source": [ + "from math import pi,cos,factorial\n", + "from scipy.misc import derivative\n", + "def f(x):\n", + " y=cos(x)\n", + " return y\n", + "xi=pi/4#\n", + "xf=pi/3#\n", + "h=xf-xi#\n", + "fi=f(xi)##function value at xi\n", + "ffa=f(xf)##actual function value at xf\n", + "\n", + "#for n=0, i.e, zero order approximation\n", + "ff=fi#\n", + "et1=(ffa-ff)*100/ffa##percent relative error at x=1\n", + "print \"The value of f at x=1 due to zero order approximation :\",ff\n", + "print \"% relative error :\",et1\n", + "print \"----------------------------------------------\"\n", + "\n", + "#for n=1, i.e, first order approximation\n", + "def f1(x):\n", + " y=derivative(f,x)\n", + " return y\n", + "f1i=f1(xi)##value of first derivative of function at xi\n", + "f1f=fi+f1i*h##value of first derivative of function at xf\n", + "et2=(ffa-f1f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to first order approximation :\",f1f\n", + "print \"% relative error :\",et2\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=2, i.e, second order approximation\n", + "def f2(x):\n", + " y=derivative(f1,x)\n", + " return y\n", + "f2i=f2(xi)##value of second derivative of function at xi\n", + "f2f=f1f+f2i*(h**2)/factorial(2)##value of second derivative of function at xf\n", + "et3=(ffa-f2f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to second order approximation :\",f2f\n", + "print \"% relative error :\",et3\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=3, i.e, third order approximation\n", + "def f3(x):\n", + " y=derivative(f2,x)\n", + " return y\n", + "f3i=f3(xi)##value of third derivative of function at xi\n", + "f3f=f2f+f3i*(h**3)/factorial(3)##value of third derivative of function at xf\n", + "et4=(ffa-f3f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to third order approximation :\",f3f\n", + "print \"% relative error :\",et4\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=4, i.e, fourth order approximation\n", + "def f4(x):\n", + " y=derivative(f3,x)\n", + " return y\n", + "f4i=f4(xi)##value of fourth derivative of function at xi\n", + "f4f=f3f+f4i*(h**4)/factorial(4)##value of fourth derivative of function at xf\n", + "et5=(ffa-f4f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to fourth order approximation :\",f4f\n", + "print \"% relative error :\",et5\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=5, i.e, fifth order approximation\n", + "f5i=(f4(1.1*xi)-f4(0.9*xi))/(2*0.1)##value of fifth derivative of function at xi (central difference method)\n", + "f5f=f4f+f5i*(h**5)/factorial(5)##value of fifth derivative of function at xf\n", + "et6=(ffa-f5f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to fifth order approximation :\",f5f\n", + "print \"% relative error :\",et6\n", + "print \"----------------------------------------------\"\n", + "\n", + "\n", + "#for n=6, i.e, sixth order approximation\n", + "def f6(x):\n", + " y=derivative(f5,x)\n", + " return y\n", + "f6i=(f4(1.1*xi)-2*f4(xi)+f4(0.9*xi))/(0.1**2)##value of sixth derivative of function at xi (central difference method)\n", + "f6f=f5f+f6i*(h**6)/factorial(6)##value of sixth derivative of function at xf\n", + "et6=(ffa-f6f)*100/ffa##% relative error at x=1\n", + "print \"The value of f at x=1 due to sixth order approximation :\",f6f\n", + "print \"% relative error :\", et6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3 : Page No:35" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Remainder: 21 \n", + "The value by first order approximation: 1275\n", + "True Value at x2: 1296\n" + ] + } + ], + "source": [ + "from math import pi,cos,factorial\n", + "m=4# Input value of m\n", + "h=5# Input value of h\n", + "def f(x):\n", + " y=x**m\n", + " return y\n", + "x1=1#\n", + "x2=x1+h#\n", + "fx1=f(x1)#\n", + "fx2=fx1+m*(fx1**(m-1))*h#\n", + "if m==1:\n", + " R=0#\n", + "elif m==2 :\n", + " R=2*(h**2)/factorial(2)#\n", + " \n", + "elif m==3:\n", + " R=(6*(x1)*(h**2)/factorial(2))+(6*(h**3)/factorial(3))#\n", + " \n", + "elif m==4:\n", + " R=(12*(x1**2)*(h**2)/factorial(2))+(24*(x1)*(h**3)/factorial(3))+(24*(h**4)/factorial(4))\n", + " \n", + "print \"\\nRemainder:\",fx2,\"\\nThe value by first order approximation:\",R\n", + "print \"True Value at x2:\",f(x2)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4: Page No:42" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "For h= 1.232323\n", + "and percent error= -2.70944264922 Derivative at x by forward difference method= 114.60931875\n", + "and percent error= -0.178591334206 Derivative at x by backward difference method= 85.854151746\n", + "and percent error= -1.44401699172 Derivative at x by central difference method= 14.3775835022\n" + ] + } + ], + "source": [ + "from scipy.misc import derivative\n", + "def f(x):\n", + " y=-0.1*(x**4)-0.15*(x**3)-0.5*(x**2)-0.25*(x)+1.2\n", + " return y\n", + "x=0.5#\n", + "h=1.232323 # Input h\n", + "x1=x-h#\n", + "x2=x+h#\n", + "#forward difference method\n", + "fdx1=(f(x2)-f(x))/h##derivative at x\n", + "et1=abs((fdx1-derivative(f,x))/derivative(f,x))*100#\n", + "#backward difference method\n", + "fdx2=(f(x)-f(x1))/h##derivative at x\n", + "et2=abs((fdx2-derivative(f,x))/derivative(f,x))*100#\n", + "#central difference method\n", + "fdx3=(f(x2)-f(x1))/(2*h)##derivative at x\n", + "et3=abs((fdx3-derivative(f,x))/derivative(f,x))*100#\n", + "print \"For h=\",h\n", + "print \"and percent error=\",fdx1,\"Derivative at x by forward difference method=\",et1\n", + "print \"and percent error=\",fdx2,\"Derivative at x by backward difference method=\",et2\n", + "print \"and percent error=\",fdx3,\"Derivative at x by central difference method=\",et3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.5: Page No: 45" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "true value is between : 15.4275 and 15.8225\n" + ] + } + ], + "source": [ + "from scipy.misc import derivative\n", + "def f(x):\n", + " y=x**3\n", + " return y\n", + "x=2.5#\n", + "delta=0.01#\n", + "deltafx=abs(derivative(f,x))*delta#\n", + "fx=f(x)#\n", + "print \"true value is between : \",fx-deltafx,\"and\",fx+deltafx" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.6: Page No: 46" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of y is between: 0.528721343471 and 0.596278656529\n", + "ymin is calculated at lower extremes of F, L, E, I values as = 0.524066539965\n", + "ymax is calculated at higher extremes of F, L, E, I values as = 0.602846335915\n" + ] + } + ], + "source": [ + "from scipy.misc import derivative\n", + "def f(F,L,E,I):\n", + " y=(F*(L**4))/(8*E*I)\n", + " return y\n", + "Fbar=50##lb/ft\n", + "Lbar=30##ft\n", + "Ebar=1.5*(10**8)##lb/ft**2\n", + "Ibar=0.06##ft**4\n", + "deltaF=2##lb/ft\n", + "deltaL=0.1##ft\n", + "deltaE=0.01*(10**8)##lb/ft**2\n", + "deltaI=0.0006##ft**4\n", + "ybar=(Fbar*(Lbar**4))/(8*Ebar*Ibar)#\n", + "def f1(F):\n", + " y=(F*(Lbar**4))/(8*Ebar*Ibar)\n", + " return y\n", + "def f2(L):\n", + " y=(Fbar*(L**4))/(8*Ebar*Ibar)\n", + " return y\n", + "def f3(E):\n", + " y=(Fbar*(Lbar**4))/(8*E*Ibar)\n", + " return y\n", + "def f4(I):\n", + " y=(Fbar*(Lbar**4))/(8*Ebar*I)\n", + " return y\n", + "\n", + "deltay=abs(derivative(f1,Fbar))*deltaF+abs(derivative(f2,Lbar))*deltaL+abs(derivative(f3,Ebar))*deltaE+abs(derivative(f4,Ibar))*deltaI#\n", + "\n", + "print \"The value of y is between:\",ybar-deltay,\"and\",ybar+deltay\n", + "ymin=((Fbar-deltaF)*((Lbar-deltaL)**4))/(8*(Ebar+deltaE)*(Ibar+deltaI))#\n", + "ymax=((Fbar+deltaF)*((Lbar+deltaL)**4))/(8*(Ebar-deltaE)*(Ibar-deltaI))#\n", + "print \"ymin is calculated at lower extremes of F, L, E, I values as =\",ymin\n", + "print \"ymax is calculated at higher extremes of F, L, E, I values as =\",ymax" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.7 : Page No:48" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The condition number of function for x = 0.18201112073 is : 1.72787595947\n", + "The condition number of function for x = 0.0160083243793 is : 1.58650429006\n" + ] + } + ], + "source": [ + "from math import pi,tan\n", + "from scipy.misc import derivative\n", + "def f(x):\n", + " y=tan(x)\n", + " return y\n", + "x1bar=(pi/2)+0.1*(pi/2)#\n", + "x2bar=(pi/2)+0.01*(pi/2)#\n", + "#computing condition number for x1bar\n", + "condnum1=x1bar*derivative(f,x1bar)/f(x1bar)#\n", + "print \"The condition number of function for x =\",condnum1,\"is :\",x1bar\n", + "if abs(condnum1)>1:\n", + " print \"Function is ill-conditioned for x =\",x1bar\n", + "\n", + "#computing condition number for x2bar\n", + "condnum2=x2bar*derivative(f,x2bar)/f(x2bar)#\n", + "print \"The condition number of function for x =\",condnum2,\"is :\",x2bar\n", + "if abs(condnum2)>1:\n", + " print \"Function is ill-conditioned for x =\",x2bar" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/chapter-4.ipynb b/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/chapter-4.ipynb new file mode 100755 index 00000000..c7c62a77 --- /dev/null +++ b/sample_notebooks/Suhaib Alam/Suhaib Alam_version_backup/chapter-4.ipynb @@ -0,0 +1,380 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:31dcf77e65a826bbecccd0c8b7094f24a045faabd3e68c38af8ed1add965bf7a" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter-4 : Bipolar Junction & Field Effect Transistors" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.1, p-175" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "VGS=10 #in Volt\n", + "IG=0.001 #in uAmpere\n", + "IG=IG*10**-6 #in Ampere\n", + "RGS=VGS/IG #in Ohm\n", + "RGS*=10**-6 #Mohm\n", + "print \"Resistance between gate and source is\",round(RGS,2),\"Mohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resistance between gate and source is 10000.0 Mohm\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.2, p-176" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "delVDS=1.5 #in Volt\n", + "delID=120 #in uAmpere\n", + "delID=delID*10**-6 #in Ampere\n", + "rd=delVDS/delID #in Ohm\n", + "rd*=10**-3 # Mohm\n", + "print \"AC drain Resistance of JFET is\",round(rd,2),\"Kohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "AC drain Resistance of JFET is 12.5 Kohm\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.3, p-179" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "ID2=1.5 #in mAmpere\n", + "ID1=1.2 #in mAmpere\n", + "delID=ID2-ID1 #in Ampere\n", + "VGS1=-4.25 #in Volt\n", + "VGS2=-4.10 #in Volt\n", + "delVGS=VGS2-VGS1 #in Volt\n", + "gm=delID/delVGS #in Ohm\n", + "print \"Transconductance is\",round(gm,2),\"mA/V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Transconductance is 2.0 mA/V\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.4, p-182" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "VDS1=5 #in Volt\n", + "VDS2=12 #in Volt\n", + "VDS3=12 #in Volt\n", + "VGS1=0 #in Volt\n", + "VGS2=0 #in Volt\n", + "VGS3=-0.25 #in Volt\n", + "ID1=8 #in mAmpere\n", + "ID2=8.2 #in mAmpere\n", + "ID3=7.5 #in mAmpere\n", + "#AC drain resistance\n", + "delVDS=VDS2-VDS1 #in Volt\n", + "delID=ID2-ID1 #in mAmpere\n", + "rd=delVDS/delID #in Kohm\n", + "print \"AC Drain resistance is\",round(rd,2),\"Kohm\"\n", + "#Transconductance\n", + "delID=ID3-ID2 #in mAmpere\n", + "delVGS=VGS3-VGS2 #in Volt\n", + "gm=delID/delVGS #in mA/V or mS\n", + "print \"Transconductance is\",round(gm,2),\"mA/V\"\n", + "#Amplification Factor\n", + "meu=rd*1000*gm*10**-3 #unitless\n", + "print \"Amplification Factor is\",round(meu,2) " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "AC Drain resistance is 35.0 Kohm\n", + "Transconductance is 2.8 mA/V\n", + "Amplification Factor is 98.0\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.5, p-188" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from __future__ import division\n", + "from math import sqrt\n", + "#given data :\n", + "VP=-4.5 #in Volt\n", + "IDSS=10 #in mAmpere\n", + "IDS=2.5 #in mAmpere\n", + "#Formula : IDS=IDSS*[1-VGS/VP]**2\n", + "VGS=VP*(1-sqrt(IDS/IDSS)) #in Volt\n", + "gm=(-2*IDSS*10**-3)*(1-VGS/VP)/VP #in A/V\n", + "gm*=1000 # mA/V\n", + "print \"Transconductance is\",round(gm,2),\"mA/V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " Transconductance is 2.22 mA/V\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.6, p-192" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "gm=10 #in mS\n", + "gm=gm*10**-3 #in S\n", + "IDSS=10 #in uAmpere\n", + "IDSS=IDSS*10**-6 #in Ampere\n", + "#VGS(OFF):VGS=VP\n", + "#Formula : gm=gmo=-2*IDSS/VP=-2*IDSS/VG(Off)\n", + "VGS_OFF=-2*IDSS/gm #in Volt\n", + "VGS_OFF*=1000 # mV\n", + "print \"VGS(OFF) is\",round(VGS_OFF),\"mV\" " + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "VGS(OFF) is -2.0 mV\n" + ] + } + ], + "prompt_number": 13 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.7, p-195" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "VP=-4 #in Volt\n", + "VGS=-2 #in Volt\n", + "IDSS=10 #in mAmpere\n", + "IDSS=IDSS*10**-3 #in Ampere\n", + "#Formula : ID=IDSS*[1-VGS/VP]**2\n", + "ID=IDSS*(1-VGS/VP)**2 #in Ampere\n", + "ID*=1000 #mA\n", + "print \"Drain Current is\",round(ID,2),\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Drain Current is 2.5 mA\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.8, p-206" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "IDSS=8.7 #in mAmpere\n", + "IDSS=IDSS*10**-3 #in Ampere\n", + "VP=-3 #in Volt\n", + "VGS=-1 #in Volt\n", + "#ID\n", + "ID=IDSS*(1-VGS/VP)**2\n", + "ID*=1000 #mA\n", + "print \"Drain current ID is\",round(ID,2),\"mA\"\n", + "#gmo\n", + "gmo=-2*IDSS/VP #in S\n", + "gmo*=1000 # mA/V or mS\n", + "print \"Transconductance for VGS=0V is\",round(gmo,2),\"mA/V or mS\"\n", + "#gm\n", + "gm=gmo*(1-VGS/VP) #in S\n", + "gm*=1000 # mA/V or mS\n", + "print \"Transconductance is\",round(gm,2),\"mA/V or mS\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Drain current ID is 3.87 mA\n", + "Transconductance for VGS=0V is 5.8 mA/V or mS\n", + "Transconductance is 3866.67 mA/V or mS\n" + ] + } + ], + "prompt_number": 18 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex 4.9, p-209" + ] + }, + { + "cell_type": "code", + "collapsed": true, + "input": [ + "from __future__ import division\n", + "#given data :\n", + "IDSS=8.4 #in mAmpere\n", + "IDSS=IDSS*10**-3 #in Ampere\n", + "VP=-3 #in Volt\n", + "VGS=-1.5 #in Volt\n", + "#ID\n", + "ID=IDSS*array(1-VGS/VP)**2\n", + "ID*=1000 # mA\n", + "print \"Drain current ID is\",round(ID,2),\"mA\"\n", + "#gmo\n", + "gmo=-2*IDSS/VP #in S\n", + "gmo*=1000 #mS\n", + "print \"Transconductance for VGS=0V is\",round(gmo,2),\"mA/V or mS\"\n", + "gm=gmo*(1-VGS/VP) #in S\n", + "gm*=1000 #mS\n", + "print \"Transconductance is\",round(gm,2),\"mA/V or mS\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Drain current ID is 2.1 mA\n", + "Transconductance for VGS=0V is 5.6 mA/V or mS\n", + "Transconductance is 2800.0 mA/V or mS\n" + ] + } + ], + "prompt_number": 21 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Suhaib Alam/ch2.ipynb b/sample_notebooks/Suhaib Alam/ch2.ipynb deleted file mode 100644 index b2b163f6..00000000 --- a/sample_notebooks/Suhaib Alam/ch2.ipynb +++ /dev/null @@ -1,507 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 - Truncation Errors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example: 2.1 Page No:29" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of f at x=0 : 1.2\n", - "The value of f at x=1 due to zero order approximation : 1.2\n", - "Truncation error : -1.0\n", - "----------------------------------------------\n", - "The value of first derivative of f at x=0 : -0.4\n", - "The value of f at x=1 due to first order approximation : 0.8\n", - "Truncation error : -0.6\n", - "----------------------------------------------\n", - "The value of second derivative of f at x=0 : -1.8\n", - "The value of f at x=1 due to second order approximation : -0.1\n", - "Truncation error : 0.3\n", - "----------------------------------------------\n", - "The value of third derivative of f at x=0 : -0.9\n", - "The value of f at x=1 due to third order approximation : -0.25\n", - "Truncation error : 0.45\n", - "----------------------------------------------\n", - "The value of fourth derivative of f at x=0 : -2.4\n", - "The value of f at x=1 due to fourth order approximation : -0.35\n", - "Truncation error : 0.55\n" - ] - } - ], - "source": [ - "from math import factorial\n", - "from scipy.misc import derivative\n", - "def f(x):\n", - " y=-0.1*x**4-0.15*x**3-0.5*x**2-0.25*x+1.2#\n", - " return y\n", - "xi=0#\n", - "xf=1#\n", - "h=xf-xi#\n", - "fi=f(xi)##function value at xi\n", - "ffa=f(xf)##actual function value at xf\n", - "\n", - "#for n=0, i.e, zero order approximation\n", - "ff=fi#\n", - "Et_1=ffa-ff##truncation error at x=1\n", - "print \"The value of f at x=0 :\",fi\n", - "print \"The value of f at x=1 due to zero order approximation :\",ff\n", - "print \"Truncation error :\",Et_1\n", - "print \"----------------------------------------------\"\n", - "\n", - "#for n=1, i.e, first order approximation\n", - "def f1(x):\n", - " y=derivative(f,x)\n", - " return y\n", - "f1i=f1(xi)##value of first derivative of function at xi\n", - "f1f=fi+f1i*h##value of first derivative of function at xf\n", - "Et_2=ffa-f1f##truncation error at x=1\n", - "print \"The value of first derivative of f at x=0 :\",f1i\n", - "print \"The value of f at x=1 due to first order approximation :\",f1f\n", - "print \"Truncation error :\",Et_2\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=2, i.e, second order approximation\n", - "def f2(x):\n", - " y=derivative(f1,x)\n", - " return y\n", - "f2i=f2(xi)##value of second derivative of function at xi\n", - "f2f=f1f+f2i*(h**2)/factorial(2)##value of second derivative of function at xf\n", - "Et_3=ffa-f2f##truncation error at x=1\n", - "print \"The value of second derivative of f at x=0 :\",f2i\n", - "print \"The value of f at x=1 due to second order approximation :\",f2f\n", - "print \"Truncation error :\",Et_3\n", - "print \"----------------------------------------------\"\n", - "\n", - "#for n=3, i.e, third order approximation\n", - "def f3(x):\n", - " y=derivative(f2,x)\n", - " return y\n", - "f3i=f3(xi)##value of third derivative of function at xi\n", - "f3f=f2f+f3i*(h**3)/factorial(3)##value of third derivative of function at xf\n", - "Et_4=ffa-f3f##truncation error at x=1\n", - "print \"The value of third derivative of f at x=0 :\",f3i\n", - "print \"The value of f at x=1 due to third order approximation :\",f3f\n", - "print \"Truncation error :\", Et_4\n", - "print \"----------------------------------------------\"\n", - "\n", - "#for n=4, i.e, fourth order approximation\n", - "def f4(x):\n", - " y=derivative(f3,x)\n", - " return y\n", - "f4i=f4(xi)##value of fourth derivative of function at xi\n", - "f4f=f3f+f4i*(h**4)/factorial(4)##value of fourth derivative of function at xf\n", - "Et_5=ffa-f4f##truncation error at x=1\n", - "print \"The value of fourth derivative of f at x=0 :\",f4i\n", - "print \"The value of f at x=1 due to fourth order approximation :\",f4f\n", - "print \"Truncation error :\",Et_5" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.2: Page No:32" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of f at x=1 due to zero order approximation : 0.707106781187\n", - "% relative error : -41.4213562373\n", - "----------------------------------------------\n", - "The value of f at x=1 due to first order approximation : 0.551333569463\n", - "% relative error : -10.2667138927\n", - "----------------------------------------------\n", - "The value of f at x=1 due to second order approximation : 0.534175415889\n", - "% relative error : -6.83508317772\n", - "----------------------------------------------\n", - "The value of f at x=1 due to third order approximation : 0.535435376789\n", - "% relative error : -7.08707535775\n", - "----------------------------------------------\n", - "The value of f at x=1 due to fourth order approximation : 0.535504768061\n", - "% relative error : -7.10095361216\n", - "----------------------------------------------\n", - "The value of f at x=1 due to fifth order approximation : 0.535501917392\n", - "% relative error : -7.10038347839\n", - "----------------------------------------------\n", - "The value of f at x=1 due to sixth order approximation : 0.535501819651\n", - "% relative error : -7.10036393016\n" - ] - } - ], - "source": [ - "from math import pi,cos,factorial\n", - "from scipy.misc import derivative\n", - "def f(x):\n", - " y=cos(x)\n", - " return y\n", - "xi=pi/4#\n", - "xf=pi/3#\n", - "h=xf-xi#\n", - "fi=f(xi)##function value at xi\n", - "ffa=f(xf)##actual function value at xf\n", - "\n", - "#for n=0, i.e, zero order approximation\n", - "ff=fi#\n", - "et1=(ffa-ff)*100/ffa##percent relative error at x=1\n", - "print \"The value of f at x=1 due to zero order approximation :\",ff\n", - "print \"% relative error :\",et1\n", - "print \"----------------------------------------------\"\n", - "\n", - "#for n=1, i.e, first order approximation\n", - "def f1(x):\n", - " y=derivative(f,x)\n", - " return y\n", - "f1i=f1(xi)##value of first derivative of function at xi\n", - "f1f=fi+f1i*h##value of first derivative of function at xf\n", - "et2=(ffa-f1f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to first order approximation :\",f1f\n", - "print \"% relative error :\",et2\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=2, i.e, second order approximation\n", - "def f2(x):\n", - " y=derivative(f1,x)\n", - " return y\n", - "f2i=f2(xi)##value of second derivative of function at xi\n", - "f2f=f1f+f2i*(h**2)/factorial(2)##value of second derivative of function at xf\n", - "et3=(ffa-f2f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to second order approximation :\",f2f\n", - "print \"% relative error :\",et3\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=3, i.e, third order approximation\n", - "def f3(x):\n", - " y=derivative(f2,x)\n", - " return y\n", - "f3i=f3(xi)##value of third derivative of function at xi\n", - "f3f=f2f+f3i*(h**3)/factorial(3)##value of third derivative of function at xf\n", - "et4=(ffa-f3f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to third order approximation :\",f3f\n", - "print \"% relative error :\",et4\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=4, i.e, fourth order approximation\n", - "def f4(x):\n", - " y=derivative(f3,x)\n", - " return y\n", - "f4i=f4(xi)##value of fourth derivative of function at xi\n", - "f4f=f3f+f4i*(h**4)/factorial(4)##value of fourth derivative of function at xf\n", - "et5=(ffa-f4f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to fourth order approximation :\",f4f\n", - "print \"% relative error :\",et5\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=5, i.e, fifth order approximation\n", - "f5i=(f4(1.1*xi)-f4(0.9*xi))/(2*0.1)##value of fifth derivative of function at xi (central difference method)\n", - "f5f=f4f+f5i*(h**5)/factorial(5)##value of fifth derivative of function at xf\n", - "et6=(ffa-f5f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to fifth order approximation :\",f5f\n", - "print \"% relative error :\",et6\n", - "print \"----------------------------------------------\"\n", - "\n", - "\n", - "#for n=6, i.e, sixth order approximation\n", - "def f6(x):\n", - " y=derivative(f5,x)\n", - " return y\n", - "f6i=(f4(1.1*xi)-2*f4(xi)+f4(0.9*xi))/(0.1**2)##value of sixth derivative of function at xi (central difference method)\n", - "f6f=f5f+f6i*(h**6)/factorial(6)##value of sixth derivative of function at xf\n", - "et6=(ffa-f6f)*100/ffa##% relative error at x=1\n", - "print \"The value of f at x=1 due to sixth order approximation :\",f6f\n", - "print \"% relative error :\", et6" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.3 : Page No:35" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Remainder: 21 \n", - "The value by first order approximation: 1275\n", - "True Value at x2: 1296\n" - ] - } - ], - "source": [ - "from math import pi,cos,factorial\n", - "m=4# Input value of m\n", - "h=5# Input value of h\n", - "def f(x):\n", - " y=x**m\n", - " return y\n", - "x1=1#\n", - "x2=x1+h#\n", - "fx1=f(x1)#\n", - "fx2=fx1+m*(fx1**(m-1))*h#\n", - "if m==1:\n", - " R=0#\n", - "elif m==2 :\n", - " R=2*(h**2)/factorial(2)#\n", - " \n", - "elif m==3:\n", - " R=(6*(x1)*(h**2)/factorial(2))+(6*(h**3)/factorial(3))#\n", - " \n", - "elif m==4:\n", - " R=(12*(x1**2)*(h**2)/factorial(2))+(24*(x1)*(h**3)/factorial(3))+(24*(h**4)/factorial(4))\n", - " \n", - "print \"\\nRemainder:\",fx2,\"\\nThe value by first order approximation:\",R\n", - "print \"True Value at x2:\",f(x2)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.4: Page No:42" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "For h= 1.232323\n", - "and percent error= -2.70944264922 Derivative at x by forward difference method= 114.60931875\n", - "and percent error= -0.178591334206 Derivative at x by backward difference method= 85.854151746\n", - "and percent error= -1.44401699172 Derivative at x by central difference method= 14.3775835022\n" - ] - } - ], - "source": [ - "from scipy.misc import derivative\n", - "def f(x):\n", - " y=-0.1*(x**4)-0.15*(x**3)-0.5*(x**2)-0.25*(x)+1.2\n", - " return y\n", - "x=0.5#\n", - "h=1.232323 # Input h\n", - "x1=x-h#\n", - "x2=x+h#\n", - "#forward difference method\n", - "fdx1=(f(x2)-f(x))/h##derivative at x\n", - "et1=abs((fdx1-derivative(f,x))/derivative(f,x))*100#\n", - "#backward difference method\n", - "fdx2=(f(x)-f(x1))/h##derivative at x\n", - "et2=abs((fdx2-derivative(f,x))/derivative(f,x))*100#\n", - "#central difference method\n", - "fdx3=(f(x2)-f(x1))/(2*h)##derivative at x\n", - "et3=abs((fdx3-derivative(f,x))/derivative(f,x))*100#\n", - "print \"For h=\",h\n", - "print \"and percent error=\",fdx1,\"Derivative at x by forward difference method=\",et1\n", - "print \"and percent error=\",fdx2,\"Derivative at x by backward difference method=\",et2\n", - "print \"and percent error=\",fdx3,\"Derivative at x by central difference method=\",et3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.5: Page No: 45" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "true value is between : 15.4275 and 15.8225\n" - ] - } - ], - "source": [ - "from scipy.misc import derivative\n", - "def f(x):\n", - " y=x**3\n", - " return y\n", - "x=2.5#\n", - "delta=0.01#\n", - "deltafx=abs(derivative(f,x))*delta#\n", - "fx=f(x)#\n", - "print \"true value is between : \",fx-deltafx,\"and\",fx+deltafx" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.6: Page No: 46" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of y is between: 0.528721343471 and 0.596278656529\n", - "ymin is calculated at lower extremes of F, L, E, I values as = 0.524066539965\n", - "ymax is calculated at higher extremes of F, L, E, I values as = 0.602846335915\n" - ] - } - ], - "source": [ - "from scipy.misc import derivative\n", - "def f(F,L,E,I):\n", - " y=(F*(L**4))/(8*E*I)\n", - " return y\n", - "Fbar=50##lb/ft\n", - "Lbar=30##ft\n", - "Ebar=1.5*(10**8)##lb/ft**2\n", - "Ibar=0.06##ft**4\n", - "deltaF=2##lb/ft\n", - "deltaL=0.1##ft\n", - "deltaE=0.01*(10**8)##lb/ft**2\n", - "deltaI=0.0006##ft**4\n", - "ybar=(Fbar*(Lbar**4))/(8*Ebar*Ibar)#\n", - "def f1(F):\n", - " y=(F*(Lbar**4))/(8*Ebar*Ibar)\n", - " return y\n", - "def f2(L):\n", - " y=(Fbar*(L**4))/(8*Ebar*Ibar)\n", - " return y\n", - "def f3(E):\n", - " y=(Fbar*(Lbar**4))/(8*E*Ibar)\n", - " return y\n", - "def f4(I):\n", - " y=(Fbar*(Lbar**4))/(8*Ebar*I)\n", - " return y\n", - "\n", - "deltay=abs(derivative(f1,Fbar))*deltaF+abs(derivative(f2,Lbar))*deltaL+abs(derivative(f3,Ebar))*deltaE+abs(derivative(f4,Ibar))*deltaI#\n", - "\n", - "print \"The value of y is between:\",ybar-deltay,\"and\",ybar+deltay\n", - "ymin=((Fbar-deltaF)*((Lbar-deltaL)**4))/(8*(Ebar+deltaE)*(Ibar+deltaI))#\n", - "ymax=((Fbar+deltaF)*((Lbar+deltaL)**4))/(8*(Ebar-deltaE)*(Ibar-deltaI))#\n", - "print \"ymin is calculated at lower extremes of F, L, E, I values as =\",ymin\n", - "print \"ymax is calculated at higher extremes of F, L, E, I values as =\",ymax" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.7 : Page No:48" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The condition number of function for x = 0.18201112073 is : 1.72787595947\n", - "The condition number of function for x = 0.0160083243793 is : 1.58650429006\n" - ] - } - ], - "source": [ - "from math import pi,tan\n", - "from scipy.misc import derivative\n", - "def f(x):\n", - " y=tan(x)\n", - " return y\n", - "x1bar=(pi/2)+0.1*(pi/2)#\n", - "x2bar=(pi/2)+0.01*(pi/2)#\n", - "#computing condition number for x1bar\n", - "condnum1=x1bar*derivative(f,x1bar)/f(x1bar)#\n", - "print \"The condition number of function for x =\",condnum1,\"is :\",x1bar\n", - "if abs(condnum1)>1:\n", - " print \"Function is ill-conditioned for x =\",x1bar\n", - "\n", - "#computing condition number for x2bar\n", - "condnum2=x2bar*derivative(f,x2bar)/f(x2bar)#\n", - "print \"The condition number of function for x =\",condnum2,\"is :\",x2bar\n", - "if abs(condnum2)>1:\n", - " print \"Function is ill-conditioned for x =\",x2bar" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Suhaib Alam/chapter-4.ipynb b/sample_notebooks/Suhaib Alam/chapter-4.ipynb deleted file mode 100755 index c7c62a77..00000000 --- a/sample_notebooks/Suhaib Alam/chapter-4.ipynb +++ /dev/null @@ -1,380 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:31dcf77e65a826bbecccd0c8b7094f24a045faabd3e68c38af8ed1add965bf7a" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter-4 : Bipolar Junction & Field Effect Transistors" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.1, p-175" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "VGS=10 #in Volt\n", - "IG=0.001 #in uAmpere\n", - "IG=IG*10**-6 #in Ampere\n", - "RGS=VGS/IG #in Ohm\n", - "RGS*=10**-6 #Mohm\n", - "print \"Resistance between gate and source is\",round(RGS,2),\"Mohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Resistance between gate and source is 10000.0 Mohm\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.2, p-176" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "delVDS=1.5 #in Volt\n", - "delID=120 #in uAmpere\n", - "delID=delID*10**-6 #in Ampere\n", - "rd=delVDS/delID #in Ohm\n", - "rd*=10**-3 # Mohm\n", - "print \"AC drain Resistance of JFET is\",round(rd,2),\"Kohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "AC drain Resistance of JFET is 12.5 Kohm\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.3, p-179" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "ID2=1.5 #in mAmpere\n", - "ID1=1.2 #in mAmpere\n", - "delID=ID2-ID1 #in Ampere\n", - "VGS1=-4.25 #in Volt\n", - "VGS2=-4.10 #in Volt\n", - "delVGS=VGS2-VGS1 #in Volt\n", - "gm=delID/delVGS #in Ohm\n", - "print \"Transconductance is\",round(gm,2),\"mA/V\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Transconductance is 2.0 mA/V\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.4, p-182" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "VDS1=5 #in Volt\n", - "VDS2=12 #in Volt\n", - "VDS3=12 #in Volt\n", - "VGS1=0 #in Volt\n", - "VGS2=0 #in Volt\n", - "VGS3=-0.25 #in Volt\n", - "ID1=8 #in mAmpere\n", - "ID2=8.2 #in mAmpere\n", - "ID3=7.5 #in mAmpere\n", - "#AC drain resistance\n", - "delVDS=VDS2-VDS1 #in Volt\n", - "delID=ID2-ID1 #in mAmpere\n", - "rd=delVDS/delID #in Kohm\n", - "print \"AC Drain resistance is\",round(rd,2),\"Kohm\"\n", - "#Transconductance\n", - "delID=ID3-ID2 #in mAmpere\n", - "delVGS=VGS3-VGS2 #in Volt\n", - "gm=delID/delVGS #in mA/V or mS\n", - "print \"Transconductance is\",round(gm,2),\"mA/V\"\n", - "#Amplification Factor\n", - "meu=rd*1000*gm*10**-3 #unitless\n", - "print \"Amplification Factor is\",round(meu,2) " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "AC Drain resistance is 35.0 Kohm\n", - "Transconductance is 2.8 mA/V\n", - "Amplification Factor is 98.0\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.5, p-188" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "from __future__ import division\n", - "from math import sqrt\n", - "#given data :\n", - "VP=-4.5 #in Volt\n", - "IDSS=10 #in mAmpere\n", - "IDS=2.5 #in mAmpere\n", - "#Formula : IDS=IDSS*[1-VGS/VP]**2\n", - "VGS=VP*(1-sqrt(IDS/IDSS)) #in Volt\n", - "gm=(-2*IDSS*10**-3)*(1-VGS/VP)/VP #in A/V\n", - "gm*=1000 # mA/V\n", - "print \"Transconductance is\",round(gm,2),\"mA/V\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " Transconductance is 2.22 mA/V\n" - ] - } - ], - "prompt_number": 11 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.6, p-192" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "gm=10 #in mS\n", - "gm=gm*10**-3 #in S\n", - "IDSS=10 #in uAmpere\n", - "IDSS=IDSS*10**-6 #in Ampere\n", - "#VGS(OFF):VGS=VP\n", - "#Formula : gm=gmo=-2*IDSS/VP=-2*IDSS/VG(Off)\n", - "VGS_OFF=-2*IDSS/gm #in Volt\n", - "VGS_OFF*=1000 # mV\n", - "print \"VGS(OFF) is\",round(VGS_OFF),\"mV\" " - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "VGS(OFF) is -2.0 mV\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.7, p-195" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "VP=-4 #in Volt\n", - "VGS=-2 #in Volt\n", - "IDSS=10 #in mAmpere\n", - "IDSS=IDSS*10**-3 #in Ampere\n", - "#Formula : ID=IDSS*[1-VGS/VP]**2\n", - "ID=IDSS*(1-VGS/VP)**2 #in Ampere\n", - "ID*=1000 #mA\n", - "print \"Drain Current is\",round(ID,2),\"mA\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Drain Current is 2.5 mA\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.8, p-206" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "IDSS=8.7 #in mAmpere\n", - "IDSS=IDSS*10**-3 #in Ampere\n", - "VP=-3 #in Volt\n", - "VGS=-1 #in Volt\n", - "#ID\n", - "ID=IDSS*(1-VGS/VP)**2\n", - "ID*=1000 #mA\n", - "print \"Drain current ID is\",round(ID,2),\"mA\"\n", - "#gmo\n", - "gmo=-2*IDSS/VP #in S\n", - "gmo*=1000 # mA/V or mS\n", - "print \"Transconductance for VGS=0V is\",round(gmo,2),\"mA/V or mS\"\n", - "#gm\n", - "gm=gmo*(1-VGS/VP) #in S\n", - "gm*=1000 # mA/V or mS\n", - "print \"Transconductance is\",round(gm,2),\"mA/V or mS\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Drain current ID is 3.87 mA\n", - "Transconductance for VGS=0V is 5.8 mA/V or mS\n", - "Transconductance is 3866.67 mA/V or mS\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex 4.9, p-209" - ] - }, - { - "cell_type": "code", - "collapsed": true, - "input": [ - "from __future__ import division\n", - "#given data :\n", - "IDSS=8.4 #in mAmpere\n", - "IDSS=IDSS*10**-3 #in Ampere\n", - "VP=-3 #in Volt\n", - "VGS=-1.5 #in Volt\n", - "#ID\n", - "ID=IDSS*array(1-VGS/VP)**2\n", - "ID*=1000 # mA\n", - "print \"Drain current ID is\",round(ID,2),\"mA\"\n", - "#gmo\n", - "gmo=-2*IDSS/VP #in S\n", - "gmo*=1000 #mS\n", - "print \"Transconductance for VGS=0V is\",round(gmo,2),\"mA/V or mS\"\n", - "gm=gmo*(1-VGS/VP) #in S\n", - "gm*=1000 #mS\n", - "print \"Transconductance is\",round(gm,2),\"mA/V or mS\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Drain current ID is 2.1 mA\n", - "Transconductance for VGS=0V is 5.6 mA/V or mS\n", - "Transconductance is 2800.0 mA/V or mS\n" - ] - } - ], - "prompt_number": 21 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive.ipynb b/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive.ipynb new file mode 100755 index 00000000..916e874c --- /dev/null +++ b/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive.ipynb @@ -0,0 +1,370 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 Passive Circuits" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2.2, Pg.no.5" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of resistance R is 16.61 ohm\n", + "The value of resistance R3 is 66.82 ohm\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "Ro=50.0\n", + "ILdB=6.0 #T−type attenuator provide 6−dB insertion loss \n", + "#calculation\n", + "IL=10**-(ILdB/20) #Determination of R\n", + "R=Ro*(1-IL)/(1+IL)\n", + "R=round(R,2)\n", + "print 'The value of resistance R is',R,'ohm' \n", + "#Determination of R3\n", + "R3=(2*Ro*IL)/(1-(0.5)**2)\n", + "R3=round(R3,2)\n", + "print 'The value of resistance R3 is',R3,'ohm'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2.3,Pg.no.7" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of resistance RA and RB is 150.5 ohm\n", + "The value of resistance RC is 37.35 ohm\n" + ] + } + ], + "source": [ + "import math\n", + "#given\n", + "Ro=50.0\n", + "ILdB=6.0\n", + "IL=10**-(ILdB/20) #Determination of RA and RB\n", + "RA=Ro*(1+IL)/(1-IL)\n", + "RA=round(RA,1)\n", + "print 'The value of resistance RA and RB is',RA,'ohm'\n", + "#Determination of RC\n", + "RC=Ro*(1-(IL)**2)/(2*IL)\n", + "RC=round(RC,2)\n", + "print 'The value of resistance RC is',RC,'ohm'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2.4,Pg.no.9" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of resistance R1 is 1.0 ohm\n", + "The value of resistance R3 is 5624.0 ohm\n", + "The value of insertion loss is 0.12 decibels\n" + ] + } + ], + "source": [ + "import math\n", + "from math import log10\n", + "#given\n", + "Rs=75.0 #resistance\n", + "Rl=50.0 \n", + "#Determination of R1\n", + "R1=(Rs*(Rs-Rl))**(1/2)\n", + "R1=round(R1,2)\n", + "print 'The value of resistance R1 is',R1,'ohm'\n", + "#Determination of R3\n", + "R3=((Rs**2)-(R1**2))/R1\n", + "R3=round(R3,2)\n", + "print 'The value of resistance R3 is',R3,'ohm'\n", + "#Determination of insertion loss\n", + "IL=(R3*(Rs+R1))/((Rs+R1+R3)*(R3+R1)-(R3)**2)\n", + "ILdB=-20*log10(IL) #convertion of power in decibels\n", + "ILdB=round(ILdB,2)\n", + "print 'The value of insertion loss is',ILdB,'decibels'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.2.5,Pg.no.10" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of resistance R2 is 1.0 ohm\n", + "The value of resistance R3 is 2499.0 ohm\n", + "The value of insertion loss is 0.2 decibels\n" + ] + } + ], + "source": [ + "from math import log10\n", + "Rs=10.0\n", + "Rl=50.0 #Determination of R2\n", + "R2=(Rl*(Rl-Rs))**(1/2)\n", + "R2=round(R2,2)\n", + "print 'The value of resistance R2 is',R2,'ohm'\n", + "#Determination of R3\n", + "R3=((Rl**2)-(R2**2))/R2\n", + "R3=round(R3,2)\n", + "print 'The value of resistance R3 is',R3,'ohm'\n", + "#Determination of insertion loss\n", + "IL=(R3*(Rs+Rl))/((Rs+R3)*(R3+R2+Rl)-(R3)**2)\n", + "ILdB=-20*log10(IL) #convertion of power in decibels\n", + "ILdB=round(ILdB,1)\n", + "print 'The value of insertion loss is',ILdB,'decibels'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.5.1,Pg.no.21" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of self resonant freq is 60.2 MHz\n", + "The value of Q−factor is 31.4\n", + "The value of effective inductance is -5.79846400003e-12 uH\n", + "The value of effective Q−factor is -5.41522720497e+12\n" + ] + } + ], + "source": [ + "import math\n", + "C=7*10**-12\n", + "R=5.0\n", + "L=10**-6\n", + "f=25*10**6 \n", + "#Determination of self resonant freq of coil denoted as Fsr\n", + "Fsr=1/(2*3.14*(L*C)**0.5)\n", + "Fsr=Fsr/(10**6)\n", + "Fsr=round(Fsr,1)\n", + "print 'The value of self resonant freq is',Fsr,'MHz'\n", + "#Determination of Q−factor of coil , excluding self − capacitive effects\n", + "Q=(2*3.14*f*L)/R\n", + "print 'The value of Q−factor is',Q\n", + "#Determination of effective inductance\n", + "Leff=L/(1-(f/Fsr)**2)\n", + "Leff=Leff*(10**6)\n", + "#Leff=round(Leff,0)\n", + "print 'The value of effective inductance is',Leff,'uH'\n", + "#Determination of effective Q−factor\n", + "Qeff=Q*(1-(f/Fsr)**2)\n", + "Qeff=round(Qeff,0)\n", + "print 'The value of effective Q−factor is',Qeff" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.8.1,Pg.no.26" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of common resonant freq is 1e-06 Mrad/sec\n", + "The transfer impedance is -6.83732235918e-05 ohm\n" + ] + } + ], + "source": [ + "import cmath\n", + "#given\n", + "Lp=150*10**-6 #inductance\n", + "Ls=150*10**-6\n", + "Cp=470*10**-12 #capacitance\n", + "Cs=470*10**-12 #Lp=Ls=150 uH,Cp=Cs=470 pF\n", + "Q=85.0 #Q−factor for each ckt is 85\n", + "c=0.01 #Coeff of coupling is 0.01\n", + "Rl=5000.0 #Load resistance Rl=5000 ohm\n", + "r=75000.0 #Constant current source with internal resistance r=75 kohm\n", + "#calculations\n", + "#Determination of common resonant frequency\n", + "wo=1/((Lp*Cp)**(1/2))\n", + "wo=wo/(10**6)\n", + "print 'The value of common resonant freq is',wo,'Mrad/sec'\n", + "p=3.77*10**6\n", + "Z2=complex(62.9004,557.266) #Formula=Rl/(1+(p*j*Cs*Rl))\n", + "Z1=complex(4.2465,564.33) #Formula=r/(1+(p*j*Cp*r)) ;At resonance Zs=Zp=Z\n", + "z=complex(0,1)\n", + "Z=wo*Ls*(1/Q +z)\n", + "Zm=complex(0,p*c*Lp) #Determination of denominator\n", + "Dr=((Z+Z1)*(Z+Z2))-(Zm**2) \n", + "#Hence transfer impedance is given as\n", + "Zr= (Z1*Z2*Zm)/Dr\n", + "Z=Zr.real\n", + "#Z=round(Z,2)\n", + "#Zr.imag=round(Zr.imag,2)\n", + "print 'The transfer impedance is',Z,'ohm'" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.10.1,Pg.no.34" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The value of common resonant freq is 169.56 Mrad/ sec\n", + "The value of Gl is 5.0 mSec\n", + "The value of alpha is 3.14\n", + "The value of effective load is 1.97 kohm\n", + "The value of tuning capacitance is 47.73 pF\n", + "The value of Rd is 1.85343097504e-05 kohm\n", + "The value of −3dB BW is 1.69 MHz\n" + ] + } + ], + "source": [ + "import math\n", + "C1=70*10**-12\n", + "C2=150*10**-12\n", + "Rl=200.0\n", + "Q=150.0\n", + "f=27*10**6\n", + "r=40000.0\n", + "#Determination of common resonant freq\n", + "wo=2*3.14*f\n", + "wo=wo/(10**6)\n", + "print 'The value of common resonant freq is',wo,'Mrad/ sec'\n", + "#Determination of Gl\n", + "Gl=1/Rl\n", + "G1=Gl*(10**3) \n", + "print'The value of Gl is',G1,'mSec'\n", + "#Checking the approxiamtion in denominator\n", + "ap=((wo*(C1+C2))/(Gl))**2\n", + "alpha=(C1+C2)/C1\n", + "alpha=round(alpha,2)\n", + "print 'The value of alpha is',alpha\n", + "#Determination of effective load\n", + "Reff=((alpha)**2)*Rl\n", + "Reff=Reff/(10**3)\n", + "Reff=round(Reff,2)\n", + "print 'The value of effective load is',Reff,'kohm' \n", + "#If effective load is much less than internal resistance hence tuning capacitance then\n", + "Cs=C1*C2/(C1+C2)\n", + "Cs=Cs*(10**12)\n", + "Cs=round(Cs,2)\n", + "print 'The value of tuning capacitance is',Cs,'pF'\n", + "#Determination of Rd\n", + "Rd=Q/(wo*Cs)\n", + "Rd=Rd/(10**3)\n", + "print 'The value of Rd is',Rd,'kohm'\n", + "#If Rd is much greater than Reff then −3dB bandwidth is given by\n", + "B=1/(2*3.14*C2*alpha*Rl)\n", + "B=B/(10**6)\n", + "B=round(B,2)\n", + "print 'The value of −3dB BW is',B,'MHz'" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive_Circuits.ipynb b/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive_Circuits.ipynb deleted file mode 100755 index 916e874c..00000000 --- a/sample_notebooks/SumadhuriDamerla/Chapter_1_Passive_Circuits.ipynb +++ /dev/null @@ -1,370 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 Passive Circuits" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2.2, Pg.no.5" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of resistance R is 16.61 ohm\n", - "The value of resistance R3 is 66.82 ohm\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "Ro=50.0\n", - "ILdB=6.0 #T−type attenuator provide 6−dB insertion loss \n", - "#calculation\n", - "IL=10**-(ILdB/20) #Determination of R\n", - "R=Ro*(1-IL)/(1+IL)\n", - "R=round(R,2)\n", - "print 'The value of resistance R is',R,'ohm' \n", - "#Determination of R3\n", - "R3=(2*Ro*IL)/(1-(0.5)**2)\n", - "R3=round(R3,2)\n", - "print 'The value of resistance R3 is',R3,'ohm'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2.3,Pg.no.7" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of resistance RA and RB is 150.5 ohm\n", - "The value of resistance RC is 37.35 ohm\n" - ] - } - ], - "source": [ - "import math\n", - "#given\n", - "Ro=50.0\n", - "ILdB=6.0\n", - "IL=10**-(ILdB/20) #Determination of RA and RB\n", - "RA=Ro*(1+IL)/(1-IL)\n", - "RA=round(RA,1)\n", - "print 'The value of resistance RA and RB is',RA,'ohm'\n", - "#Determination of RC\n", - "RC=Ro*(1-(IL)**2)/(2*IL)\n", - "RC=round(RC,2)\n", - "print 'The value of resistance RC is',RC,'ohm'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2.4,Pg.no.9" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of resistance R1 is 1.0 ohm\n", - "The value of resistance R3 is 5624.0 ohm\n", - "The value of insertion loss is 0.12 decibels\n" - ] - } - ], - "source": [ - "import math\n", - "from math import log10\n", - "#given\n", - "Rs=75.0 #resistance\n", - "Rl=50.0 \n", - "#Determination of R1\n", - "R1=(Rs*(Rs-Rl))**(1/2)\n", - "R1=round(R1,2)\n", - "print 'The value of resistance R1 is',R1,'ohm'\n", - "#Determination of R3\n", - "R3=((Rs**2)-(R1**2))/R1\n", - "R3=round(R3,2)\n", - "print 'The value of resistance R3 is',R3,'ohm'\n", - "#Determination of insertion loss\n", - "IL=(R3*(Rs+R1))/((Rs+R1+R3)*(R3+R1)-(R3)**2)\n", - "ILdB=-20*log10(IL) #convertion of power in decibels\n", - "ILdB=round(ILdB,2)\n", - "print 'The value of insertion loss is',ILdB,'decibels'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.2.5,Pg.no.10" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of resistance R2 is 1.0 ohm\n", - "The value of resistance R3 is 2499.0 ohm\n", - "The value of insertion loss is 0.2 decibels\n" - ] - } - ], - "source": [ - "from math import log10\n", - "Rs=10.0\n", - "Rl=50.0 #Determination of R2\n", - "R2=(Rl*(Rl-Rs))**(1/2)\n", - "R2=round(R2,2)\n", - "print 'The value of resistance R2 is',R2,'ohm'\n", - "#Determination of R3\n", - "R3=((Rl**2)-(R2**2))/R2\n", - "R3=round(R3,2)\n", - "print 'The value of resistance R3 is',R3,'ohm'\n", - "#Determination of insertion loss\n", - "IL=(R3*(Rs+Rl))/((Rs+R3)*(R3+R2+Rl)-(R3)**2)\n", - "ILdB=-20*log10(IL) #convertion of power in decibels\n", - "ILdB=round(ILdB,1)\n", - "print 'The value of insertion loss is',ILdB,'decibels'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.5.1,Pg.no.21" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of self resonant freq is 60.2 MHz\n", - "The value of Q−factor is 31.4\n", - "The value of effective inductance is -5.79846400003e-12 uH\n", - "The value of effective Q−factor is -5.41522720497e+12\n" - ] - } - ], - "source": [ - "import math\n", - "C=7*10**-12\n", - "R=5.0\n", - "L=10**-6\n", - "f=25*10**6 \n", - "#Determination of self resonant freq of coil denoted as Fsr\n", - "Fsr=1/(2*3.14*(L*C)**0.5)\n", - "Fsr=Fsr/(10**6)\n", - "Fsr=round(Fsr,1)\n", - "print 'The value of self resonant freq is',Fsr,'MHz'\n", - "#Determination of Q−factor of coil , excluding self − capacitive effects\n", - "Q=(2*3.14*f*L)/R\n", - "print 'The value of Q−factor is',Q\n", - "#Determination of effective inductance\n", - "Leff=L/(1-(f/Fsr)**2)\n", - "Leff=Leff*(10**6)\n", - "#Leff=round(Leff,0)\n", - "print 'The value of effective inductance is',Leff,'uH'\n", - "#Determination of effective Q−factor\n", - "Qeff=Q*(1-(f/Fsr)**2)\n", - "Qeff=round(Qeff,0)\n", - "print 'The value of effective Q−factor is',Qeff" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.8.1,Pg.no.26" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of common resonant freq is 1e-06 Mrad/sec\n", - "The transfer impedance is -6.83732235918e-05 ohm\n" - ] - } - ], - "source": [ - "import cmath\n", - "#given\n", - "Lp=150*10**-6 #inductance\n", - "Ls=150*10**-6\n", - "Cp=470*10**-12 #capacitance\n", - "Cs=470*10**-12 #Lp=Ls=150 uH,Cp=Cs=470 pF\n", - "Q=85.0 #Q−factor for each ckt is 85\n", - "c=0.01 #Coeff of coupling is 0.01\n", - "Rl=5000.0 #Load resistance Rl=5000 ohm\n", - "r=75000.0 #Constant current source with internal resistance r=75 kohm\n", - "#calculations\n", - "#Determination of common resonant frequency\n", - "wo=1/((Lp*Cp)**(1/2))\n", - "wo=wo/(10**6)\n", - "print 'The value of common resonant freq is',wo,'Mrad/sec'\n", - "p=3.77*10**6\n", - "Z2=complex(62.9004,557.266) #Formula=Rl/(1+(p*j*Cs*Rl))\n", - "Z1=complex(4.2465,564.33) #Formula=r/(1+(p*j*Cp*r)) ;At resonance Zs=Zp=Z\n", - "z=complex(0,1)\n", - "Z=wo*Ls*(1/Q +z)\n", - "Zm=complex(0,p*c*Lp) #Determination of denominator\n", - "Dr=((Z+Z1)*(Z+Z2))-(Zm**2) \n", - "#Hence transfer impedance is given as\n", - "Zr= (Z1*Z2*Zm)/Dr\n", - "Z=Zr.real\n", - "#Z=round(Z,2)\n", - "#Zr.imag=round(Zr.imag,2)\n", - "print 'The transfer impedance is',Z,'ohm'" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.10.1,Pg.no.34" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The value of common resonant freq is 169.56 Mrad/ sec\n", - "The value of Gl is 5.0 mSec\n", - "The value of alpha is 3.14\n", - "The value of effective load is 1.97 kohm\n", - "The value of tuning capacitance is 47.73 pF\n", - "The value of Rd is 1.85343097504e-05 kohm\n", - "The value of −3dB BW is 1.69 MHz\n" - ] - } - ], - "source": [ - "import math\n", - "C1=70*10**-12\n", - "C2=150*10**-12\n", - "Rl=200.0\n", - "Q=150.0\n", - "f=27*10**6\n", - "r=40000.0\n", - "#Determination of common resonant freq\n", - "wo=2*3.14*f\n", - "wo=wo/(10**6)\n", - "print 'The value of common resonant freq is',wo,'Mrad/ sec'\n", - "#Determination of Gl\n", - "Gl=1/Rl\n", - "G1=Gl*(10**3) \n", - "print'The value of Gl is',G1,'mSec'\n", - "#Checking the approxiamtion in denominator\n", - "ap=((wo*(C1+C2))/(Gl))**2\n", - "alpha=(C1+C2)/C1\n", - "alpha=round(alpha,2)\n", - "print 'The value of alpha is',alpha\n", - "#Determination of effective load\n", - "Reff=((alpha)**2)*Rl\n", - "Reff=Reff/(10**3)\n", - "Reff=round(Reff,2)\n", - "print 'The value of effective load is',Reff,'kohm' \n", - "#If effective load is much less than internal resistance hence tuning capacitance then\n", - "Cs=C1*C2/(C1+C2)\n", - "Cs=Cs*(10**12)\n", - "Cs=round(Cs,2)\n", - "print 'The value of tuning capacitance is',Cs,'pF'\n", - "#Determination of Rd\n", - "Rd=Q/(wo*Cs)\n", - "Rd=Rd/(10**3)\n", - "print 'The value of Rd is',Rd,'kohm'\n", - "#If Rd is much greater than Reff then −3dB bandwidth is given by\n", - "B=1/(2*3.14*C2*alpha*Rl)\n", - "B=B/(10**6)\n", - "B=round(B,2)\n", - "print 'The value of −3dB BW is',B,'MHz'" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SumedhKadam/Chapter_1_General.ipynb b/sample_notebooks/SumedhKadam/Chapter_1_General.ipynb new file mode 100644 index 00000000..62d27f1f --- /dev/null +++ b/sample_notebooks/SumedhKadam/Chapter_1_General.ipynb @@ -0,0 +1,117 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 1 General Principles" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1.1 Page No 10 " + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Part(a)\n", + "(10 mN)(5 GN) = 50 kilo Newton square\n", + "\n", + "Part(b)\n", + "(100 mm)(0.5 MN square) = 25 Gigameter Newton square\n", + "\n", + "Part(c)\n", + "(50 MN cube)(500 Gg) = 100 Kilo Newton cube per kg\n" + ] + } + ], + "source": [ + "# Example Number 1.1\n", + "\n", + "# Part(a)\n", + "# Variable Declaration\n", + "a = 10 # [micro Newton(mN)]\n", + "b = 5 # [Giga Newton(GN)]\n", + "\n", + "# Calculation\n", + "# We have to find c = a * b\n", + "c = 10*5 # [micro Newton(mN)*Giga Newton(GN)]\n", + "c = (10*10**(-3))*(5*10**(9)) # [N**(2)]\n", + "c = (10*10**(-3))*(5*10**(9))*10**(-6) #[kN**(2)]\n", + "\n", + "#Result\n", + "print\"Part(a)\"\n", + "print \"(10 mN)(5 GN) = \",int(c),\"kilo Newton square\\n\"\n", + "\n", + "# Part(b)\n", + "# Variable Declaration\n", + "a = 100 #[millimeter(mm)]\n", + "b = 0.5**(2) #[mega Newton square(MN**(2))]\n", + "\n", + "# Calculation\n", + "# We have to find c = a * b\n", + "c = (100*10**(-3))*(0.25*10**(12)) #[m.N**(2)]\n", + "c = (100*10**(-3))*(0.25*10**(12))*10**(-9) #[Gm.N**(2)]\n", + "\n", + "#Result\n", + "print\"Part(b)\"\n", + "print \"(100 mm)(0.5 MN square) = \",int(c),\"Gigameter Newton square\\n\"\n", + "\n", + "# Part(c) (Correction in the question (50 MN cube)(500 Gg))\n", + "# Variable Declaration\n", + "a = 50 #[mega newton cube((MN)**(3))]\n", + "b = 500 #[gigagram(Gg)]\n", + "\n", + "# Calculation\n", + "# We have to find c = a / b\n", + "c = 50*(10**(6))**3 / 500*10**(6) #[N**(3)/kg]\n", + "c = (50*((10**(6))**3) / (500*10**(6)))*10**(-9) #[kN**(3)/kg]\n", + "\n", + "#Result\n", + "print\"Part(c)\"\n", + "print \"(50 MN cube)(500 Gg) = \",int(c),\"Kilo Newton cube per kg\"\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/sample_notebooks/SumedhKadam/Chapter_1_General_Principles.ipynb b/sample_notebooks/SumedhKadam/Chapter_1_General_Principles.ipynb deleted file mode 100644 index 62d27f1f..00000000 --- a/sample_notebooks/SumedhKadam/Chapter_1_General_Principles.ipynb +++ /dev/null @@ -1,117 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 1 General Principles" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1.1 Page No 10 " - ] - }, - { - "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Part(a)\n", - "(10 mN)(5 GN) = 50 kilo Newton square\n", - "\n", - "Part(b)\n", - "(100 mm)(0.5 MN square) = 25 Gigameter Newton square\n", - "\n", - "Part(c)\n", - "(50 MN cube)(500 Gg) = 100 Kilo Newton cube per kg\n" - ] - } - ], - "source": [ - "# Example Number 1.1\n", - "\n", - "# Part(a)\n", - "# Variable Declaration\n", - "a = 10 # [micro Newton(mN)]\n", - "b = 5 # [Giga Newton(GN)]\n", - "\n", - "# Calculation\n", - "# We have to find c = a * b\n", - "c = 10*5 # [micro Newton(mN)*Giga Newton(GN)]\n", - "c = (10*10**(-3))*(5*10**(9)) # [N**(2)]\n", - "c = (10*10**(-3))*(5*10**(9))*10**(-6) #[kN**(2)]\n", - "\n", - "#Result\n", - "print\"Part(a)\"\n", - "print \"(10 mN)(5 GN) = \",int(c),\"kilo Newton square\\n\"\n", - "\n", - "# Part(b)\n", - "# Variable Declaration\n", - "a = 100 #[millimeter(mm)]\n", - "b = 0.5**(2) #[mega Newton square(MN**(2))]\n", - "\n", - "# Calculation\n", - "# We have to find c = a * b\n", - "c = (100*10**(-3))*(0.25*10**(12)) #[m.N**(2)]\n", - "c = (100*10**(-3))*(0.25*10**(12))*10**(-9) #[Gm.N**(2)]\n", - "\n", - "#Result\n", - "print\"Part(b)\"\n", - "print \"(100 mm)(0.5 MN square) = \",int(c),\"Gigameter Newton square\\n\"\n", - "\n", - "# Part(c) (Correction in the question (50 MN cube)(500 Gg))\n", - "# Variable Declaration\n", - "a = 50 #[mega newton cube((MN)**(3))]\n", - "b = 500 #[gigagram(Gg)]\n", - "\n", - "# Calculation\n", - "# We have to find c = a / b\n", - "c = 50*(10**(6))**3 / 500*10**(6) #[N**(3)/kg]\n", - "c = (50*((10**(6))**3) / (500*10**(6)))*10**(-9) #[kN**(3)/kg]\n", - "\n", - "#Result\n", - "print\"Part(c)\"\n", - "print \"(50 MN cube)(500 Gg) = \",int(c),\"Kilo Newton cube per kg\"\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/sample_notebooks/SwathiSyamala/Chapter_6_IMPEDENCE_MATCHING_AND_TUNNING.ipynb b/sample_notebooks/SwathiSyamala/Chapter_6_IMPEDENCE_MATCHING_AND_TUNNING.ipynb deleted file mode 100755 index e50612ad..00000000 --- a/sample_notebooks/SwathiSyamala/Chapter_6_IMPEDENCE_MATCHING_AND_TUNNING.ipynb +++ /dev/null @@ -1,277 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 6 IMPEDENCE MATCHING AND TUNNING" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.1 page no:284" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "inductor of first circuit in nH = 38.9848400617\n", - "capacitor of the first circuit in pF = 0.9227738301\n", - "inductor of second circuit in nH = 46.138691505\n", - "capacitor of the second circuit in pF = 2.59898933745\n", - "\"NOTE:−for above specific problem Rl>Zo, positive X implies inductor , negative X implies capacitor , positive B implies capacitor and negative B implies inductor .\"\n" - ] - } - ], - "source": [ - "#Exa 6.1 program to design an L section matching network\n", - "# example:−6.1,page no.−284.\n", - "from math import pi,sqrt\n", - "from sympy import I\n", - "# program to design an L section matching network to match a series RC load.\n", - "Zl=200-I*100; # load impedence .\n", - "Rl=200;Xl=-100;f=500*10**6;Zo=100;\n", - "B1=(Xl+sqrt(Rl/Zo)*sqrt(Rl**2+Xl**2-(Rl*Zo)))/(Rl**2+Xl**2);\n", - "B2=(Xl-sqrt(Rl/Zo)*sqrt(Rl**2+Xl**2-(Rl*Zo)))/(Rl**2+Xl**2);\n", - "C1=(B1/(2*pi*f))*10**12;\n", - "L2=(-1/(B2*2*pi*f))*10**9;\n", - "X1=(1/B1)+((Xl*Zo)/Rl)-(Zo/(B1*Rl));\n", - "X2=(1/B2)+((Xl*Zo)/Rl)-(Zo/(B2*Rl));\n", - "L1=(X1/(2*pi*f))*10**9;\n", - "C2=(-1/(X2*2*pi*f))*10**12;\n", - "print\"inductor of first circuit in nH = \",L1\n", - "print\"capacitor of the first circuit in pF = \",C1\n", - "print\"inductor of second circuit in nH = \",L2\n", - "print\"capacitor of the second circuit in pF = \",C2 \n", - "print\"\\\"NOTE:−for above specific problem Rl>Zo, positive X implies inductor , negative X implies capacitor , positive B implies capacitor and negative B implies inductor .\\\"\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.2 page no:304" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "charecteristic impedence of matching section = 22.360679775\n", - " fractional bandwidth = 0.293159219438\n" - ] - } - ], - "source": [ - "#Exa 6.5 design quarter wave matching transformer\n", - "#example:−6.5,page no.−304.\n", - "from math import sqrt,pi,acos\n", - "#program to design a single section quarter wave matching transformer .\n", - "Zl=10; # load impedence .\n", - "Zo=50; # characteristic impedence .\n", - "fo=3*10**9;swr=1.5; # maximum limit of swr.\n", - "Z1=sqrt(Zo*Zl); # characteristic impedence of the matching section .\n", - "taom=(swr-1)/(swr+1);\n", - "frac_bw=2-(4/pi)*acos((taom/sqrt(1-taom**2))*(2*sqrt(Zo*Zl)/abs(Zl-Zo))); # fractional bandwidth .\n", - "print \"charecteristic impedence of matching section =\",Z1\n", - "print \" fractional bandwidth = \",frac_bw" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.6 page no:307" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "approximate value of reflection coefficient is = 0.4\n", - "the error in percent is about = 4.0\n" - ] - } - ], - "source": [ - "#Exa 6.6 program to evaluate the worst case percent error\n", - "# example:−6.6,page no.−307.\n", - "#from math import abs\n", - "# program to evaluate the worst case percent error in computing magnitude of reflection coefficient .\n", - "Z1 =100.; \n", - "Z2 =150.; \n", - "Zl =225.;\n", - "tao_1=(Z2-Z1)/(Z2+Z1);\n", - "tao_2=(Zl-Z2)/(Zl+Z2);\n", - "tao_exact=(tao_1+tao_2)/(1+tao_1*tao_2); # this results as angle is taken zero .\n", - "tao_approx=tao_1+tao_2; # this results as angle is taken zero .\n", - "eror=abs(((tao_exact -tao_approx)/tao_exact)*100);\n", - "print \"approximate value of reflection coefficient is = \",tao_approx\n", - "print \"the error in percent is about = \",eror" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.7 page no:312" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Z1 = 91.7004043205\n", - "Z2 = 84.0896415254\n", - "Z3 = 77.1105412704\n" - ] - } - ], - "source": [ - "#Exa 6.7 design three section binomial transformer\n", - "# example:−6.7,page no.−312.\n", - "from math import pi,acos\n", - "# program to design three section binomial transformer .\n", - "Zl=50.;Zo=100.;N=3;taom=0.05;\n", - "A=(2**-N)*abs((Zl-Zo)/(Zl+Zo));\n", - "frac_bw=2-(4/pi)*acos(0.5*(taom/A)**2);\n", - "c=1\n", - "Z1=Zo*((Zl/Zo)**((2**-N)*(c**N)));\n", - "print \"Z1 = \",Z1\n", - "c=3**(1/3)\n", - "Z2=Z1*((Zl/Zo)**((2**-N)*(c**N)));\n", - "print \"Z2 = \",Z2\n", - "c=3**(1/3)\n", - "Z3=Z2*((Zl/Zo)**((2**-N)*(c**N)));\n", - "print \"Z3 = \",Z3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.8 page no:316" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the characteristic impedences are = 52.5641025641 , 52.5641025641 , 95.1219512195\n" - ] - } - ], - "source": [ - "#Exa 6.8 design three section chebysev transfomer\n", - "# example:−6.8,page no.−316.\n", - "from math import pi,cosh\n", - "from sympy import asec,acosh\n", - "# program to design a three section chebysev transformer .\n", - "Zl=100.;Zo=50.;taom=0.05;N=3;A=0.05;\n", - "thetam=asec(cosh((1/N)*acosh((1/taom)*abs((Zl-Zo)/(Zl+Zo)))))*(180/pi);\n", - "x=(cosh((1/N)*acosh((1/taom)*abs((Zl-Zo)/(Zl+Zo)))))\n", - "tao_o=A*(x**3)/2;\n", - "tao_1=(3*A*(x**3-x))/2; # from symmetry tao 3=tao \n", - "Z1=Zo*((1+tao_o)/(1-tao_o));\n", - "Z2=Z1*((1+tao_1)/(1-tao_1));\n", - "Z3=Zl*((1-tao_o)/(1+tao_o));\n", - "print \"the characteristic impedences are = \",Z1,\",\",Z2,\",\",Z3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 6.9 page no:323" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "tao o = -0.346573590279973\n", - "A= -3.54467649562\n" - ] - } - ], - "source": [ - "#Exa 6.9 design triangular taper and a klopfenstein taper\n", - "#example:−6.9,page no.−323.\n", - "from sympy import acosh,log\n", - "#program to designa triangular taper and a klopfenstein taper .\n", - "taom =0.02; Zl =50.; Zo =100.;\n", - "tao_o=0.5*log(Zl/Zo);\n", - "A=complex(acosh(tao_o/taom));\n", - "A=A.real;\n", - "print \"tao o = \",tao_o\n", - "print\"A= \",A" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/SwathiSyamala/SwathiSyamala_version_backup/Chapter_6_IMPEDENCE_MATCHING_AND.ipynb b/sample_notebooks/SwathiSyamala/SwathiSyamala_version_backup/Chapter_6_IMPEDENCE_MATCHING_AND.ipynb new file mode 100755 index 00000000..e50612ad --- /dev/null +++ b/sample_notebooks/SwathiSyamala/SwathiSyamala_version_backup/Chapter_6_IMPEDENCE_MATCHING_AND.ipynb @@ -0,0 +1,277 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 6 IMPEDENCE MATCHING AND TUNNING" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.1 page no:284" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "inductor of first circuit in nH = 38.9848400617\n", + "capacitor of the first circuit in pF = 0.9227738301\n", + "inductor of second circuit in nH = 46.138691505\n", + "capacitor of the second circuit in pF = 2.59898933745\n", + "\"NOTE:−for above specific problem Rl>Zo, positive X implies inductor , negative X implies capacitor , positive B implies capacitor and negative B implies inductor .\"\n" + ] + } + ], + "source": [ + "#Exa 6.1 program to design an L section matching network\n", + "# example:−6.1,page no.−284.\n", + "from math import pi,sqrt\n", + "from sympy import I\n", + "# program to design an L section matching network to match a series RC load.\n", + "Zl=200-I*100; # load impedence .\n", + "Rl=200;Xl=-100;f=500*10**6;Zo=100;\n", + "B1=(Xl+sqrt(Rl/Zo)*sqrt(Rl**2+Xl**2-(Rl*Zo)))/(Rl**2+Xl**2);\n", + "B2=(Xl-sqrt(Rl/Zo)*sqrt(Rl**2+Xl**2-(Rl*Zo)))/(Rl**2+Xl**2);\n", + "C1=(B1/(2*pi*f))*10**12;\n", + "L2=(-1/(B2*2*pi*f))*10**9;\n", + "X1=(1/B1)+((Xl*Zo)/Rl)-(Zo/(B1*Rl));\n", + "X2=(1/B2)+((Xl*Zo)/Rl)-(Zo/(B2*Rl));\n", + "L1=(X1/(2*pi*f))*10**9;\n", + "C2=(-1/(X2*2*pi*f))*10**12;\n", + "print\"inductor of first circuit in nH = \",L1\n", + "print\"capacitor of the first circuit in pF = \",C1\n", + "print\"inductor of second circuit in nH = \",L2\n", + "print\"capacitor of the second circuit in pF = \",C2 \n", + "print\"\\\"NOTE:−for above specific problem Rl>Zo, positive X implies inductor , negative X implies capacitor , positive B implies capacitor and negative B implies inductor .\\\"\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.2 page no:304" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "charecteristic impedence of matching section = 22.360679775\n", + " fractional bandwidth = 0.293159219438\n" + ] + } + ], + "source": [ + "#Exa 6.5 design quarter wave matching transformer\n", + "#example:−6.5,page no.−304.\n", + "from math import sqrt,pi,acos\n", + "#program to design a single section quarter wave matching transformer .\n", + "Zl=10; # load impedence .\n", + "Zo=50; # characteristic impedence .\n", + "fo=3*10**9;swr=1.5; # maximum limit of swr.\n", + "Z1=sqrt(Zo*Zl); # characteristic impedence of the matching section .\n", + "taom=(swr-1)/(swr+1);\n", + "frac_bw=2-(4/pi)*acos((taom/sqrt(1-taom**2))*(2*sqrt(Zo*Zl)/abs(Zl-Zo))); # fractional bandwidth .\n", + "print \"charecteristic impedence of matching section =\",Z1\n", + "print \" fractional bandwidth = \",frac_bw" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.6 page no:307" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "approximate value of reflection coefficient is = 0.4\n", + "the error in percent is about = 4.0\n" + ] + } + ], + "source": [ + "#Exa 6.6 program to evaluate the worst case percent error\n", + "# example:−6.6,page no.−307.\n", + "#from math import abs\n", + "# program to evaluate the worst case percent error in computing magnitude of reflection coefficient .\n", + "Z1 =100.; \n", + "Z2 =150.; \n", + "Zl =225.;\n", + "tao_1=(Z2-Z1)/(Z2+Z1);\n", + "tao_2=(Zl-Z2)/(Zl+Z2);\n", + "tao_exact=(tao_1+tao_2)/(1+tao_1*tao_2); # this results as angle is taken zero .\n", + "tao_approx=tao_1+tao_2; # this results as angle is taken zero .\n", + "eror=abs(((tao_exact -tao_approx)/tao_exact)*100);\n", + "print \"approximate value of reflection coefficient is = \",tao_approx\n", + "print \"the error in percent is about = \",eror" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.7 page no:312" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Z1 = 91.7004043205\n", + "Z2 = 84.0896415254\n", + "Z3 = 77.1105412704\n" + ] + } + ], + "source": [ + "#Exa 6.7 design three section binomial transformer\n", + "# example:−6.7,page no.−312.\n", + "from math import pi,acos\n", + "# program to design three section binomial transformer .\n", + "Zl=50.;Zo=100.;N=3;taom=0.05;\n", + "A=(2**-N)*abs((Zl-Zo)/(Zl+Zo));\n", + "frac_bw=2-(4/pi)*acos(0.5*(taom/A)**2);\n", + "c=1\n", + "Z1=Zo*((Zl/Zo)**((2**-N)*(c**N)));\n", + "print \"Z1 = \",Z1\n", + "c=3**(1/3)\n", + "Z2=Z1*((Zl/Zo)**((2**-N)*(c**N)));\n", + "print \"Z2 = \",Z2\n", + "c=3**(1/3)\n", + "Z3=Z2*((Zl/Zo)**((2**-N)*(c**N)));\n", + "print \"Z3 = \",Z3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.8 page no:316" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the characteristic impedences are = 52.5641025641 , 52.5641025641 , 95.1219512195\n" + ] + } + ], + "source": [ + "#Exa 6.8 design three section chebysev transfomer\n", + "# example:−6.8,page no.−316.\n", + "from math import pi,cosh\n", + "from sympy import asec,acosh\n", + "# program to design a three section chebysev transformer .\n", + "Zl=100.;Zo=50.;taom=0.05;N=3;A=0.05;\n", + "thetam=asec(cosh((1/N)*acosh((1/taom)*abs((Zl-Zo)/(Zl+Zo)))))*(180/pi);\n", + "x=(cosh((1/N)*acosh((1/taom)*abs((Zl-Zo)/(Zl+Zo)))))\n", + "tao_o=A*(x**3)/2;\n", + "tao_1=(3*A*(x**3-x))/2; # from symmetry tao 3=tao \n", + "Z1=Zo*((1+tao_o)/(1-tao_o));\n", + "Z2=Z1*((1+tao_1)/(1-tao_1));\n", + "Z3=Zl*((1-tao_o)/(1+tao_o));\n", + "print \"the characteristic impedences are = \",Z1,\",\",Z2,\",\",Z3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 6.9 page no:323" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "tao o = -0.346573590279973\n", + "A= -3.54467649562\n" + ] + } + ], + "source": [ + "#Exa 6.9 design triangular taper and a klopfenstein taper\n", + "#example:−6.9,page no.−323.\n", + "from sympy import acosh,log\n", + "#program to designa triangular taper and a klopfenstein taper .\n", + "taom =0.02; Zl =50.; Zo =100.;\n", + "tao_o=0.5*log(Zl/Zo);\n", + "A=complex(acosh(tao_o/taom));\n", + "A=A.real;\n", + "print \"tao o = \",tao_o\n", + "print\"A= \",A" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Tarun KumarDas/Chapter9.ipynb b/sample_notebooks/Tarun KumarDas/Chapter9.ipynb deleted file mode 100755 index 320477a8..00000000 --- a/sample_notebooks/Tarun KumarDas/Chapter9.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.5 Page 150" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=20#in\n", - "l=100#in\n", - "r=120#r.p.m\n", - "v=3.5#in\n", - "l2=1#in\n", - "l3=1/8#in\n", - "v1=1.44#omega in/sec\n", - "\n", - "#CALCULATIONS\n", - "V=p*(1.06/1.166)#omega in./sec\n", - "R=(V/v1)#omega in/sec\n", - "\n", - "#RESULTS\n", - "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.7 Page 151" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=0.6#in\n", - "m=1.0#in\n", - "t=0.75#in\n", - "p=4#in\n", - "\n", - "#CALCULATIONS\n", - "D=t/m#in\n", - "A=(p*m/D)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel and laps of the value is\",round(A,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel and laps of the value is 5.333 in\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.10 Page 154" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "l=1.5#in\n", - "p=4.0#in\n", - "v=0.98#in\n", - "\n", - "#CALCULATIONS\n", - "T=(l*p/v)#in\n", - "\n", - "#RESULTS\n", - "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the particulars of a value and it eccentric is 6.122 in\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.12 Page 156" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=1/10#in\n", - "v1=3/4#in\n", - "v2=3/5#in\n", - "m=1*1/2#in\n", - "l=4#cranks\n", - "a1=1.25#in\n", - "a2=0.7#in\n", - "\n", - "#CALCULATIONS\n", - "C=a1/a2#in\n", - "A=l*a1/a2#in\n", - "S=(A/2-a1)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel of the value is\",round(S,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel of the value is 2.321 in\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.17 Page 161" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=3*1/2#in\n", - "a=30#degree\n", - "l=0.8#in\n", - "v1=0.2#in\n", - "L=0.13#in\n", - "m=1.075#in\n", - "d=0.58#in\n", - "p=1.875#in\n", - "\n", - "#CALCULATIONS\n", - "V=(p-d)#in\n", - "P=V+1.25#in\n", - "\n", - "#RESULTS\n", - "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the main value and the maximum opening to steam is 2.545 in\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Chapter9_2.ipynb b/sample_notebooks/Tarun KumarDas/Chapter9_2.ipynb deleted file mode 100755 index 320477a8..00000000 --- a/sample_notebooks/Tarun KumarDas/Chapter9_2.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.5 Page 150" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=20#in\n", - "l=100#in\n", - "r=120#r.p.m\n", - "v=3.5#in\n", - "l2=1#in\n", - "l3=1/8#in\n", - "v1=1.44#omega in/sec\n", - "\n", - "#CALCULATIONS\n", - "V=p*(1.06/1.166)#omega in./sec\n", - "R=(V/v1)#omega in/sec\n", - "\n", - "#RESULTS\n", - "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.7 Page 151" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=0.6#in\n", - "m=1.0#in\n", - "t=0.75#in\n", - "p=4#in\n", - "\n", - "#CALCULATIONS\n", - "D=t/m#in\n", - "A=(p*m/D)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel and laps of the value is\",round(A,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel and laps of the value is 5.333 in\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.10 Page 154" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "l=1.5#in\n", - "p=4.0#in\n", - "v=0.98#in\n", - "\n", - "#CALCULATIONS\n", - "T=(l*p/v)#in\n", - "\n", - "#RESULTS\n", - "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the particulars of a value and it eccentric is 6.122 in\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.12 Page 156" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=1/10#in\n", - "v1=3/4#in\n", - "v2=3/5#in\n", - "m=1*1/2#in\n", - "l=4#cranks\n", - "a1=1.25#in\n", - "a2=0.7#in\n", - "\n", - "#CALCULATIONS\n", - "C=a1/a2#in\n", - "A=l*a1/a2#in\n", - "S=(A/2-a1)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel of the value is\",round(S,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel of the value is 2.321 in\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.17 Page 161" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=3*1/2#in\n", - "a=30#degree\n", - "l=0.8#in\n", - "v1=0.2#in\n", - "L=0.13#in\n", - "m=1.075#in\n", - "d=0.58#in\n", - "p=1.875#in\n", - "\n", - "#CALCULATIONS\n", - "V=(p-d)#in\n", - "P=V+1.25#in\n", - "\n", - "#RESULTS\n", - "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the main value and the maximum opening to steam is 2.545 in\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Chapter9_3.ipynb b/sample_notebooks/Tarun KumarDas/Chapter9_3.ipynb deleted file mode 100755 index 320477a8..00000000 --- a/sample_notebooks/Tarun KumarDas/Chapter9_3.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.5 Page 150" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=20#in\n", - "l=100#in\n", - "r=120#r.p.m\n", - "v=3.5#in\n", - "l2=1#in\n", - "l3=1/8#in\n", - "v1=1.44#omega in/sec\n", - "\n", - "#CALCULATIONS\n", - "V=p*(1.06/1.166)#omega in./sec\n", - "R=(V/v1)#omega in/sec\n", - "\n", - "#RESULTS\n", - "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.7 Page 151" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=0.6#in\n", - "m=1.0#in\n", - "t=0.75#in\n", - "p=4#in\n", - "\n", - "#CALCULATIONS\n", - "D=t/m#in\n", - "A=(p*m/D)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel and laps of the value is\",round(A,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel and laps of the value is 5.333 in\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.10 Page 154" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "l=1.5#in\n", - "p=4.0#in\n", - "v=0.98#in\n", - "\n", - "#CALCULATIONS\n", - "T=(l*p/v)#in\n", - "\n", - "#RESULTS\n", - "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the particulars of a value and it eccentric is 6.122 in\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.12 Page 156" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=1/10#in\n", - "v1=3/4#in\n", - "v2=3/5#in\n", - "m=1*1/2#in\n", - "l=4#cranks\n", - "a1=1.25#in\n", - "a2=0.7#in\n", - "\n", - "#CALCULATIONS\n", - "C=a1/a2#in\n", - "A=l*a1/a2#in\n", - "S=(A/2-a1)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel of the value is\",round(S,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel of the value is 2.321 in\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.17 Page 161" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=3*1/2#in\n", - "a=30#degree\n", - "l=0.8#in\n", - "v1=0.2#in\n", - "L=0.13#in\n", - "m=1.075#in\n", - "d=0.58#in\n", - "p=1.875#in\n", - "\n", - "#CALCULATIONS\n", - "V=(p-d)#in\n", - "P=V+1.25#in\n", - "\n", - "#RESULTS\n", - "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the main value and the maximum opening to steam is 2.545 in\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Chapter9_4.ipynb b/sample_notebooks/Tarun KumarDas/Chapter9_4.ipynb deleted file mode 100755 index 320477a8..00000000 --- a/sample_notebooks/Tarun KumarDas/Chapter9_4.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.5 Page 150" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=20#in\n", - "l=100#in\n", - "r=120#r.p.m\n", - "v=3.5#in\n", - "l2=1#in\n", - "l3=1/8#in\n", - "v1=1.44#omega in/sec\n", - "\n", - "#CALCULATIONS\n", - "V=p*(1.06/1.166)#omega in./sec\n", - "R=(V/v1)#omega in/sec\n", - "\n", - "#RESULTS\n", - "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.7 Page 151" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=0.6#in\n", - "m=1.0#in\n", - "t=0.75#in\n", - "p=4#in\n", - "\n", - "#CALCULATIONS\n", - "D=t/m#in\n", - "A=(p*m/D)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel and laps of the value is\",round(A,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel and laps of the value is 5.333 in\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.10 Page 154" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "l=1.5#in\n", - "p=4.0#in\n", - "v=0.98#in\n", - "\n", - "#CALCULATIONS\n", - "T=(l*p/v)#in\n", - "\n", - "#RESULTS\n", - "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the particulars of a value and it eccentric is 6.122 in\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.12 Page 156" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "p=1/10#in\n", - "v1=3/4#in\n", - "v2=3/5#in\n", - "m=1*1/2#in\n", - "l=4#cranks\n", - "a1=1.25#in\n", - "a2=0.7#in\n", - "\n", - "#CALCULATIONS\n", - "C=a1/a2#in\n", - "A=l*a1/a2#in\n", - "S=(A/2-a1)#in\n", - "\n", - "#RESULTS\n", - "print\"the travel of the value is\",round(S,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the travel of the value is 2.321 in\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 9.17 Page 161" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#initialisation of variable\n", - "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", - "v=3*1/2#in\n", - "a=30#degree\n", - "l=0.8#in\n", - "v1=0.2#in\n", - "L=0.13#in\n", - "m=1.075#in\n", - "d=0.58#in\n", - "p=1.875#in\n", - "\n", - "#CALCULATIONS\n", - "V=(p-d)#in\n", - "P=V+1.25#in\n", - "\n", - "#RESULTS\n", - "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the main value and the maximum opening to steam is 2.545 in\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9.ipynb b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9.ipynb new file mode 100755 index 00000000..320477a8 --- /dev/null +++ b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9.ipynb @@ -0,0 +1,227 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 Page 150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=20#in\n", + "l=100#in\n", + "r=120#r.p.m\n", + "v=3.5#in\n", + "l2=1#in\n", + "l3=1/8#in\n", + "v1=1.44#omega in/sec\n", + "\n", + "#CALCULATIONS\n", + "V=p*(1.06/1.166)#omega in./sec\n", + "R=(V/v1)#omega in/sec\n", + "\n", + "#RESULTS\n", + "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7 Page 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=0.6#in\n", + "m=1.0#in\n", + "t=0.75#in\n", + "p=4#in\n", + "\n", + "#CALCULATIONS\n", + "D=t/m#in\n", + "A=(p*m/D)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel and laps of the value is\",round(A,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel and laps of the value is 5.333 in\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10 Page 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "l=1.5#in\n", + "p=4.0#in\n", + "v=0.98#in\n", + "\n", + "#CALCULATIONS\n", + "T=(l*p/v)#in\n", + "\n", + "#RESULTS\n", + "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the particulars of a value and it eccentric is 6.122 in\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.12 Page 156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=1/10#in\n", + "v1=3/4#in\n", + "v2=3/5#in\n", + "m=1*1/2#in\n", + "l=4#cranks\n", + "a1=1.25#in\n", + "a2=0.7#in\n", + "\n", + "#CALCULATIONS\n", + "C=a1/a2#in\n", + "A=l*a1/a2#in\n", + "S=(A/2-a1)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel of the value is\",round(S,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel of the value is 2.321 in\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.17 Page 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=3*1/2#in\n", + "a=30#degree\n", + "l=0.8#in\n", + "v1=0.2#in\n", + "L=0.13#in\n", + "m=1.075#in\n", + "d=0.58#in\n", + "p=1.875#in\n", + "\n", + "#CALCULATIONS\n", + "V=(p-d)#in\n", + "P=V+1.25#in\n", + "\n", + "#RESULTS\n", + "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the main value and the maximum opening to steam is 2.545 in\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_2.ipynb b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_2.ipynb new file mode 100755 index 00000000..320477a8 --- /dev/null +++ b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_2.ipynb @@ -0,0 +1,227 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 Page 150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=20#in\n", + "l=100#in\n", + "r=120#r.p.m\n", + "v=3.5#in\n", + "l2=1#in\n", + "l3=1/8#in\n", + "v1=1.44#omega in/sec\n", + "\n", + "#CALCULATIONS\n", + "V=p*(1.06/1.166)#omega in./sec\n", + "R=(V/v1)#omega in/sec\n", + "\n", + "#RESULTS\n", + "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7 Page 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=0.6#in\n", + "m=1.0#in\n", + "t=0.75#in\n", + "p=4#in\n", + "\n", + "#CALCULATIONS\n", + "D=t/m#in\n", + "A=(p*m/D)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel and laps of the value is\",round(A,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel and laps of the value is 5.333 in\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10 Page 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "l=1.5#in\n", + "p=4.0#in\n", + "v=0.98#in\n", + "\n", + "#CALCULATIONS\n", + "T=(l*p/v)#in\n", + "\n", + "#RESULTS\n", + "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the particulars of a value and it eccentric is 6.122 in\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.12 Page 156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=1/10#in\n", + "v1=3/4#in\n", + "v2=3/5#in\n", + "m=1*1/2#in\n", + "l=4#cranks\n", + "a1=1.25#in\n", + "a2=0.7#in\n", + "\n", + "#CALCULATIONS\n", + "C=a1/a2#in\n", + "A=l*a1/a2#in\n", + "S=(A/2-a1)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel of the value is\",round(S,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel of the value is 2.321 in\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.17 Page 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=3*1/2#in\n", + "a=30#degree\n", + "l=0.8#in\n", + "v1=0.2#in\n", + "L=0.13#in\n", + "m=1.075#in\n", + "d=0.58#in\n", + "p=1.875#in\n", + "\n", + "#CALCULATIONS\n", + "V=(p-d)#in\n", + "P=V+1.25#in\n", + "\n", + "#RESULTS\n", + "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the main value and the maximum opening to steam is 2.545 in\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_3.ipynb b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_3.ipynb new file mode 100755 index 00000000..320477a8 --- /dev/null +++ b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_3.ipynb @@ -0,0 +1,227 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 Page 150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=20#in\n", + "l=100#in\n", + "r=120#r.p.m\n", + "v=3.5#in\n", + "l2=1#in\n", + "l3=1/8#in\n", + "v1=1.44#omega in/sec\n", + "\n", + "#CALCULATIONS\n", + "V=p*(1.06/1.166)#omega in./sec\n", + "R=(V/v1)#omega in/sec\n", + "\n", + "#RESULTS\n", + "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7 Page 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=0.6#in\n", + "m=1.0#in\n", + "t=0.75#in\n", + "p=4#in\n", + "\n", + "#CALCULATIONS\n", + "D=t/m#in\n", + "A=(p*m/D)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel and laps of the value is\",round(A,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel and laps of the value is 5.333 in\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10 Page 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "l=1.5#in\n", + "p=4.0#in\n", + "v=0.98#in\n", + "\n", + "#CALCULATIONS\n", + "T=(l*p/v)#in\n", + "\n", + "#RESULTS\n", + "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the particulars of a value and it eccentric is 6.122 in\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.12 Page 156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=1/10#in\n", + "v1=3/4#in\n", + "v2=3/5#in\n", + "m=1*1/2#in\n", + "l=4#cranks\n", + "a1=1.25#in\n", + "a2=0.7#in\n", + "\n", + "#CALCULATIONS\n", + "C=a1/a2#in\n", + "A=l*a1/a2#in\n", + "S=(A/2-a1)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel of the value is\",round(S,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel of the value is 2.321 in\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.17 Page 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=3*1/2#in\n", + "a=30#degree\n", + "l=0.8#in\n", + "v1=0.2#in\n", + "L=0.13#in\n", + "m=1.075#in\n", + "d=0.58#in\n", + "p=1.875#in\n", + "\n", + "#CALCULATIONS\n", + "V=(p-d)#in\n", + "P=V+1.25#in\n", + "\n", + "#RESULTS\n", + "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the main value and the maximum opening to steam is 2.545 in\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_4.ipynb b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_4.ipynb new file mode 100755 index 00000000..320477a8 --- /dev/null +++ b/sample_notebooks/Tarun KumarDas/Tarun KumarDas_version_backup/Chapter9_4.ipynb @@ -0,0 +1,227 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:023bb2358c5a7a6740b1b9a08290e11f954e790555a353817bbe84615e4679e6" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 9: VALVE DIAGRAMS AND VALVE GEARS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.5 Page 150" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=20#in\n", + "l=100#in\n", + "r=120#r.p.m\n", + "v=3.5#in\n", + "l2=1#in\n", + "l3=1/8#in\n", + "v1=1.44#omega in/sec\n", + "\n", + "#CALCULATIONS\n", + "V=p*(1.06/1.166)#omega in./sec\n", + "R=(V/v1)#omega in/sec\n", + "\n", + "#RESULTS\n", + "print\"The ratio of velocity of the piston to the velocity is\",round(R,3),\"Omega in/sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The ratio of velocity of the piston to the velocity is 12.626 Omega in/sec\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.7 Page 151" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=0.6#in\n", + "m=1.0#in\n", + "t=0.75#in\n", + "p=4#in\n", + "\n", + "#CALCULATIONS\n", + "D=t/m#in\n", + "A=(p*m/D)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel and laps of the value is\",round(A,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel and laps of the value is 5.333 in\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.10 Page 154" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "l=1.5#in\n", + "p=4.0#in\n", + "v=0.98#in\n", + "\n", + "#CALCULATIONS\n", + "T=(l*p/v)#in\n", + "\n", + "#RESULTS\n", + "print\"the particulars of a value and it eccentric is\",round(T,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the particulars of a value and it eccentric is 6.122 in\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.12 Page 156" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "p=1/10#in\n", + "v1=3/4#in\n", + "v2=3/5#in\n", + "m=1*1/2#in\n", + "l=4#cranks\n", + "a1=1.25#in\n", + "a2=0.7#in\n", + "\n", + "#CALCULATIONS\n", + "C=a1/a2#in\n", + "A=l*a1/a2#in\n", + "S=(A/2-a1)#in\n", + "\n", + "#RESULTS\n", + "print\"the travel of the value is\",round(S,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the travel of the value is 2.321 in\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 9.17 Page 161" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#initialisation of variable\n", + "from math import pi,sqrt,acos,asin,atan,cos,sin,tan\n", + "v=3*1/2#in\n", + "a=30#degree\n", + "l=0.8#in\n", + "v1=0.2#in\n", + "L=0.13#in\n", + "m=1.075#in\n", + "d=0.58#in\n", + "p=1.875#in\n", + "\n", + "#CALCULATIONS\n", + "V=(p-d)#in\n", + "P=V+1.25#in\n", + "\n", + "#RESULTS\n", + "print\"the main value and the maximum opening to steam is\",round(P,3),\"in\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the main value and the maximum opening to steam is 2.545 in\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/TestUser/TestUser_version_backup/chapter1.ipynb b/sample_notebooks/TestUser/TestUser_version_backup/chapter1.ipynb new file mode 100755 index 00000000..cf45a409 --- /dev/null +++ b/sample_notebooks/TestUser/TestUser_version_backup/chapter1.ipynb @@ -0,0 +1,423 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1: Tension Comprssion and Shear" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1, page no. 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "Find compressive stress and strain in the post\n", + "\"\"\"\n", + "\n", + "import math\n", + "\n", + "#initialisation\n", + "\n", + "d_1 = 4 # inner diameter (inch)\n", + "d_2 = 4.5 #outer diameter (inch)\n", + "P = 26000 # pressure in pound\n", + "L = 16 # Length of cylinder (inch)\n", + "my_del = 0.012 # shortening of post (inch)\n", + "\n", + "#calculation\n", + "A = (math.pi/4)*((d_2**2)-(d_1**2)) #Area (inch^2)\n", + "s = P/A # stress\n", + "\n", + "print \"compressive stress in the post is \", round(s), \"psi\"\n", + "\n", + "e = my_del/L # strain\n", + "\n", + "print \"compressive strain in the post is %e\" %e" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "compressive stress in the post is 7789.0 psi\n", + "compressive strain in the post is 7.500000e-04\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2, page no. 10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "formula for maximum stress & calculating maximum stress\n", + "\"\"\"\n", + "\n", + "import math \n", + "\n", + "#initialisation\n", + "W = 1500 # weight (Newton)\n", + "d = 0.008 #diameter(meter) \n", + "g = 77000 # Weight density of steel\n", + "L = 40 # Length of bar (m)\n", + "\n", + "#calculation\n", + "\n", + "A = (math.pi/4)*(d**2) # Area\n", + "s_max = (1500/A) + (g*L) # maximum stress\n", + "\n", + "#result\n", + "print \"Therefore the maximum stress in the rod is \", round(s_max,1), \"Pa\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Therefore the maximum stress in the rod is 32921551.8 Pa\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.3. page no. 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "calculating change in lenght of pipe, strain in pipe, increase in diameter & increase in wall thickness\n", + "\"\"\"\n", + "\n", + "import math \n", + "\n", + "#initialisation\n", + "d1 = 4.5 # diameter in inch\n", + "d2 = 6 # diameter in inch\n", + "A = (math.pi/4)*((d2**2)-(d1**2)) # Area\n", + "P = 140 # pressure in K\n", + "s = -P/A # stress (compression)\n", + "E = 30000 # young's modulus in Ksi\n", + "e = s/E # strain\n", + "\n", + "#calculation\n", + "\n", + "# Part (a)\n", + "my_del = e*4*12 # del = e*L \n", + "print \"Change in length of the pipe is\", round(my_del,3), \"inch\"\n", + "\n", + "# Part (b)\n", + "v = 0.30 # Poissio's ratio\n", + "e_ = -(v*e)\n", + "print \"Lateral strain in the pipe is %e\" %e_\n", + "\n", + "# Part (c)\n", + "del_d2 = e_*d2 \n", + "del_d1 = e_*d1\n", + "print \"Increase in the inner diameter is \", round(del_d1,6), \"inch\"\n", + "\n", + "# Part (d)\n", + "t = 0.75\n", + "del_t = e_*t\n", + "print \"Increase in the wall thicness is %f\" %del_t, \"inch\"\n", + "del_t1 = (del_d2-del_d1)/2 \n", + "print \"del_t1 = del_t\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Change in length of the pipe is -0.018 inch\n", + "Lateral strain in the pipe is 1.131768e-04\n", + "Increase in the inner diameter is 0.000509 inch\n", + "Increase in the wall thicness is 0.000085 inch\n", + "del_t1 = del_t\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4, page no. 35" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "calculate average shear stress and compressive stress\n", + "\"\"\"\n", + "\n", + "import math \n", + "\n", + "#initialisation\n", + "d = 0.02 # diameter in m\n", + "t = 0.008 # thickness in m\n", + "A = math.pi*d*t # shear area\n", + "P = 110000 # prassure in Newton\n", + "\n", + "#calculation\n", + "A1 = (math.pi/4)*(d**2) # Punch area\n", + "t_aver = P/A # Average shear stress \n", + "\n", + "\n", + "print \"Average shear stress in the plate is \", t_aver, \"Pa\"\n", + "s_c = P/A1 # compressive stress\n", + "print \"Average compressive stress in the plate is \", s_c, \"Pa\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Average shear stress in the plate is 218838046.751 Pa\n", + "Average compressive stress in the plate is 350140874.802 Pa\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Eample 1.5, page no. 36" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "calculate bearing stress, shear stress in pin,\n", + "bearing stress between pin and gussets,\n", + "shear stress in anchor bolts\n", + "\"\"\"\n", + "\n", + "import math \n", + "\n", + "#initialisation\n", + "\n", + "P = 12.0 # Pressure in K\n", + "t = 0.375 # thickness of wall in inch\n", + "theta = 40.0 # angle in degree\n", + "d_pin = 0.75 # diameter of pin in inch\n", + "t_G = 0.625 # thickness of gusset in inch\n", + "t_B = 0.375 #thickness of base plate in inch\n", + "d_b = 0.50 # diameter of bolt in inch\n", + "\n", + "#calculation\n", + "\n", + "#Part (a)\n", + "s_b1 = P/(2*t*d_pin) # bearing stress\n", + "print \"Bearing stress between strut and pin\", round(s_b1,1), \"ksi\"\n", + "\n", + "#Part (b)\n", + "t_pin = (4*P)/(2*math.pi*(d_pin**2)) # average shear stress in the \n", + "print \"Shear stress in pin is \", round(t_pin,1), \"ksi\"\n", + "\n", + "# Part (c)\n", + "s_b2 = P/(2*t_G*d_pin) # bearing stress between pin and gusset\n", + "print \"Bearing stress between pin and gussets is\", s_b2, \"ksi\"\n", + "\n", + "# Part (d)\n", + "s_b3 = (P*math.cos(math.radians(40))/(4*t_B*d_b)) # bearing stress between anchor bolt and base plate\n", + "print \"Bearing stress between anchor bolts & base plate\", round(s_b3,1), \"ksi\"\n", + "\n", + "# Part (e)\n", + "t_bolt = (4*math.cos(math.radians(40))*P)/(4*math.pi*(d_b**2)) # shear stress in anchor bolt\n", + "print \"Shear stress in anchor bolts is\", round(t_bolt,1), \"ksi\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Bearing stress between strut and pin 21.3 ksi\n", + "Shear stress in pin is 13.6 ksi\n", + "Bearing stress between pin and gussets is 12.8 ksi\n", + "Bearing stress between anchor bolts & base plate 12.3 ksi\n", + "Shear stress in anchor bolts is 11.7 ksi\n" + ] + } + ], + "prompt_number": 39 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, page no. 42" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "determine stress at various parts\n", + "\"\"\"\n", + "\n", + "import math\n", + "\n", + "#initialisation\n", + "b1 = 1.5 # width of recmath.tangular crosssection in inch\n", + "t = 0.5 # thickness of recmath.tangular crosssection in inch\n", + "b2 = 3.0 # width of enlarged recmath.tangular crosssection in inch\n", + "d = 1.0 # diameter in inch\n", + "\n", + "#calculation\n", + "\n", + "# Part (a)\n", + "s_1 = 16000 # maximum allowable tensile stress in Psi\n", + "P_1 = s_1*t*b1 \n", + "print \"The allowable load P1 is\", P_1, \"lb\"\n", + "\n", + "# Part (b)\n", + "s_2 = 11000 # maximum allowable tensile stress in Psi\n", + "P_2 = s_2*t*(b2-d) \n", + "print \"allowable load P2 at this section is\", P_2, \"lb\"\n", + "\n", + "#Part (c)\n", + "s_3 = 26000 # maximum allowable tensile stress in Psi\n", + "P_3 = s_3*t*d \n", + "print \"The allowable load based upon bearing between the hanger and the bolt is\", P_3, \"lb\"\n", + "\n", + "# Part (d)\n", + "s_4 = 6500 # maximum allowable tensile stress in Psi\n", + "P_4 = (math.pi/4)*(d**2)*2*s_4 \n", + "print \"the allowable load P4 based upon shear in the bolt is\", round(P_4), \"lb\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The allowable load P1 is 12000.0 lb\n", + "allowable load P2 at this section is 11000.0 lb\n", + "The allowable load based upon bearing between the hanger and the bolt is 13000.0 lb\n", + "the allowable load P4 based upon shear in the bolt is 10210.0 lb\n" + ] + } + ], + "prompt_number": 42 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8, page no. 46" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\"\"\"\n", + "calculating the cross sectional area \n", + "\"\"\"\n", + "\n", + "import math \n", + "\n", + "#initialisation\n", + "R_ah = (2700*0.8 + 2700*2.6)/2 # Horizontal component at A in N\n", + "R_ch = R_ah # Horizontal component at C in N\n", + "R_cv = (2700*2.2 + 2700*0.4)/3 # vertical component at C in N\n", + "R_av = 2700 + 2700 - R_cv # vertical component at A in N\n", + "R_a = math.sqrt((R_ah**2)+(R_av**2))\n", + "R_c = math.sqrt((R_ch**2)+(R_cv**2))\n", + "Fab = R_a # Tensile force in bar AB\n", + "Vc = R_c # Shear force acting on the pin at C\n", + "s_allow = 125000000 # allowable stress in tension \n", + "t_allow = 45000000 # allowable stress in shear\n", + "\n", + "#calculation\n", + "Aab = Fab / s_allow # required area of bar \n", + "Apin = Vc / (2*t_allow) # required area of pin\n", + "\n", + "\n", + "print \"Required area of bar is %f\" %Apin, \"m^2\"\n", + "d = math.sqrt((4*Apin)/math.pi) # diameter in meter\n", + "print \"Required diameter of pin is %f\" %d, \"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Required area of bar is 0.000057 m^2\n", + "Required diameter of pin is 0.008537 m\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/TestUser/chapter1.ipynb b/sample_notebooks/TestUser/chapter1.ipynb deleted file mode 100755 index cf45a409..00000000 --- a/sample_notebooks/TestUser/chapter1.ipynb +++ /dev/null @@ -1,423 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1: Tension Comprssion and Shear" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1, page no. 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "Find compressive stress and strain in the post\n", - "\"\"\"\n", - "\n", - "import math\n", - "\n", - "#initialisation\n", - "\n", - "d_1 = 4 # inner diameter (inch)\n", - "d_2 = 4.5 #outer diameter (inch)\n", - "P = 26000 # pressure in pound\n", - "L = 16 # Length of cylinder (inch)\n", - "my_del = 0.012 # shortening of post (inch)\n", - "\n", - "#calculation\n", - "A = (math.pi/4)*((d_2**2)-(d_1**2)) #Area (inch^2)\n", - "s = P/A # stress\n", - "\n", - "print \"compressive stress in the post is \", round(s), \"psi\"\n", - "\n", - "e = my_del/L # strain\n", - "\n", - "print \"compressive strain in the post is %e\" %e" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "compressive stress in the post is 7789.0 psi\n", - "compressive strain in the post is 7.500000e-04\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2, page no. 10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "formula for maximum stress & calculating maximum stress\n", - "\"\"\"\n", - "\n", - "import math \n", - "\n", - "#initialisation\n", - "W = 1500 # weight (Newton)\n", - "d = 0.008 #diameter(meter) \n", - "g = 77000 # Weight density of steel\n", - "L = 40 # Length of bar (m)\n", - "\n", - "#calculation\n", - "\n", - "A = (math.pi/4)*(d**2) # Area\n", - "s_max = (1500/A) + (g*L) # maximum stress\n", - "\n", - "#result\n", - "print \"Therefore the maximum stress in the rod is \", round(s_max,1), \"Pa\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Therefore the maximum stress in the rod is 32921551.8 Pa\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.3. page no. 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "calculating change in lenght of pipe, strain in pipe, increase in diameter & increase in wall thickness\n", - "\"\"\"\n", - "\n", - "import math \n", - "\n", - "#initialisation\n", - "d1 = 4.5 # diameter in inch\n", - "d2 = 6 # diameter in inch\n", - "A = (math.pi/4)*((d2**2)-(d1**2)) # Area\n", - "P = 140 # pressure in K\n", - "s = -P/A # stress (compression)\n", - "E = 30000 # young's modulus in Ksi\n", - "e = s/E # strain\n", - "\n", - "#calculation\n", - "\n", - "# Part (a)\n", - "my_del = e*4*12 # del = e*L \n", - "print \"Change in length of the pipe is\", round(my_del,3), \"inch\"\n", - "\n", - "# Part (b)\n", - "v = 0.30 # Poissio's ratio\n", - "e_ = -(v*e)\n", - "print \"Lateral strain in the pipe is %e\" %e_\n", - "\n", - "# Part (c)\n", - "del_d2 = e_*d2 \n", - "del_d1 = e_*d1\n", - "print \"Increase in the inner diameter is \", round(del_d1,6), \"inch\"\n", - "\n", - "# Part (d)\n", - "t = 0.75\n", - "del_t = e_*t\n", - "print \"Increase in the wall thicness is %f\" %del_t, \"inch\"\n", - "del_t1 = (del_d2-del_d1)/2 \n", - "print \"del_t1 = del_t\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Change in length of the pipe is -0.018 inch\n", - "Lateral strain in the pipe is 1.131768e-04\n", - "Increase in the inner diameter is 0.000509 inch\n", - "Increase in the wall thicness is 0.000085 inch\n", - "del_t1 = del_t\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4, page no. 35" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "calculate average shear stress and compressive stress\n", - "\"\"\"\n", - "\n", - "import math \n", - "\n", - "#initialisation\n", - "d = 0.02 # diameter in m\n", - "t = 0.008 # thickness in m\n", - "A = math.pi*d*t # shear area\n", - "P = 110000 # prassure in Newton\n", - "\n", - "#calculation\n", - "A1 = (math.pi/4)*(d**2) # Punch area\n", - "t_aver = P/A # Average shear stress \n", - "\n", - "\n", - "print \"Average shear stress in the plate is \", t_aver, \"Pa\"\n", - "s_c = P/A1 # compressive stress\n", - "print \"Average compressive stress in the plate is \", s_c, \"Pa\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Average shear stress in the plate is 218838046.751 Pa\n", - "Average compressive stress in the plate is 350140874.802 Pa\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Eample 1.5, page no. 36" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "calculate bearing stress, shear stress in pin,\n", - "bearing stress between pin and gussets,\n", - "shear stress in anchor bolts\n", - "\"\"\"\n", - "\n", - "import math \n", - "\n", - "#initialisation\n", - "\n", - "P = 12.0 # Pressure in K\n", - "t = 0.375 # thickness of wall in inch\n", - "theta = 40.0 # angle in degree\n", - "d_pin = 0.75 # diameter of pin in inch\n", - "t_G = 0.625 # thickness of gusset in inch\n", - "t_B = 0.375 #thickness of base plate in inch\n", - "d_b = 0.50 # diameter of bolt in inch\n", - "\n", - "#calculation\n", - "\n", - "#Part (a)\n", - "s_b1 = P/(2*t*d_pin) # bearing stress\n", - "print \"Bearing stress between strut and pin\", round(s_b1,1), \"ksi\"\n", - "\n", - "#Part (b)\n", - "t_pin = (4*P)/(2*math.pi*(d_pin**2)) # average shear stress in the \n", - "print \"Shear stress in pin is \", round(t_pin,1), \"ksi\"\n", - "\n", - "# Part (c)\n", - "s_b2 = P/(2*t_G*d_pin) # bearing stress between pin and gusset\n", - "print \"Bearing stress between pin and gussets is\", s_b2, \"ksi\"\n", - "\n", - "# Part (d)\n", - "s_b3 = (P*math.cos(math.radians(40))/(4*t_B*d_b)) # bearing stress between anchor bolt and base plate\n", - "print \"Bearing stress between anchor bolts & base plate\", round(s_b3,1), \"ksi\"\n", - "\n", - "# Part (e)\n", - "t_bolt = (4*math.cos(math.radians(40))*P)/(4*math.pi*(d_b**2)) # shear stress in anchor bolt\n", - "print \"Shear stress in anchor bolts is\", round(t_bolt,1), \"ksi\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Bearing stress between strut and pin 21.3 ksi\n", - "Shear stress in pin is 13.6 ksi\n", - "Bearing stress between pin and gussets is 12.8 ksi\n", - "Bearing stress between anchor bolts & base plate 12.3 ksi\n", - "Shear stress in anchor bolts is 11.7 ksi\n" - ] - } - ], - "prompt_number": 39 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, page no. 42" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "determine stress at various parts\n", - "\"\"\"\n", - "\n", - "import math\n", - "\n", - "#initialisation\n", - "b1 = 1.5 # width of recmath.tangular crosssection in inch\n", - "t = 0.5 # thickness of recmath.tangular crosssection in inch\n", - "b2 = 3.0 # width of enlarged recmath.tangular crosssection in inch\n", - "d = 1.0 # diameter in inch\n", - "\n", - "#calculation\n", - "\n", - "# Part (a)\n", - "s_1 = 16000 # maximum allowable tensile stress in Psi\n", - "P_1 = s_1*t*b1 \n", - "print \"The allowable load P1 is\", P_1, \"lb\"\n", - "\n", - "# Part (b)\n", - "s_2 = 11000 # maximum allowable tensile stress in Psi\n", - "P_2 = s_2*t*(b2-d) \n", - "print \"allowable load P2 at this section is\", P_2, \"lb\"\n", - "\n", - "#Part (c)\n", - "s_3 = 26000 # maximum allowable tensile stress in Psi\n", - "P_3 = s_3*t*d \n", - "print \"The allowable load based upon bearing between the hanger and the bolt is\", P_3, \"lb\"\n", - "\n", - "# Part (d)\n", - "s_4 = 6500 # maximum allowable tensile stress in Psi\n", - "P_4 = (math.pi/4)*(d**2)*2*s_4 \n", - "print \"the allowable load P4 based upon shear in the bolt is\", round(P_4), \"lb\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The allowable load P1 is 12000.0 lb\n", - "allowable load P2 at this section is 11000.0 lb\n", - "The allowable load based upon bearing between the hanger and the bolt is 13000.0 lb\n", - "the allowable load P4 based upon shear in the bolt is 10210.0 lb\n" - ] - } - ], - "prompt_number": 42 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8, page no. 46" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\"\"\"\n", - "calculating the cross sectional area \n", - "\"\"\"\n", - "\n", - "import math \n", - "\n", - "#initialisation\n", - "R_ah = (2700*0.8 + 2700*2.6)/2 # Horizontal component at A in N\n", - "R_ch = R_ah # Horizontal component at C in N\n", - "R_cv = (2700*2.2 + 2700*0.4)/3 # vertical component at C in N\n", - "R_av = 2700 + 2700 - R_cv # vertical component at A in N\n", - "R_a = math.sqrt((R_ah**2)+(R_av**2))\n", - "R_c = math.sqrt((R_ch**2)+(R_cv**2))\n", - "Fab = R_a # Tensile force in bar AB\n", - "Vc = R_c # Shear force acting on the pin at C\n", - "s_allow = 125000000 # allowable stress in tension \n", - "t_allow = 45000000 # allowable stress in shear\n", - "\n", - "#calculation\n", - "Aab = Fab / s_allow # required area of bar \n", - "Apin = Vc / (2*t_allow) # required area of pin\n", - "\n", - "\n", - "print \"Required area of bar is %f\" %Apin, \"m^2\"\n", - "d = math.sqrt((4*Apin)/math.pi) # diameter in meter\n", - "print \"Required diameter of pin is %f\" %d, \"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Required area of bar is 0.000057 m^2\n", - "Required diameter of pin is 0.008537 m\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/UmangAgarwal/Sample_Notebook.ipynb b/sample_notebooks/UmangAgarwal/Sample_Notebook.ipynb deleted file mode 100755 index 34fb4a40..00000000 --- a/sample_notebooks/UmangAgarwal/Sample_Notebook.ipynb +++ /dev/null @@ -1,128 +0,0 @@ -Sample Notebook - Heat and Mass Transfer by R.K. Rajput : Chapter 1 - Basic Concepts -author: Umang Agarwal - - -# Example 1.1 Page 16-17 - -L=.045; #[m] - Thickness of conducting wall -delT = 350 - 50; #[C] - Temperature Difference across the Wall -k=370; #[W/m.C] - Thermal Conductivity of Wall Material -#calculations -#Using Fourier's Law eq 1.1 -q = k*delT/(L*10**6); #[MW/m^2] - Heat Flux -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer per unit area =",q," W"); -#END - -# Example 1.2 Page 17 - -L = .15; #[m] - Thickness of conducting wall -delT = 150 - 45; #[C] - Temperature Difference across the Wall -A = 4.5; #[m^2] - Wall Area -k=9.35; #[W/m.C] - Thermal Conductivity of Wall Material -#calculations -#Using Fourier's Law eq 1.1 -Q = k*A*delT/L; #[W] - Heat Transfer -#Temperature gradient using Fourier's Law -TG = - Q/(k*A); #[C/m] - Temperature Gradient -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer per unit area =",Q," W"); -print '%s %.2f %s' %("\n \n The Temperature Gradient in the flow direction =",TG," C/m"); -#END - -# Example 1.3 Page 17-18 - -x = .0825; #[m] - Thickness of side wall of the conducting oven -delT = 175 - 75; #[C] - Temperature Difference across the Wall -k=0.044; #[W/m.C] - Thermal Conductivity of Wall Insulation -Q = 40.5; #[W] - Energy dissipitated by the electric coil withn the oven -#calculations -#Using Fourier's Law eq 1.1 -A = (Q*x)/(k*delT); #[m^2] - Area of wall -#results -print '%s %.2f %s' %("\n \n Area of the wall =",A," m^2"); -#END - -# Example 1.4 Page 18-19 - -delT = 300-20; #[C] - Temperature Difference across the Wall -h = 20; #[W/m^2.C] - Convective Heat Transfer Coefficient -A = 1*1.5; #[m^2] - Wall Area -#calculations -#Using Newton's Law of cooling eq 1.6 -Q = h*A*delT; #[W] - Heat Transfer -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer =",Q," W"); -#END - -# Example 1.5 Page 19 - -L=.15; #[m] - Length of conducting wire -d = 0.0015; #[m] - Diameter of conducting wire -A = 22*d*L/7; #[m^2] - Surface Area exposed to Convection -delT = 120 - 100; #[C] - Temperature Difference across the Wire -h = 4500; #[W/m^2.C] - Convective Heat Transfer Coefficient -print 'Electric Power to be supplied = Convective Heat loss'; -#calculations -#Using Newton's Law of cooling eq 1.6 -Q = h*A*delT; #[W] - Heat Transfer -Q = round(Q,1); -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer =",Q," W"); -#END - -# Example 1.6 Page 20-21 - -T1 = 300 + 273; #[K] - Temperature of 1st surface -T2 = 40 + 273; #[K] - Temperature of 2nd surface -A = 1.5; #[m^2] - Surface Area -F = 0.52; #[dimensionless] - The value of Factor due geometric location and emissivity -sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant -#calculations -#Using Stephen-Boltzmann Law eq 1.9 -Q = F*sigma*A*(T1**4 - T2**4) #[W] - Heat Transfer -#Equivalent Thermal Resistance using eq 1.10 -Rth = (T1-T2)/Q; #[C/W] - Equivalent Thermal Resistance -#Equivalent convectoin coefficient using h*A*(T1-T2) = Q -h = Q/(A*(T1-T2)); #[W/(m^2*C)] - Equivalent Convection Coefficient -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer =",Q," W"); -print '%s %.2f %s' %("\n The equivalent thermal resistance =",Rth," C/W"); -print '%s %.2f %s' %("\n The equivalent convection coefficient =",h," W/(m^2 * C)"); -#END - -# Example 1.7 Page 21-22 - -L = 0.025; #[m] - Thickness of plate -A = 0.6*0.9; #[m^2] - Area of plate -Ts = 310; #[C] - Surface Temperature of plate -Tf = 15; #[C] - Temperature of fluid(air) -h = 22; #[W/m^2.C] - Convective Heat Transfer Coefficient -Qr = 250; #[W] - Heat lost from the plate due to radiation -k = 45; #[W/m.C] - Thermal Conductivity of Plate -#calculations -# In this problem, heat conducted by the plate is removed by a combination of convection and radiation -# Heat conducted through the plate = Convection Heat losses + Radiation Losses -# If Ti is the internal plate temperature, then heat conducted = k*A*(Ts-Ti)/L -Qc = h*A*(Ts-Tf); #[W] - Convection Heat Loss -Ti = Ts + L*(Qc + Qr)/(A*k); #[C] - Inside plate Temperature -#results -print '%s %.2f %s' %("\n \n Rate of Heat Transfer =",Ti," C"); -#END - -# Example 1.8 Page 22 - -Ts = 250; #[C] - Surface Temperature -Tsurr = 110; #[C] - Temperature of surroundings -h = 75; #[W/m^2.C] - Convective Heat Transfer Coefficient -F = 1; #[dimensionless] - The value of Factor due geometric location and emissivity -sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant -k = 10; #[W/m.C] - Thermal Conductivity of Solid -#calculations -# Heat conducted through the plate = Convection Heat losses + Radiation Losses -qr = F*sigma*((Ts+273)**4-(Tsurr+273)**4) #[W/m^2] - #[W] - Heat lost per unit area from the plate due to radiation -qc = h*(Ts-Tsurr); #[W/m^2] - Convection Heat Loss per unit area -TG = -(qc+qr)/k; #[C/m] - Temperature Gradient -#results -print '%s %.2f %s' %("\n \n The temperature Gradient =",TG," C/m"); -#END diff --git a/sample_notebooks/UmangAgarwal/Sample_Notebook_Umang.ipynb b/sample_notebooks/UmangAgarwal/Sample_Notebook_Umang.ipynb deleted file mode 100755 index 1eb49726..00000000 --- a/sample_notebooks/UmangAgarwal/Sample_Notebook_Umang.ipynb +++ /dev/null @@ -1,163 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "Sample Notebook - Heat and Mass Transfer by R.K. Rajput : Chapter 1 - Basic Concepts\n", - "author: Umang Agarwal\n", - "\n", - "\n", - "# Example 1.1 Page 16-17\n", - "\n", - "L=.045; \t\t \t\t\t#[m] - Thickness of conducting wall\n", - "delT = 350 - 50; \t\t #[C] - Temperature Difference across the Wall\n", - "k=370; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Material\n", - "#calculations\n", - "#Using Fourier's Law eq 1.1\n", - "q = k*delT/(L*10**6); \t\t\t#[MW/m^2] - Heat Flux\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer per unit area =\",q,\" W\");\n", - "#END\n", - "\n", - "# Example 1.2 Page 17\n", - "\n", - "L = .15; \t\t \t\t\t#[m] - Thickness of conducting wall\n", - "delT = 150 - 45; \t\t #[C] - Temperature Difference across the Wall\n", - "A = 4.5; #[m^2] - Wall Area\n", - "k=9.35; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Material\n", - "#calculations\n", - "#Using Fourier's Law eq 1.1\n", - "Q = k*A*delT/L; \t\t\t#[W] - Heat Transfer\n", - "#Temperature gradient using Fourier's Law\n", - "TG = - Q/(k*A); #[C/m] - Temperature Gradient\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer per unit area =\",Q,\" W\");\n", - "print '%s %.2f %s' %(\"\\n \\n The Temperature Gradient in the flow direction =\",TG,\" C/m\");\n", - "#END\n", - "\n", - "# Example 1.3 Page 17-18\n", - "\n", - "x = .0825; \t\t \t\t\t#[m] - Thickness of side wall of the conducting oven\n", - "delT = 175 - 75; \t\t #[C] - Temperature Difference across the Wall\n", - "k=0.044; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Insulation\n", - "Q = 40.5; #[W] - Energy dissipitated by the electric coil withn the oven \n", - "#calculations\n", - "#Using Fourier's Law eq 1.1\n", - "A = (Q*x)/(k*delT); \t\t#[m^2] - Area of wall\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Area of the wall =\",A,\" m^2\");\n", - "#END\n", - "\n", - "# Example 1.4 Page 18-19\n", - "\n", - "delT = 300-20; \t\t #[C] - Temperature Difference across the Wall\n", - "h = 20; \t\t\t\t\t#[W/m^2.C] - Convective Heat Transfer Coefficient\n", - "A = 1*1.5; #[m^2] - Wall Area\n", - "#calculations\n", - "#Using Newton's Law of cooling eq 1.6\n", - "Q = h*A*delT; \t\t\t#[W] - Heat Transfer\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", - "#END\n", - "\n", - "# Example 1.5 Page 19\n", - "\n", - "L=.15; \t\t \t\t\t#[m] - Length of conducting wire\n", - "d = 0.0015; #[m] - Diameter of conducting wire\n", - "A = 22*d*L/7; #[m^2] - Surface Area exposed to Convection\n", - "delT = 120 - 100; \t\t #[C] - Temperature Difference across the Wire\n", - "h = 4500; \t\t\t\t\t#[W/m^2.C] - Convective Heat Transfer Coefficient\n", - "print 'Electric Power to be supplied = Convective Heat loss';\n", - "#calculations\n", - "#Using Newton's Law of cooling eq 1.6\n", - "Q = h*A*delT; \t\t\t#[W] - Heat Transfer\n", - "Q = round(Q,1);\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", - "#END\n", - "\n", - "# Example 1.6 Page 20-21\n", - "\n", - "T1 = 300 + 273; \t\t #[K] - Temperature of 1st surface\n", - "T2 = 40 + 273; #[K] - Temperature of 2nd surface\n", - "A = 1.5; #[m^2] - Surface Area\n", - "F = 0.52; \t\t\t\t #[dimensionless] - The value of Factor due geometric location and emissivity\n", - "sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant\n", - "#calculations\n", - "#Using Stephen-Boltzmann Law eq 1.9\n", - "Q = F*sigma*A*(T1**4 - T2**4) \t #[W] - Heat Transfer\n", - "#Equivalent Thermal Resistance using eq 1.10\n", - "Rth = (T1-T2)/Q; #[C/W] - Equivalent Thermal Resistance\n", - "#Equivalent convectoin coefficient using h*A*(T1-T2) = Q\n", - "h = Q/(A*(T1-T2)); #[W/(m^2*C)] - Equivalent Convection Coefficient\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", - "print '%s %.2f %s' %(\"\\n The equivalent thermal resistance =\",Rth,\" C/W\");\n", - "print '%s %.2f %s' %(\"\\n The equivalent convection coefficient =\",h,\" W/(m^2 * C)\");\n", - "#END\n", - "\n", - "# Example 1.7 Page 21-22\n", - "\n", - "L = 0.025; #[m] - Thickness of plate\n", - "A = 0.6*0.9; #[m^2] - Area of plate \n", - "Ts = 310; \t\t #[C] - Surface Temperature of plate\n", - "Tf = 15; #[C] - Temperature of fluid(air)\n", - "h = 22; \t\t\t\t\t #[W/m^2.C] - Convective Heat Transfer Coefficient\n", - "Qr = 250; \t\t\t\t #[W] - Heat lost from the plate due to radiation\n", - "k = 45; \t\t\t\t\t #[W/m.C] - Thermal Conductivity of Plate\n", - "#calculations\n", - "# In this problem, heat conducted by the plate is removed by a combination of convection and radiation\n", - "# Heat conducted through the plate = Convection Heat losses + Radiation Losses\n", - "# If Ti is the internal plate temperature, then heat conducted = k*A*(Ts-Ti)/L\n", - "Qc = h*A*(Ts-Tf); #[W] - Convection Heat Loss\n", - "Ti = Ts + L*(Qc + Qr)/(A*k); \t #[C] - Inside plate Temperature\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Ti,\" C\");\n", - "#END\n", - "\n", - "# Example 1.8 Page 22\n", - "\n", - "Ts = 250; \t\t #[C] - Surface Temperature\n", - "Tsurr = 110; #[C] - Temperature of surroundings\n", - "h = 75; \t\t\t\t\t #[W/m^2.C] - Convective Heat Transfer Coefficient\n", - "F = 1; \t\t\t\t #[dimensionless] - The value of Factor due geometric location and emissivity\n", - "sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant\n", - "k = 10; \t\t\t\t\t #[W/m.C] - Thermal Conductivity of Solid\n", - "#calculations\n", - "# Heat conducted through the plate = Convection Heat losses + Radiation Losses\n", - "qr = F*sigma*((Ts+273)**4-(Tsurr+273)**4) #[W/m^2] - #[W] - Heat lost per unit area from the plate due to radiation\n", - "qc = h*(Ts-Tsurr); #[W/m^2] - Convection Heat Loss per unit area\n", - "TG = -(qc+qr)/k; \t #[C/m] - Temperature Gradient\n", - "#results\n", - "print '%s %.2f %s' %(\"\\n \\n The temperature Gradient =\",TG,\" C/m\");\n", - "#END\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/UmangAgarwal/UmangAgarwal_version_backup/Sample.ipynb b/sample_notebooks/UmangAgarwal/UmangAgarwal_version_backup/Sample.ipynb new file mode 100755 index 00000000..1eb49726 --- /dev/null +++ b/sample_notebooks/UmangAgarwal/UmangAgarwal_version_backup/Sample.ipynb @@ -0,0 +1,163 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "Sample Notebook - Heat and Mass Transfer by R.K. Rajput : Chapter 1 - Basic Concepts\n", + "author: Umang Agarwal\n", + "\n", + "\n", + "# Example 1.1 Page 16-17\n", + "\n", + "L=.045; \t\t \t\t\t#[m] - Thickness of conducting wall\n", + "delT = 350 - 50; \t\t #[C] - Temperature Difference across the Wall\n", + "k=370; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Material\n", + "#calculations\n", + "#Using Fourier's Law eq 1.1\n", + "q = k*delT/(L*10**6); \t\t\t#[MW/m^2] - Heat Flux\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer per unit area =\",q,\" W\");\n", + "#END\n", + "\n", + "# Example 1.2 Page 17\n", + "\n", + "L = .15; \t\t \t\t\t#[m] - Thickness of conducting wall\n", + "delT = 150 - 45; \t\t #[C] - Temperature Difference across the Wall\n", + "A = 4.5; #[m^2] - Wall Area\n", + "k=9.35; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Material\n", + "#calculations\n", + "#Using Fourier's Law eq 1.1\n", + "Q = k*A*delT/L; \t\t\t#[W] - Heat Transfer\n", + "#Temperature gradient using Fourier's Law\n", + "TG = - Q/(k*A); #[C/m] - Temperature Gradient\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer per unit area =\",Q,\" W\");\n", + "print '%s %.2f %s' %(\"\\n \\n The Temperature Gradient in the flow direction =\",TG,\" C/m\");\n", + "#END\n", + "\n", + "# Example 1.3 Page 17-18\n", + "\n", + "x = .0825; \t\t \t\t\t#[m] - Thickness of side wall of the conducting oven\n", + "delT = 175 - 75; \t\t #[C] - Temperature Difference across the Wall\n", + "k=0.044; \t\t\t\t\t#[W/m.C] - Thermal Conductivity of Wall Insulation\n", + "Q = 40.5; #[W] - Energy dissipitated by the electric coil withn the oven \n", + "#calculations\n", + "#Using Fourier's Law eq 1.1\n", + "A = (Q*x)/(k*delT); \t\t#[m^2] - Area of wall\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Area of the wall =\",A,\" m^2\");\n", + "#END\n", + "\n", + "# Example 1.4 Page 18-19\n", + "\n", + "delT = 300-20; \t\t #[C] - Temperature Difference across the Wall\n", + "h = 20; \t\t\t\t\t#[W/m^2.C] - Convective Heat Transfer Coefficient\n", + "A = 1*1.5; #[m^2] - Wall Area\n", + "#calculations\n", + "#Using Newton's Law of cooling eq 1.6\n", + "Q = h*A*delT; \t\t\t#[W] - Heat Transfer\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", + "#END\n", + "\n", + "# Example 1.5 Page 19\n", + "\n", + "L=.15; \t\t \t\t\t#[m] - Length of conducting wire\n", + "d = 0.0015; #[m] - Diameter of conducting wire\n", + "A = 22*d*L/7; #[m^2] - Surface Area exposed to Convection\n", + "delT = 120 - 100; \t\t #[C] - Temperature Difference across the Wire\n", + "h = 4500; \t\t\t\t\t#[W/m^2.C] - Convective Heat Transfer Coefficient\n", + "print 'Electric Power to be supplied = Convective Heat loss';\n", + "#calculations\n", + "#Using Newton's Law of cooling eq 1.6\n", + "Q = h*A*delT; \t\t\t#[W] - Heat Transfer\n", + "Q = round(Q,1);\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", + "#END\n", + "\n", + "# Example 1.6 Page 20-21\n", + "\n", + "T1 = 300 + 273; \t\t #[K] - Temperature of 1st surface\n", + "T2 = 40 + 273; #[K] - Temperature of 2nd surface\n", + "A = 1.5; #[m^2] - Surface Area\n", + "F = 0.52; \t\t\t\t #[dimensionless] - The value of Factor due geometric location and emissivity\n", + "sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant\n", + "#calculations\n", + "#Using Stephen-Boltzmann Law eq 1.9\n", + "Q = F*sigma*A*(T1**4 - T2**4) \t #[W] - Heat Transfer\n", + "#Equivalent Thermal Resistance using eq 1.10\n", + "Rth = (T1-T2)/Q; #[C/W] - Equivalent Thermal Resistance\n", + "#Equivalent convectoin coefficient using h*A*(T1-T2) = Q\n", + "h = Q/(A*(T1-T2)); #[W/(m^2*C)] - Equivalent Convection Coefficient\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Q,\" W\");\n", + "print '%s %.2f %s' %(\"\\n The equivalent thermal resistance =\",Rth,\" C/W\");\n", + "print '%s %.2f %s' %(\"\\n The equivalent convection coefficient =\",h,\" W/(m^2 * C)\");\n", + "#END\n", + "\n", + "# Example 1.7 Page 21-22\n", + "\n", + "L = 0.025; #[m] - Thickness of plate\n", + "A = 0.6*0.9; #[m^2] - Area of plate \n", + "Ts = 310; \t\t #[C] - Surface Temperature of plate\n", + "Tf = 15; #[C] - Temperature of fluid(air)\n", + "h = 22; \t\t\t\t\t #[W/m^2.C] - Convective Heat Transfer Coefficient\n", + "Qr = 250; \t\t\t\t #[W] - Heat lost from the plate due to radiation\n", + "k = 45; \t\t\t\t\t #[W/m.C] - Thermal Conductivity of Plate\n", + "#calculations\n", + "# In this problem, heat conducted by the plate is removed by a combination of convection and radiation\n", + "# Heat conducted through the plate = Convection Heat losses + Radiation Losses\n", + "# If Ti is the internal plate temperature, then heat conducted = k*A*(Ts-Ti)/L\n", + "Qc = h*A*(Ts-Tf); #[W] - Convection Heat Loss\n", + "Ti = Ts + L*(Qc + Qr)/(A*k); \t #[C] - Inside plate Temperature\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n Rate of Heat Transfer =\",Ti,\" C\");\n", + "#END\n", + "\n", + "# Example 1.8 Page 22\n", + "\n", + "Ts = 250; \t\t #[C] - Surface Temperature\n", + "Tsurr = 110; #[C] - Temperature of surroundings\n", + "h = 75; \t\t\t\t\t #[W/m^2.C] - Convective Heat Transfer Coefficient\n", + "F = 1; \t\t\t\t #[dimensionless] - The value of Factor due geometric location and emissivity\n", + "sigma = 5.67*(10**-8) #(W/(m^2 * K^4)) - Stephen - Boltzmann Constant\n", + "k = 10; \t\t\t\t\t #[W/m.C] - Thermal Conductivity of Solid\n", + "#calculations\n", + "# Heat conducted through the plate = Convection Heat losses + Radiation Losses\n", + "qr = F*sigma*((Ts+273)**4-(Tsurr+273)**4) #[W/m^2] - #[W] - Heat lost per unit area from the plate due to radiation\n", + "qc = h*(Ts-Tsurr); #[W/m^2] - Convection Heat Loss per unit area\n", + "TG = -(qc+qr)/k; \t #[C/m] - Temperature Gradient\n", + "#results\n", + "print '%s %.2f %s' %(\"\\n \\n The temperature Gradient =\",TG,\" C/m\");\n", + "#END\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Vaibhav Vajani/Vaibhav Vajani_version_backup/chapter2.ipynb b/sample_notebooks/Vaibhav Vajani/Vaibhav Vajani_version_backup/chapter2.ipynb new file mode 100755 index 00000000..142664b2 --- /dev/null +++ b/sample_notebooks/Vaibhav Vajani/Vaibhav Vajani_version_backup/chapter2.ipynb @@ -0,0 +1,1412 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2: Determinants and Matrices" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.1, page no. 55" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Determinant of A is: a*b*c - a*f**2 - b*g**2 - c*h**2 + 2*f*g*h\n" + ] + } + ], + "source": [ + "import sympy\n", + "\n", + "a = sympy.Symbol('a')\n", + "h = sympy.Symbol('h')\n", + "g = sympy.Symbol('g')\n", + "b = sympy.Symbol('b')\n", + "f = sympy.Symbol('f')\n", + "c = sympy.Symbol('c')\n", + "A = sympy.Matrix([[a,h,g],[h,b,f],[g,f,c]])\n", + "\n", + "print \"Determinant of A is: \", A.det()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.2, page no. 55" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Determinanat of a is: 88.0\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.array([[0,1,2,3],[1,0,3,0],[2,3,0,1],[3,0,1,2]])\n", + "print \"Determinant of a is:\",numpy.linalg.det(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.3, page no. 56" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-a**3*b**2*c + a**3*b*c**2 + a**2*b**3*c - a**2*b*c**3 + a**2*b - a**2*c - a*b**3*c**2 + a*b**2*c**3 - a*b**2 + a*c**2 + b**2*c - b*c**2\n" + ] + } + ], + "source": [ + "import numpy\n", + "from sympy import *\n", + "\n", + "a = Symbol('a');\n", + "b = Symbol('b');\n", + "c = Symbol('c');\n", + "A = sympy.Matrix([[a,a**2,a**3-1],[b,b**2,b**3-1],[c,c**2,c**3-1]])\n", + "\n", + "print A.det()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.4, page no. 57" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Determinanat of a is: -24.0\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.array([[21,17,7,10],[24,22,6,10],[6,8,2,3],[6,7,1,2]])\n", + "print \"Determinanat of a is:\",numpy.linalg.det(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.8, page no. 57" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a: x**y*log(x)\n", + "b: x**y*y*log(x)/x + x**y/x\n", + "c: x**y*y**2*log(x)/x**2 - x**y*y*log(x)/x**2 + 2*x**y*y/x**2 - x**y/x**2\n", + "d: x**y*y/x\n", + "e: x**y*y*log(x)/x + x**y/x\n", + "f: x**y*y**2*log(x)/x**2 - x**y*y*log(x)/x**2 + 2*x**y*y/x**2 - x**y/x**2\n", + "Clearly c = f\n" + ] + } + ], + "source": [ + "from sympy import *\n", + "\n", + "x = Symbol('x');\n", + "y = Symbol('y')\n", + "u = x**y\n", + "a = diff(u, y)\n", + "b = diff(a, x)\n", + "c = diff(b, x)\n", + "d = diff(u, x)\n", + "e = diff(d, y)\n", + "f = diff(e, x)\n", + "print \"a: \", a\n", + "print \"b: \", b\n", + "print \"c: \", c\n", + "print \"d: \", d\n", + "print \"e: \", e\n", + "print \"f: \", f\n", + "print \"Clearly c = f\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.16, page no. 64" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " AB=\n", + "[[ 3 -2]\n", + " [ 5 -5]\n", + " [ 7 -8]]\n", + "BA=\n" + ] + }, + { + "ename": "ValueError", + "evalue": "objects are not aligned", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mA\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mB\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"BA=\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 9\u001b[1;33m \u001b[1;32mprint\u001b[0m \u001b[0mB\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mA\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 10\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;31m#Error in book as well. The matrix dimensions are not equal. Error in Scilab too\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;32m/usr/lib/python2.7/dist-packages/numpy/matrixlib/defmatrix.pyc\u001b[0m in \u001b[0;36m__mul__\u001b[1;34m(self, other)\u001b[0m\n\u001b[0;32m 339\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtuple\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[1;31m# This promotes 1-D vectors to row vectors\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 341\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0masmatrix\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 342\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misscalar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'__rmul__'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mValueError\u001b[0m: objects are not aligned" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[0,1,2],[1,2,3],[2,3,4]])\n", + "B = numpy.matrix([[1,-2],[-1,0],[2,-1]])\n", + "\n", + "print \"AB=\"\n", + "print A*B\n", + "print \"BA=\"\n", + "print B*A\n", + "\n", + "#Error in book as well. The matrix dimensions are not equal. Error in Scilab too" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.17, page no. 65" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A*B=\n", + "[[ 5 9 13]\n", + " [-1 2 4]\n", + " [-2 2 4]]\n", + "\n", + "B*A=\n", + "[[-1 12 11]\n", + " [-1 7 8]\n", + " [-2 -1 5]]\n", + "Clearly AB is not equal to BA\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.array([[1,3,0],[-1,2,1],[0,0,2]])\n", + "B = numpy.array([[2,3,4],[1,2,3],[-1,1,2]])\n", + "ma = numpy.matrix(A)\n", + "mb = numpy.matrix(B)\n", + "print \"A*B=\"\n", + "print ma*mb\n", + "print \"\"\n", + "print \"B*A=\"\n", + "print mb*ma\n", + "print \"Clearly AB is not equal to BA\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.18, page no. 65" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "AB=C−−>B=inv(A)∗C\n", + "\n", + "[[ 1.00000000e+00 -1.77635684e-15 -8.88178420e-16]\n", + " [ -2.22044605e-16 2.00000000e+00 -1.11022302e-16]\n", + " [ 1.77635684e-15 0.00000000e+00 1.00000000e+00]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[3,2,2],[1,3,1],[5,3,4]])\n", + "C = numpy.matrix([[3,4,2],[1,6,1],[5,6,4]])\n", + "print \"AB=C−−>B=inv(A)∗C\"\n", + "print \"\"\n", + "B = numpy.linalg.inv(A)*C \n", + "print B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.19, page no. 66" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Aˆ3−4∗Aˆ2−3A+11*I=\n", + "\n", + "[[ 0. 0. 0.]\n", + " [ 0. 0. 0.]\n", + " [ 0. 0. 0.]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.array([[1,3,2],[2,0,-1],[1,2,3]])\n", + "I = numpy.eye(3)\n", + "A = numpy.matrix(A)\n", + "print \"Aˆ3−4∗Aˆ2−3A+11*I=\"\n", + "print \"\"\n", + "print A**3-4*A**2-3*A+11*I" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.20, page no. 67" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Enter the value of n: 3\n", + "Calculating A ^ n: \n", + "[[ 31 -75]\n", + " [ 12 -29]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "0\n", + "A = numpy.matrix([[11,-25],[4, -9]])\n", + "n = int(raw_input(\"Enter the value of n: \"))\n", + "print \"Calculating A ^ n: \"\n", + "print A**n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.23, page no. 70" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inverse of A is: \n", + "[[ 3. 1. 1.5 ]\n", + " [-1.25 -0.25 -0.75]\n", + " [-0.25 -0.25 -0.25]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", + "print \"Inverse of A is: \"\n", + "print numpy.linalg.inv(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.24.1, page no. 71" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank of A is: 2\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[1,2,3],[1,4,2],[2,6,5]])\n", + "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.24.2, page no. 71" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank of A is: 2\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[0,1,-3,-1],[1,0,1,1],[3,1,0,2],[1,1,-2,0]])\n", + "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.25, page no. 72" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inverse of A is: \n", + "[[ 3. 1. 1.5 ]\n", + " [-1.25 -0.25 -0.75]\n", + " [-0.25 -0.25 -0.25]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", + "print \"Inverse of A is: \"\n", + "print numpy.linalg.inv(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.26, page no. 73" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank of A is: 3\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[2,3,-1,-1],[1,-1,-2,-4],[3,1,3,-2],[6,3,0,-7]])\n", + "r,p = numpy.linalg.eigh ( A )\n", + "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.28, page no. 75" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inverse of A is: \n", + "[[ 1.4 0.2 -0.4]\n", + " [-1.5 0. 0.5]\n", + " [ 1.1 -0.2 -0.1]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[1,1,1],[4,3,-1],[3,5,3]])\n", + "print \"Inverse of A is: \"\n", + "print numpy.linalg.inv(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.31, page no. 78" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " The equations can be rewritten as AX=B where X=[ x1 ; x2 ; x3 ; x4 ] and \n", + "Determinant of A=\n", + "8.0\n", + "Inverse of A =\n", + "[[ 0.5 0.5 0.5 -0.5]\n", + " [-0.5 0. 0. 0.5]\n", + " [ 0. -0.5 0. 0.5]\n", + " [ 0. 0. -0.5 0.5]]\n", + "X= [[ 1.]\n", + " [-1.]\n", + " [ 2.]\n", + " [-2.]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "print \"The equations can be rewritten as AX=B where X=[ x1 ; x2 ; x3 ; x4 ] and \"\n", + "A = numpy.matrix([[1,-1,1,1],[1,1,-1,1],[1,1,1,-1],[1,1,1,1]])\n", + "B = numpy.matrix([[2],[-4],[4],[0]])\n", + "print \"Determinant of A=\"\n", + "print numpy.linalg.det(A)\n", + "print \"Inverse of A =\"\n", + "print numpy.linalg.inv(A)\n", + "print \"X=\",numpy.linalg.inv(A)*B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.32, page no. 78" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The equations can be rewritten as AX=B where X=[x;y;z] and\n", + "Determinant of A=\n", + "-8.79296635503e-14\n", + "Since det(A)=0 , hence, this system of equation will have infinite solutions.. hence, the system is consistent\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "print \"The equations can be rewritten as AX=B where X=[x;y;z] and\"\n", + "A = numpy.matrix([[5,3,7],[3,26,2],[7,2,10]])\n", + "B = numpy.matrix([[4],[9],[5]])\n", + "print \"Determinant of A=\"\n", + "print numpy.linalg.det(A)\n", + "print \"Since det(A)=0 , hence, this system of equation will have infinite solutions.. hence, the system is consistent\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.34.1, page no. 80" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank of A is 3\n", + "Equations have only a trivial solution : x=y=z=0\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[1,2,3],[3,4,4],[7,10,12]])\n", + "p = numpy.linalg.matrix_rank(A)\n", + "print \"Rank of A is\",p\n", + "if p==3:\n", + " print \"Equations have only a trivial solution : x=y=z=0\"\n", + "else:\n", + " print \"Equations have infinite no . of solutions.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.34.2, page no. 80" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rank of A is 2\n", + "Equations have infinite no. of solutions.\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[4,2,1,3],[6,3,4,7],[2,1,0,1]])\n", + "p = numpy.linalg.matrix_rank(A)\n", + "print \"Rank of A is\",p\n", + "if p ==4:\n", + " print \"Equations have only a trivial solution : x=y=z=0\"\n", + "else:\n", + " print \"Equations have infinite no. of solutions.\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.38, page no. 83" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The given equations can be written as Y=AX where\n", + "Determinant of A is -1.0\n", + "Since, its non−singular, hence transformation is regular\n", + "Inverse of A is\n", + "[[ 2. -2. -1.]\n", + " [-4. 5. 3.]\n", + " [ 1. -1. -1.]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "print \"The given equations can be written as Y=AX where\"\n", + "A = numpy.matrix([[2,1,1],[1,1,2],[1,0,-2]])\n", + "print \"Determinant of A is\",numpy.linalg.det ( A )\n", + "print \"Since, its non−singular, hence transformation is regular\"\n", + "print\"Inverse of A is\"\n", + "print numpy.linalg.inv ( A )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.39, page no. 84" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[[-0.66666667 0.33333333 0.66666667]\n", + " [ 0.66666667 0.66666667 0.33333333]\n", + " [ 0.33333333 -0.66666667 0.66666667]]\n", + "A transpose is equal to\n", + "[[-0.66666667 0.66666667 0.33333333]\n", + " [ 0.33333333 0.66666667 -0.66666667]\n", + " [ 0.66666667 0.33333333 0.66666667]]\n", + "A∗(transpose of A)=\n", + "[[ 1. 0. 0.]\n", + " [ 0. 1. 0.]\n", + " [ 0. 0. 1.]]\n", + "Hence, A is orthogonal\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[-2./3,1./3,2./3],[2./3,2./3,1./3],[1./3,-2./3,2./3]])\n", + "print A\n", + "print \"A transpose is equal to\"\n", + "print A.transpose()\n", + "print \"A∗(transpose of A)=\"\n", + "print A*A.transpose()\n", + "print \"Hence, A is orthogonal\"" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.42, page no. 87" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\n", + "R is normalised. let U represents unnormalised version of r\n", + "Two eigen vectors are the two columns of U\n", + "[[ 4. 1.]\n", + " [ 0. 0.]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "import math\n", + "\n", + "A = numpy.matrix([[5,4],[1,2]])\n", + "print \"Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\"\n", + "P,R= numpy.linalg.eig(A)\n", + "U = numpy.zeros([2, 2])\n", + "print \"R is normalised. let U represents unnormalised version of r\"\n", + "U[0,0]= R[0,0]*math.sqrt(17)\n", + "U[0,1]= R[0,1]*math.sqrt(17)\n", + "U[0,1]= R[1,1]*math.sqrt(2)\n", + "print \"Two eigen vectors are the two columns of U\"\n", + "print U" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Examle 2.43, page no. 88" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\n", + "R is normalised. let U represents unnormalised version of r\n", + "[-2. 3. 6.]\n", + "Three eigen vectors are the three columns of U\n", + "[[ -2.82842712 5.19615242 14.69693846]\n", + " [ 0. 0. 0. ]\n", + " [ 0. 0. 0. ]]\n" + ] + } + ], + "source": [ + "import numpy,math\n", + "\n", + "A = numpy.matrix([[1,1,3],[1,5,1],[3,1,1]])\n", + "U = numpy.zeros([3,3])\n", + "print \"Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\"\n", + "R,P = numpy.linalg.eig(A)\n", + "print \"R is normalised. let U represents unnormalised version of r\"\n", + "print R\n", + "U[0,0] = R[0]*math.sqrt(2) \n", + "U[0,1] = R[1]*math.sqrt(3)\n", + "U[0,2] = R[2]*math.sqrt(6)\n", + "print \"Three eigen vectors are the three columns of U\"\n", + "print U" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.44, page no. 89" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\n", + "R is normalised. let U represents unnormalised version of r\n", + "[ 3. 2. 5.]\n", + "Three eigen vectors are the three columns of U\n", + "[[ 3. 2. 18.70828693]\n", + " [ 0. 0. 0. ]\n", + " [ 0. 0. 0. ]]\n" + ] + } + ], + "source": [ + "import numpy,math\n", + "\n", + "A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])\n", + "U = numpy.zeros([3,3])\n", + "print \"Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\"\n", + "R,P = numpy.linalg.eig(A)\n", + "print \"R is normalised. let U represents unnormalised version of r\"\n", + "print R\n", + "U[0,0] = R[0]*math.sqrt(1) \n", + "U[0,1] = R[1]*math.sqrt(1)\n", + "U[0,2] = R[2]*math.sqrt(14)\n", + "print \"Three eigen vectors are the three columns of U\"\n", + "print U" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.45, page no. 90" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Eigen values of A are\n", + "(array([-1., 5.]), matrix([[-0.89442719, -0.70710678],\n", + " [ 0.4472136 , -0.70710678]]))\n", + "Let\n", + "Hence, the characteristic equation is ( x−a ) ( x−b)\n", + "[-8 -5]\n", + "Aˆ2−4∗A−5∗ I=\n", + "[[ 0. 0.]\n", + " [ 0. 0.]]\n", + "Inverse of A=\n", + "[[-0.6 0.8]\n", + " [ 0.4 -0.2]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "x = numpy.poly([0])\n", + "A = numpy.matrix([[1,4],[2,3]])\n", + "I = numpy.eye(2)\n", + "print \"Eigen values of A are\"\n", + "print numpy.linalg.eig(A)\n", + "print \"Let\"\n", + "a = -1;\n", + "b = 5;\n", + "print \"Hence, the characteristic equation is ( x−a ) ( x−b)\"\n", + "print ( x - a ) *( x - b )\n", + "\n", + "print \"Aˆ2−4∗A−5∗ I=\"\n", + "print A**2-4*A-5* I\n", + "print \"Inverse of A=\"\n", + "print numpy.linalg.inv ( A )" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.46, page no. 91" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Egenvalues of A are\n", + "(array([ 4.25683813, 0.40327935, -4.66011748]), matrix([[ 0.10296232, -0.91299477, -0.48509974],\n", + " [-0.90473047, 0.40531299, 0.37306899],\n", + " [ 0.41335402, 0.04649661, 0.79088417]]))\n", + "Let\n", + "Hence, the characteristic equation is ( x−a ) ( x−b) ( x−c )\n", + "[-10.99999905 8.00000095]\n", + "Inverse of A=\n", + "[[ 3. 1. 1.5 ]\n", + " [-1.25 -0.25 -0.75]\n", + " [-0.25 -0.25 -0.25]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "x = numpy.poly([0])\n", + "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", + "print \"Egenvalues of A are\"\n", + "print numpy.linalg.eig(A)\n", + "print \"Let\"\n", + "a =4.2568381\n", + "b =0.4032794\n", + "c = -4.6601175\n", + "print \"Hence, the characteristic equation is ( x−a ) ( x−b) ( x−c )\"\n", + "p = (x-a)*(x-b)*(x-c)\n", + "print p\n", + "print \"Inverse of A=\"\n", + "print numpy.linalg.inv(A)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.47, page no. 91" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Eigenvalues of A are\n", + "(array([ 3., 1., 1.]), matrix([[ 0.70710678, -0.70710678, -0.40824829],\n", + " [ 0. , 0. , 0.81649658],\n", + " [ 0.70710678, 0.70710678, -0.40824829]]))\n", + "Let\n", + "Hence, the characteristic equation is (x−a)(x−b)(x−c)=\n", + "[ 0 -3]\n", + "Aˆ8−5∗Aˆ7+7∗Aˆ6−3∗Aˆ5+Aˆ4−5∗Aˆ3+8∗Aˆ2−2∗A+I =\n", + "[[ 8. 5. 5.]\n", + " [ 0. 3. 0.]\n", + " [ 5. 5. 8.]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "x = numpy.poly([0])\n", + "A = numpy.matrix([[2,1,1],[0,1,0],[1,1,2]])\n", + "I = numpy.eye(3)\n", + "print \"Eigenvalues of A are\"\n", + "print numpy.linalg.eig(A)\n", + "print \"Let\"\n", + "a =1\n", + "b =1\n", + "c =3\n", + "print \"Hence, the characteristic equation is (x−a)(x−b)(x−c)=\"\n", + "p = (x-a)*(x-b)*(x-c)\n", + "print p\n", + "print \"Aˆ8−5∗Aˆ7+7∗Aˆ6−3∗Aˆ5+Aˆ4−5∗Aˆ3+8∗Aˆ2−2∗A+I =\"\n", + "print A**8-5*A**7+7*A**6-3*A**5+A**4-5*A**3+8*A**2-2*A+I" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "## Example 2.48, page no. 93" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R is matrix of transformation and D is a diagonal matrix\n", + "[-1.65544238 -0.21075588 2.86619826]\n", + "[[-0.87936655 -0.34661859 -0.32645063]\n", + " [ 0.11410244 0.51222983 -0.85123513]\n", + " [-0.46227167 0.78579651 0.41088775]]\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[-1,2,-2],[1,2,1],[-1,-1,0]])\n", + "print \"R is matrix of transformation and D is a diagonal matrix\"\n", + "[R,D]= numpy.linalg.eigh(A)\n", + "print R\n", + "print D" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.49, page no. 93" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "R is matrix of transformation and D is a diagonal matrix\n", + "R is normalised, let P denotes unnormalised version of R . Then \n", + "[ 3. 2. 5.]\n", + "[[ 4.24264069 3.46410162 12.24744871]\n", + " [ 0. 0. 0. ]\n", + " [ 0. 0. 0. ]]\n", + "A^4= [[ 81 65 1502]\n", + " [ 0 16 1218]\n", + " [ 0 0 625]]\n" + ] + } + ], + "source": [ + "import numpy,math\n", + "\n", + "A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])\n", + "P = numpy.zeros([3,3])\n", + "print \"R is matrix of transformation and D is a diagonal matrix\"\n", + "R,D = numpy.linalg.eig(A)\n", + "print \"R is normalised, let P denotes unnormalised version of R . Then \"\n", + "print R\n", + "P[0,0] = R[0]*math.sqrt(2) \n", + "P[0,1] = R[1]*math.sqrt(3)\n", + "P[0,2] = R[2]*math.sqrt(6)\n", + "print P\n", + "print \"A^4= \",A**4" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.50, page no. 94" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3∗xˆ2+5∗yˆ2+3∗zˆ2−2∗y∗z+2∗z∗x−2∗x∗y\n", + "The matrix of the given quadratic form is\n", + "Let R represents the matrix of transformation and Prepresents a diagonal matrix whose values are the eigenvalues of A. then\n", + "So, canonical form is 2∗xˆ2+3∗yˆ2+6∗zˆ2\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "print \"3∗xˆ2+5∗yˆ2+3∗zˆ2−2∗y∗z+2∗z∗x−2∗x∗y\"\n", + "print \"The matrix of the given quadratic form is\"\n", + "A = numpy.matrix([[3,-1,1],[-1,5,-1],[1,-1,3]])\n", + "print \"Let R represents the matrix of transformation and Prepresents a diagonal matrix whose values are the eigenvalues of A. then\"\n", + "[R,P] = numpy.linalg.eig(A)\n", + "print \"So, canonical form is 2∗xˆ2+3∗yˆ2+6∗zˆ2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.51, page no. 95" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "2∗x1∗x2+2∗x1∗x3−2∗x2∗x3\n", + "The matrix of the given quadratic form is\n", + "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\n", + "so, canonical form is −2∗xˆ2+yˆ2+ zˆ2\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "print \"2∗x1∗x2+2∗x1∗x3−2∗x2∗x3\"\n", + "print \"The matrix of the given quadratic form is\"\n", + "A = numpy.matrix([[0,1,1],[1,0,-1],[1,-1,0]])\n", + "print \"Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\"\n", + "[R,P] = numpy.linalg.eig(A)\n", + "print \"so, canonical form is −2∗xˆ2+yˆ2+ zˆ2\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.52, page no. 96" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "A∗= [[ 2.-1.j -5.-0.j]\n", + " [ 3.-0.j 0.-1.j]\n", + " [-1.-3.j 4.+2.j]]\n", + "AA∗= [[ 24.+0.j -20.+2.j]\n", + " [-20.-2.j 46.+0.j]]\n", + "Clearly, AA∗ is hermitian matrix\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "'''\n", + "A=[2+%i 3 -1+3*%i;-5 %i 4-2*%i]\n", + "'''\n", + "\n", + "A = numpy.matrix([[2+1j,3,-1+3*1j],[-5,1j,4-2*1j]])\n", + "#A = A.getH()\n", + "print \"A∗=\", A.getH()\n", + "print \"AA∗=\", A*(A.getH())\n", + "print \"Clearly, AA∗ is hermitian matrix\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.53, page no. 97" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " A∗= [[ 0.-0.j 0.-0.j]\n", + " [-0.-0.j 0.-0.j]]\n", + "AA∗= [[ 0.+0.j 0.+0.j]\n", + " [ 0.+0.j 0.+0.j]]\n", + "A∗A= [[ 0.+0.j 0.+0.j]\n", + " [ 0.+0.j 0.+0.j]]\n" + ] + } + ], + "source": [ + "import numpy \n", + "\n", + "A = numpy.matrix([[(1/2)*(1+1j),(1/2)*(-1+1j)],[(1/2)*(1+1j),(1/2)*(1-1j)]])\n", + "print \"A∗=\", A.getH()\n", + "print \"AA∗=\", A*(A.getH())\n", + "print \"A∗A=\", (A.getH())*A" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2.54, page no. 97" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I−A=\n", + "inverse of (I+A)=\n", + "[[ 0.16666667+0.j -0.16666667-0.33333333j]\n", + " [ 0.16666667-0.33333333j 0.16666667+0.j ]]\n", + "((I−A)(inverse(I+A)))∗((I−A)(inverse(I+A)))=\n", + "[[ 1.11111111e-01-0.44444444j -2.77555756e-17+0.88888889j]\n", + " [ -2.77555756e-17+0.88888889j 1.11111111e-01+0.44444444j]]\n", + "((I−A)(inverse(I+A)))((I−A)(inverse(I+A)))∗=\n", + "[[ 1.11111111e-01+0.44444444j 1.11022302e-16+0.88888889j]\n", + " [ 1.11022302e-16+0.88888889j 1.11111111e-01-0.44444444j]]\n", + "Clearly, the product is an identity matrix.hence, it is a unitary matrix\n" + ] + } + ], + "source": [ + "import numpy\n", + "\n", + "A = numpy.matrix([[0,1+2*1j],[-1+2*1j,0]])\n", + "I = numpy.eye(2)\n", + "print \"I−A=\"\n", + "I-A\n", + "print \"inverse of (I+A)=\"\n", + "print numpy.linalg.inv(I+A)\n", + "print \"((I−A)(inverse(I+A)))∗((I−A)(inverse(I+A)))=\"\n", + "print (((I-A)*(numpy.linalg.inv(I+A))).T)*((I-A)*(numpy.linalg.inv(I+A)))\n", + "print \"((I−A)(inverse(I+A)))((I−A)(inverse(I+A)))∗=\"\n", + "print ((I-A)*(numpy.linalg.inv(I+A)))*(((I-A)*(numpy.linalg.inv(I+A))).T)\n", + "print \"Clearly, the product is an identity matrix.hence, it is a unitary matrix\"" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Vaibhav Vajani/chapter2.ipynb b/sample_notebooks/Vaibhav Vajani/chapter2.ipynb deleted file mode 100755 index 142664b2..00000000 --- a/sample_notebooks/Vaibhav Vajani/chapter2.ipynb +++ /dev/null @@ -1,1412 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2: Determinants and Matrices" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.1, page no. 55" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Determinant of A is: a*b*c - a*f**2 - b*g**2 - c*h**2 + 2*f*g*h\n" - ] - } - ], - "source": [ - "import sympy\n", - "\n", - "a = sympy.Symbol('a')\n", - "h = sympy.Symbol('h')\n", - "g = sympy.Symbol('g')\n", - "b = sympy.Symbol('b')\n", - "f = sympy.Symbol('f')\n", - "c = sympy.Symbol('c')\n", - "A = sympy.Matrix([[a,h,g],[h,b,f],[g,f,c]])\n", - "\n", - "print \"Determinant of A is: \", A.det()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.2, page no. 55" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Determinanat of a is: 88.0\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.array([[0,1,2,3],[1,0,3,0],[2,3,0,1],[3,0,1,2]])\n", - "print \"Determinant of a is:\",numpy.linalg.det(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.3, page no. 56" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-a**3*b**2*c + a**3*b*c**2 + a**2*b**3*c - a**2*b*c**3 + a**2*b - a**2*c - a*b**3*c**2 + a*b**2*c**3 - a*b**2 + a*c**2 + b**2*c - b*c**2\n" - ] - } - ], - "source": [ - "import numpy\n", - "from sympy import *\n", - "\n", - "a = Symbol('a');\n", - "b = Symbol('b');\n", - "c = Symbol('c');\n", - "A = sympy.Matrix([[a,a**2,a**3-1],[b,b**2,b**3-1],[c,c**2,c**3-1]])\n", - "\n", - "print A.det()" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.4, page no. 57" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Determinanat of a is: -24.0\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.array([[21,17,7,10],[24,22,6,10],[6,8,2,3],[6,7,1,2]])\n", - "print \"Determinanat of a is:\",numpy.linalg.det(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.8, page no. 57" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a: x**y*log(x)\n", - "b: x**y*y*log(x)/x + x**y/x\n", - "c: x**y*y**2*log(x)/x**2 - x**y*y*log(x)/x**2 + 2*x**y*y/x**2 - x**y/x**2\n", - "d: x**y*y/x\n", - "e: x**y*y*log(x)/x + x**y/x\n", - "f: x**y*y**2*log(x)/x**2 - x**y*y*log(x)/x**2 + 2*x**y*y/x**2 - x**y/x**2\n", - "Clearly c = f\n" - ] - } - ], - "source": [ - "from sympy import *\n", - "\n", - "x = Symbol('x');\n", - "y = Symbol('y')\n", - "u = x**y\n", - "a = diff(u, y)\n", - "b = diff(a, x)\n", - "c = diff(b, x)\n", - "d = diff(u, x)\n", - "e = diff(d, y)\n", - "f = diff(e, x)\n", - "print \"a: \", a\n", - "print \"b: \", b\n", - "print \"c: \", c\n", - "print \"d: \", d\n", - "print \"e: \", e\n", - "print \"f: \", f\n", - "print \"Clearly c = f\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.16, page no. 64" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " AB=\n", - "[[ 3 -2]\n", - " [ 5 -5]\n", - " [ 7 -8]]\n", - "BA=\n" - ] - }, - { - "ename": "ValueError", - "evalue": "objects are not aligned", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mValueError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m\u001b[0m in \u001b[0;36m\u001b[1;34m()\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[0mA\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mB\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 8\u001b[0m \u001b[1;32mprint\u001b[0m \u001b[1;34m\"BA=\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 9\u001b[1;33m \u001b[1;32mprint\u001b[0m \u001b[0mB\u001b[0m\u001b[1;33m*\u001b[0m\u001b[0mA\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 10\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 11\u001b[0m \u001b[1;31m#Error in book as well. The matrix dimensions are not equal. Error in Scilab too\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;32m/usr/lib/python2.7/dist-packages/numpy/matrixlib/defmatrix.pyc\u001b[0m in \u001b[0;36m__mul__\u001b[1;34m(self, other)\u001b[0m\n\u001b[0;32m 339\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misinstance\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;33m(\u001b[0m\u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mndarray\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mlist\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mtuple\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 340\u001b[0m \u001b[1;31m# This promotes 1-D vectors to row vectors\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 341\u001b[1;33m \u001b[1;32mreturn\u001b[0m \u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0masmatrix\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 342\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0misscalar\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mor\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mother\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;34m'__rmul__'\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 343\u001b[0m \u001b[1;32mreturn\u001b[0m \u001b[0mN\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mdot\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mother\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", - "\u001b[1;31mValueError\u001b[0m: objects are not aligned" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[0,1,2],[1,2,3],[2,3,4]])\n", - "B = numpy.matrix([[1,-2],[-1,0],[2,-1]])\n", - "\n", - "print \"AB=\"\n", - "print A*B\n", - "print \"BA=\"\n", - "print B*A\n", - "\n", - "#Error in book as well. The matrix dimensions are not equal. Error in Scilab too" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.17, page no. 65" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A*B=\n", - "[[ 5 9 13]\n", - " [-1 2 4]\n", - " [-2 2 4]]\n", - "\n", - "B*A=\n", - "[[-1 12 11]\n", - " [-1 7 8]\n", - " [-2 -1 5]]\n", - "Clearly AB is not equal to BA\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.array([[1,3,0],[-1,2,1],[0,0,2]])\n", - "B = numpy.array([[2,3,4],[1,2,3],[-1,1,2]])\n", - "ma = numpy.matrix(A)\n", - "mb = numpy.matrix(B)\n", - "print \"A*B=\"\n", - "print ma*mb\n", - "print \"\"\n", - "print \"B*A=\"\n", - "print mb*ma\n", - "print \"Clearly AB is not equal to BA\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.18, page no. 65" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "AB=C−−>B=inv(A)∗C\n", - "\n", - "[[ 1.00000000e+00 -1.77635684e-15 -8.88178420e-16]\n", - " [ -2.22044605e-16 2.00000000e+00 -1.11022302e-16]\n", - " [ 1.77635684e-15 0.00000000e+00 1.00000000e+00]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[3,2,2],[1,3,1],[5,3,4]])\n", - "C = numpy.matrix([[3,4,2],[1,6,1],[5,6,4]])\n", - "print \"AB=C−−>B=inv(A)∗C\"\n", - "print \"\"\n", - "B = numpy.linalg.inv(A)*C \n", - "print B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.19, page no. 66" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Aˆ3−4∗Aˆ2−3A+11*I=\n", - "\n", - "[[ 0. 0. 0.]\n", - " [ 0. 0. 0.]\n", - " [ 0. 0. 0.]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.array([[1,3,2],[2,0,-1],[1,2,3]])\n", - "I = numpy.eye(3)\n", - "A = numpy.matrix(A)\n", - "print \"Aˆ3−4∗Aˆ2−3A+11*I=\"\n", - "print \"\"\n", - "print A**3-4*A**2-3*A+11*I" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.20, page no. 67" - ] - }, - { - "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Enter the value of n: 3\n", - "Calculating A ^ n: \n", - "[[ 31 -75]\n", - " [ 12 -29]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "0\n", - "A = numpy.matrix([[11,-25],[4, -9]])\n", - "n = int(raw_input(\"Enter the value of n: \"))\n", - "print \"Calculating A ^ n: \"\n", - "print A**n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.23, page no. 70" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Inverse of A is: \n", - "[[ 3. 1. 1.5 ]\n", - " [-1.25 -0.25 -0.75]\n", - " [-0.25 -0.25 -0.25]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", - "print \"Inverse of A is: \"\n", - "print numpy.linalg.inv(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.24.1, page no. 71" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank of A is: 2\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[1,2,3],[1,4,2],[2,6,5]])\n", - "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.24.2, page no. 71" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank of A is: 2\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[0,1,-3,-1],[1,0,1,1],[3,1,0,2],[1,1,-2,0]])\n", - "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.25, page no. 72" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Inverse of A is: \n", - "[[ 3. 1. 1.5 ]\n", - " [-1.25 -0.25 -0.75]\n", - " [-0.25 -0.25 -0.25]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", - "print \"Inverse of A is: \"\n", - "print numpy.linalg.inv(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.26, page no. 73" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank of A is: 3\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[2,3,-1,-1],[1,-1,-2,-4],[3,1,3,-2],[6,3,0,-7]])\n", - "r,p = numpy.linalg.eigh ( A )\n", - "print \"Rank of A is:\",numpy.linalg.matrix_rank(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.28, page no. 75" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Inverse of A is: \n", - "[[ 1.4 0.2 -0.4]\n", - " [-1.5 0. 0.5]\n", - " [ 1.1 -0.2 -0.1]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[1,1,1],[4,3,-1],[3,5,3]])\n", - "print \"Inverse of A is: \"\n", - "print numpy.linalg.inv(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.31, page no. 78" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " The equations can be rewritten as AX=B where X=[ x1 ; x2 ; x3 ; x4 ] and \n", - "Determinant of A=\n", - "8.0\n", - "Inverse of A =\n", - "[[ 0.5 0.5 0.5 -0.5]\n", - " [-0.5 0. 0. 0.5]\n", - " [ 0. -0.5 0. 0.5]\n", - " [ 0. 0. -0.5 0.5]]\n", - "X= [[ 1.]\n", - " [-1.]\n", - " [ 2.]\n", - " [-2.]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "print \"The equations can be rewritten as AX=B where X=[ x1 ; x2 ; x3 ; x4 ] and \"\n", - "A = numpy.matrix([[1,-1,1,1],[1,1,-1,1],[1,1,1,-1],[1,1,1,1]])\n", - "B = numpy.matrix([[2],[-4],[4],[0]])\n", - "print \"Determinant of A=\"\n", - "print numpy.linalg.det(A)\n", - "print \"Inverse of A =\"\n", - "print numpy.linalg.inv(A)\n", - "print \"X=\",numpy.linalg.inv(A)*B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.32, page no. 78" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The equations can be rewritten as AX=B where X=[x;y;z] and\n", - "Determinant of A=\n", - "-8.79296635503e-14\n", - "Since det(A)=0 , hence, this system of equation will have infinite solutions.. hence, the system is consistent\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "print \"The equations can be rewritten as AX=B where X=[x;y;z] and\"\n", - "A = numpy.matrix([[5,3,7],[3,26,2],[7,2,10]])\n", - "B = numpy.matrix([[4],[9],[5]])\n", - "print \"Determinant of A=\"\n", - "print numpy.linalg.det(A)\n", - "print \"Since det(A)=0 , hence, this system of equation will have infinite solutions.. hence, the system is consistent\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.34.1, page no. 80" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank of A is 3\n", - "Equations have only a trivial solution : x=y=z=0\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[1,2,3],[3,4,4],[7,10,12]])\n", - "p = numpy.linalg.matrix_rank(A)\n", - "print \"Rank of A is\",p\n", - "if p==3:\n", - " print \"Equations have only a trivial solution : x=y=z=0\"\n", - "else:\n", - " print \"Equations have infinite no . of solutions.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.34.2, page no. 80" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Rank of A is 2\n", - "Equations have infinite no. of solutions.\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[4,2,1,3],[6,3,4,7],[2,1,0,1]])\n", - "p = numpy.linalg.matrix_rank(A)\n", - "print \"Rank of A is\",p\n", - "if p ==4:\n", - " print \"Equations have only a trivial solution : x=y=z=0\"\n", - "else:\n", - " print \"Equations have infinite no. of solutions.\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.38, page no. 83" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The given equations can be written as Y=AX where\n", - "Determinant of A is -1.0\n", - "Since, its non−singular, hence transformation is regular\n", - "Inverse of A is\n", - "[[ 2. -2. -1.]\n", - " [-4. 5. 3.]\n", - " [ 1. -1. -1.]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "print \"The given equations can be written as Y=AX where\"\n", - "A = numpy.matrix([[2,1,1],[1,1,2],[1,0,-2]])\n", - "print \"Determinant of A is\",numpy.linalg.det ( A )\n", - "print \"Since, its non−singular, hence transformation is regular\"\n", - "print\"Inverse of A is\"\n", - "print numpy.linalg.inv ( A )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.39, page no. 84" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[[-0.66666667 0.33333333 0.66666667]\n", - " [ 0.66666667 0.66666667 0.33333333]\n", - " [ 0.33333333 -0.66666667 0.66666667]]\n", - "A transpose is equal to\n", - "[[-0.66666667 0.66666667 0.33333333]\n", - " [ 0.33333333 0.66666667 -0.66666667]\n", - " [ 0.66666667 0.33333333 0.66666667]]\n", - "A∗(transpose of A)=\n", - "[[ 1. 0. 0.]\n", - " [ 0. 1. 0.]\n", - " [ 0. 0. 1.]]\n", - "Hence, A is orthogonal\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[-2./3,1./3,2./3],[2./3,2./3,1./3],[1./3,-2./3,2./3]])\n", - "print A\n", - "print \"A transpose is equal to\"\n", - "print A.transpose()\n", - "print \"A∗(transpose of A)=\"\n", - "print A*A.transpose()\n", - "print \"Hence, A is orthogonal\"" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.42, page no. 87" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\n", - "R is normalised. let U represents unnormalised version of r\n", - "Two eigen vectors are the two columns of U\n", - "[[ 4. 1.]\n", - " [ 0. 0.]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "import math\n", - "\n", - "A = numpy.matrix([[5,4],[1,2]])\n", - "print \"Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\"\n", - "P,R= numpy.linalg.eig(A)\n", - "U = numpy.zeros([2, 2])\n", - "print \"R is normalised. let U represents unnormalised version of r\"\n", - "U[0,0]= R[0,0]*math.sqrt(17)\n", - "U[0,1]= R[0,1]*math.sqrt(17)\n", - "U[0,1]= R[1,1]*math.sqrt(2)\n", - "print \"Two eigen vectors are the two columns of U\"\n", - "print U" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Examle 2.43, page no. 88" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\n", - "R is normalised. let U represents unnormalised version of r\n", - "[-2. 3. 6.]\n", - "Three eigen vectors are the three columns of U\n", - "[[ -2.82842712 5.19615242 14.69693846]\n", - " [ 0. 0. 0. ]\n", - " [ 0. 0. 0. ]]\n" - ] - } - ], - "source": [ - "import numpy,math\n", - "\n", - "A = numpy.matrix([[1,1,3],[1,5,1],[3,1,1]])\n", - "U = numpy.zeros([3,3])\n", - "print \"Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\"\n", - "R,P = numpy.linalg.eig(A)\n", - "print \"R is normalised. let U represents unnormalised version of r\"\n", - "print R\n", - "U[0,0] = R[0]*math.sqrt(2) \n", - "U[0,1] = R[1]*math.sqrt(3)\n", - "U[0,2] = R[2]*math.sqrt(6)\n", - "print \"Three eigen vectors are the three columns of U\"\n", - "print U" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.44, page no. 89" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\n", - "R is normalised. let U represents unnormalised version of r\n", - "[ 3. 2. 5.]\n", - "Three eigen vectors are the three columns of U\n", - "[[ 3. 2. 18.70828693]\n", - " [ 0. 0. 0. ]\n", - " [ 0. 0. 0. ]]\n" - ] - } - ], - "source": [ - "import numpy,math\n", - "\n", - "A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])\n", - "U = numpy.zeros([3,3])\n", - "print \"Let Rrepresents the matrix of transformation and Prepresents a diagonalmatrix whose values are the eigenvalues of A. then\"\n", - "R,P = numpy.linalg.eig(A)\n", - "print \"R is normalised. let U represents unnormalised version of r\"\n", - "print R\n", - "U[0,0] = R[0]*math.sqrt(1) \n", - "U[0,1] = R[1]*math.sqrt(1)\n", - "U[0,2] = R[2]*math.sqrt(14)\n", - "print \"Three eigen vectors are the three columns of U\"\n", - "print U" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.45, page no. 90" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Eigen values of A are\n", - "(array([-1., 5.]), matrix([[-0.89442719, -0.70710678],\n", - " [ 0.4472136 , -0.70710678]]))\n", - "Let\n", - "Hence, the characteristic equation is ( x−a ) ( x−b)\n", - "[-8 -5]\n", - "Aˆ2−4∗A−5∗ I=\n", - "[[ 0. 0.]\n", - " [ 0. 0.]]\n", - "Inverse of A=\n", - "[[-0.6 0.8]\n", - " [ 0.4 -0.2]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "x = numpy.poly([0])\n", - "A = numpy.matrix([[1,4],[2,3]])\n", - "I = numpy.eye(2)\n", - "print \"Eigen values of A are\"\n", - "print numpy.linalg.eig(A)\n", - "print \"Let\"\n", - "a = -1;\n", - "b = 5;\n", - "print \"Hence, the characteristic equation is ( x−a ) ( x−b)\"\n", - "print ( x - a ) *( x - b )\n", - "\n", - "print \"Aˆ2−4∗A−5∗ I=\"\n", - "print A**2-4*A-5* I\n", - "print \"Inverse of A=\"\n", - "print numpy.linalg.inv ( A )" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.46, page no. 91" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Egenvalues of A are\n", - "(array([ 4.25683813, 0.40327935, -4.66011748]), matrix([[ 0.10296232, -0.91299477, -0.48509974],\n", - " [-0.90473047, 0.40531299, 0.37306899],\n", - " [ 0.41335402, 0.04649661, 0.79088417]]))\n", - "Let\n", - "Hence, the characteristic equation is ( x−a ) ( x−b) ( x−c )\n", - "[-10.99999905 8.00000095]\n", - "Inverse of A=\n", - "[[ 3. 1. 1.5 ]\n", - " [-1.25 -0.25 -0.75]\n", - " [-0.25 -0.25 -0.25]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "x = numpy.poly([0])\n", - "A = numpy.matrix([[1,1,3],[1,3,-3],[-2,-4,-4]])\n", - "print \"Egenvalues of A are\"\n", - "print numpy.linalg.eig(A)\n", - "print \"Let\"\n", - "a =4.2568381\n", - "b =0.4032794\n", - "c = -4.6601175\n", - "print \"Hence, the characteristic equation is ( x−a ) ( x−b) ( x−c )\"\n", - "p = (x-a)*(x-b)*(x-c)\n", - "print p\n", - "print \"Inverse of A=\"\n", - "print numpy.linalg.inv(A)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.47, page no. 91" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Eigenvalues of A are\n", - "(array([ 3., 1., 1.]), matrix([[ 0.70710678, -0.70710678, -0.40824829],\n", - " [ 0. , 0. , 0.81649658],\n", - " [ 0.70710678, 0.70710678, -0.40824829]]))\n", - "Let\n", - "Hence, the characteristic equation is (x−a)(x−b)(x−c)=\n", - "[ 0 -3]\n", - "Aˆ8−5∗Aˆ7+7∗Aˆ6−3∗Aˆ5+Aˆ4−5∗Aˆ3+8∗Aˆ2−2∗A+I =\n", - "[[ 8. 5. 5.]\n", - " [ 0. 3. 0.]\n", - " [ 5. 5. 8.]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "x = numpy.poly([0])\n", - "A = numpy.matrix([[2,1,1],[0,1,0],[1,1,2]])\n", - "I = numpy.eye(3)\n", - "print \"Eigenvalues of A are\"\n", - "print numpy.linalg.eig(A)\n", - "print \"Let\"\n", - "a =1\n", - "b =1\n", - "c =3\n", - "print \"Hence, the characteristic equation is (x−a)(x−b)(x−c)=\"\n", - "p = (x-a)*(x-b)*(x-c)\n", - "print p\n", - "print \"Aˆ8−5∗Aˆ7+7∗Aˆ6−3∗Aˆ5+Aˆ4−5∗Aˆ3+8∗Aˆ2−2∗A+I =\"\n", - "print A**8-5*A**7+7*A**6-3*A**5+A**4-5*A**3+8*A**2-2*A+I" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "## Example 2.48, page no. 93" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R is matrix of transformation and D is a diagonal matrix\n", - "[-1.65544238 -0.21075588 2.86619826]\n", - "[[-0.87936655 -0.34661859 -0.32645063]\n", - " [ 0.11410244 0.51222983 -0.85123513]\n", - " [-0.46227167 0.78579651 0.41088775]]\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[-1,2,-2],[1,2,1],[-1,-1,0]])\n", - "print \"R is matrix of transformation and D is a diagonal matrix\"\n", - "[R,D]= numpy.linalg.eigh(A)\n", - "print R\n", - "print D" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.49, page no. 93" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "R is matrix of transformation and D is a diagonal matrix\n", - "R is normalised, let P denotes unnormalised version of R . Then \n", - "[ 3. 2. 5.]\n", - "[[ 4.24264069 3.46410162 12.24744871]\n", - " [ 0. 0. 0. ]\n", - " [ 0. 0. 0. ]]\n", - "A^4= [[ 81 65 1502]\n", - " [ 0 16 1218]\n", - " [ 0 0 625]]\n" - ] - } - ], - "source": [ - "import numpy,math\n", - "\n", - "A = numpy.matrix([[3,1,4],[0,2,6],[0,0,5]])\n", - "P = numpy.zeros([3,3])\n", - "print \"R is matrix of transformation and D is a diagonal matrix\"\n", - "R,D = numpy.linalg.eig(A)\n", - "print \"R is normalised, let P denotes unnormalised version of R . Then \"\n", - "print R\n", - "P[0,0] = R[0]*math.sqrt(2) \n", - "P[0,1] = R[1]*math.sqrt(3)\n", - "P[0,2] = R[2]*math.sqrt(6)\n", - "print P\n", - "print \"A^4= \",A**4" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.50, page no. 94" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3∗xˆ2+5∗yˆ2+3∗zˆ2−2∗y∗z+2∗z∗x−2∗x∗y\n", - "The matrix of the given quadratic form is\n", - "Let R represents the matrix of transformation and Prepresents a diagonal matrix whose values are the eigenvalues of A. then\n", - "So, canonical form is 2∗xˆ2+3∗yˆ2+6∗zˆ2\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "print \"3∗xˆ2+5∗yˆ2+3∗zˆ2−2∗y∗z+2∗z∗x−2∗x∗y\"\n", - "print \"The matrix of the given quadratic form is\"\n", - "A = numpy.matrix([[3,-1,1],[-1,5,-1],[1,-1,3]])\n", - "print \"Let R represents the matrix of transformation and Prepresents a diagonal matrix whose values are the eigenvalues of A. then\"\n", - "[R,P] = numpy.linalg.eig(A)\n", - "print \"So, canonical form is 2∗xˆ2+3∗yˆ2+6∗zˆ2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.51, page no. 95" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "2∗x1∗x2+2∗x1∗x3−2∗x2∗x3\n", - "The matrix of the given quadratic form is\n", - "Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\n", - "so, canonical form is −2∗xˆ2+yˆ2+ zˆ2\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "print \"2∗x1∗x2+2∗x1∗x3−2∗x2∗x3\"\n", - "print \"The matrix of the given quadratic form is\"\n", - "A = numpy.matrix([[0,1,1],[1,0,-1],[1,-1,0]])\n", - "print \"Let R represents the matrix of transformation and P represents a diagonal matrix whose values are the eigenvalues of A. then\"\n", - "[R,P] = numpy.linalg.eig(A)\n", - "print \"so, canonical form is −2∗xˆ2+yˆ2+ zˆ2\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.52, page no. 96" - ] - }, - { - "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "A∗= [[ 2.-1.j -5.-0.j]\n", - " [ 3.-0.j 0.-1.j]\n", - " [-1.-3.j 4.+2.j]]\n", - "AA∗= [[ 24.+0.j -20.+2.j]\n", - " [-20.-2.j 46.+0.j]]\n", - "Clearly, AA∗ is hermitian matrix\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "'''\n", - "A=[2+%i 3 -1+3*%i;-5 %i 4-2*%i]\n", - "'''\n", - "\n", - "A = numpy.matrix([[2+1j,3,-1+3*1j],[-5,1j,4-2*1j]])\n", - "#A = A.getH()\n", - "print \"A∗=\", A.getH()\n", - "print \"AA∗=\", A*(A.getH())\n", - "print \"Clearly, AA∗ is hermitian matrix\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.53, page no. 97" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " A∗= [[ 0.-0.j 0.-0.j]\n", - " [-0.-0.j 0.-0.j]]\n", - "AA∗= [[ 0.+0.j 0.+0.j]\n", - " [ 0.+0.j 0.+0.j]]\n", - "A∗A= [[ 0.+0.j 0.+0.j]\n", - " [ 0.+0.j 0.+0.j]]\n" - ] - } - ], - "source": [ - "import numpy \n", - "\n", - "A = numpy.matrix([[(1/2)*(1+1j),(1/2)*(-1+1j)],[(1/2)*(1+1j),(1/2)*(1-1j)]])\n", - "print \"A∗=\", A.getH()\n", - "print \"AA∗=\", A*(A.getH())\n", - "print \"A∗A=\", (A.getH())*A" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2.54, page no. 97" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I−A=\n", - "inverse of (I+A)=\n", - "[[ 0.16666667+0.j -0.16666667-0.33333333j]\n", - " [ 0.16666667-0.33333333j 0.16666667+0.j ]]\n", - "((I−A)(inverse(I+A)))∗((I−A)(inverse(I+A)))=\n", - "[[ 1.11111111e-01-0.44444444j -2.77555756e-17+0.88888889j]\n", - " [ -2.77555756e-17+0.88888889j 1.11111111e-01+0.44444444j]]\n", - "((I−A)(inverse(I+A)))((I−A)(inverse(I+A)))∗=\n", - "[[ 1.11111111e-01+0.44444444j 1.11022302e-16+0.88888889j]\n", - " [ 1.11022302e-16+0.88888889j 1.11111111e-01-0.44444444j]]\n", - "Clearly, the product is an identity matrix.hence, it is a unitary matrix\n" - ] - } - ], - "source": [ - "import numpy\n", - "\n", - "A = numpy.matrix([[0,1+2*1j],[-1+2*1j,0]])\n", - "I = numpy.eye(2)\n", - "print \"I−A=\"\n", - "I-A\n", - "print \"inverse of (I+A)=\"\n", - "print numpy.linalg.inv(I+A)\n", - "print \"((I−A)(inverse(I+A)))∗((I−A)(inverse(I+A)))=\"\n", - "print (((I-A)*(numpy.linalg.inv(I+A))).T)*((I-A)*(numpy.linalg.inv(I+A)))\n", - "print \"((I−A)(inverse(I+A)))((I−A)(inverse(I+A)))∗=\"\n", - "print ((I-A)*(numpy.linalg.inv(I+A)))*(((I-A)*(numpy.linalg.inv(I+A))).T)\n", - "print \"Clearly, the product is an identity matrix.hence, it is a unitary matrix\"" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric.ipynb b/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric.ipynb new file mode 100755 index 00000000..cdc8b25e --- /dev/null +++ b/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric.ipynb @@ -0,0 +1,296 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Electric Fields" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_5 pgno:65" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Maximum field = V/m per volt 42064315640.1\n" + ] + } + ], + "source": [ + "#Chapter 2, Example 5, page 65\n", + "#Calculate the maximum field at the sphere surface\n", + "#Calulating Field at surface E based on figure 2.31 and table 2.3\n", + "from math import pi\n", + "Q1 = 0.25\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "RV1= ((1/0.25**2)+(0.067/(0.25-0.067)**2)+(0.0048/(0.25-0.067)**2))\n", + "RV2= ((0.25+0.01795+0.00128)/(0.75-0.067)**2)\n", + "RV= RV1+RV2\n", + "E = (Q1*RV)/(4*pi*e0)\n", + "print\"Maximum field = V/m per volt\",E\n", + "\n", + "#Answers vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_6 pgno:66" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#Chapter 2, Exmaple 6, page 66\n", + "#calculation based on figure 2.32\n", + "\n", + "#(a)Charge on each bundle\n", + "print\"Part a\\t\"\n", + "req = (0.0175*0.45)**0.5\n", + "print\"Equivalent radius = m \", req\n", + "from math import log\n", + "from math import pi\n", + "V = 400*10**3 #Voltage\n", + "H = 12. #bundle height in m\n", + "d = 9. #pole to pole spacing in m\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "Hd = ((2*H)**2+d**2)**0.5#2*H**2 + d**2\n", + "Q = V*2*pi*e0/(log((2*H/req))-log((Hd/d)))\n", + "q = Q/2\n", + "print\"Charge per bundle = uC/m \",Q #micro C/m\n", + "print\"Charge per sunconducter = uC/m \",q #micro C/m\n", + "\n", + "#(b part i)Maximim & average surface feild\n", + "print\"\\tPart b\"\n", + "print\"\\tSub part 1\\t\"\n", + "r = 0.0175 #subconductor radius\n", + "R = 0.45 #conductor to subconductor spacing\n", + "MF = (q/(2*pi*e0))*((1/r)+(1/R)) # maximum feild\n", + "print\"Maximum feild = kV/m \\t\",MF\n", + "MSF = (q/(2*pi*e0))*((1/r)-(1/R)) # maximum surface feild\n", + "print\"Maximum feild = kV/m \\t\",MSF\n", + "ASF = (q/(2*pi*e0))*(1/r) # Average surface feild\n", + "print\"Maximum feild = kV/m \\t\",ASF\n", + "\n", + "#(b part ii) Considering the two sunconductors on the left\n", + "print\"\\tSub part 2\\t\"\n", + "#field at the outer point of subconductor #1 \n", + "drO1 = 1/(d+r)\n", + "dRrO1 = 1/(d+R+r)\n", + "EO1 = MF -((q/(2*pi*e0))*(drO1+dRrO1))\n", + "print\"EO1 = kV/m \\t\",EO1\n", + "#field at the outer point of subconductor #2 \n", + "drO2 = 1/(d-r)\n", + "dRrO2 = 1/(d-R-r)\n", + "EO2 = MF -((q/(2*pi*e0))*(dRrO2+drO2))\n", + "print\"EO2 = kV/m \\t\",EO2\n", + "\n", + "#field at the inner point of subconductor #1 \n", + "drI1 = 1/(d-r)\n", + "dRrI1 = 1/(d+R-r)\n", + "EI1 = MSF -((q/(2*pi*e0))*(drI1+dRrI1))\n", + "print\"EI1 = kV/m \\t\",EI1\n", + "#field at the inner point of subconductor #2 \n", + "drI2 = 1/(d+r)\n", + "dRrI2 = 1/(d-R+r)\n", + "EI2 = MSF -((q/(2*pi*e0))*(dRrI2+drI2)) \n", + "print\"EI2 = kV/m \\t\",EI2\n", + "\n", + "#(part c)Average of the maximim gradient\n", + "print\"\\tPart c\\t\"\n", + "Eavg = (EO1+EO2)/2\n", + "print\"The average of the maximum gradient = kV/m \\t\",Eavg\n", + "\n", + "\n", + "#Answers might vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_7 pgno:69" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Electric Feild = V/m \t30015596280.4\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 7, page 69\n", + "#Electric feild induced at x\n", + "from math import pi\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "q = 1 # C/m\n", + "C = (q/(2*pi*e0))\n", + "#Based on figure 2.33\n", + "E = C-(C*(1./3.+1./7.))+(C*(1+1./5.+1./9.))+(C*(1./5.+1./9.))-(C*(1./3.+1./7.))\n", + "print\"Electric Feild = V/m \\t\",E\n", + "\n", + "#Answers might vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_8 pgno:70" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Thickness of graded design= cm 4.24264068712\n", + "Curve = cm**2 62.4264068712\n", + "V1 = cm**3 47402.906725\n", + "Thickness of regular design = cm 14.684289433\n", + "V2 = cm**3 861.944682812\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 8, page 70\n", + "#Calculate the volume of the insulator\n", + "#Thinkness of graded design\n", + "from math import e\n", + "from math import pi\n", + "V = 150*(2)**0.5\n", + "Ebd = 50\n", + "T = V/Ebd\n", + "print\"\\nThickness of graded design= cm \",T\n", + "#Based on figure 2.24\n", + "r = 2 # radius of the conductor\n", + "l = 10 #length of graded cylinder; The textbook uses 10 instead of 20\n", + "zr = l*(T+r)\n", + "print\"Curve = cm**2 \",zr\n", + "#Volume of graded design V1\n", + "V1 = 4*pi*zr*(zr-r)\n", + "print\"V1 = cm**3 \",V1 #Unit is wrong in the textbook\n", + "#Thickness of regular design as obtained form Eq.2.77\n", + "pow = V/(2*Ebd)\n", + "t = 2*(e**pow-1)\n", + "print\"Thickness of regular design = cm \",t\n", + "#Volume of regular design V2\n", + "V2 = pi*((2+t)**2-4)\n", + "print\"V2 = cm**3 \",V2#unit not mentioned in textbook\n", + " \n", + "#Answers may vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_11 pgno:75" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The values of Phi2 and Phi4 are: [[ -3.6568 326.5 ]\n", + " [ 261.92857143 -4.37537287]]\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 11, page 75\n", + "#Calculate the potential within the mesh\n", + "#Based on figure 2.38(b)\n", + "#equations are obtained using Eq.2.46\n", + "import numpy\n", + "from numpy import linalg\n", + "A1 = 1/2*(0.54+0.16)\n", + "A2 = 1/2*(0.91+0.14)\n", + "S = numpy.matrix([[0.5571, -0.4571, -0.1],[-0.4751, 0.828, 0.3667],[-0.1, 0.667, 0.4667]])\n", + "#By obtaining the elements of the global stiffness matrix(Sadiku,1994)\n", + "#and by emplying the Eq.2.49(a)\n", + "S1 = numpy.matrix([[1.25, -0.014],[-0.014, 0.8381]])\n", + "S2 = numpy.matrix([[-0.7786, -0.4571],[-0.4571, -0.3667]])\n", + "Phi13 = numpy.matrix([[0], [10]])\n", + "val1 = S2*Phi13\n", + "Phi24 = val1/S1\n", + "print\"The values of Phi2 and Phi4 are:\",Phi24\n", + "\n", + "#Answers may vary due to round of error \n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric_Fields.ipynb b/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric_Fields.ipynb deleted file mode 100755 index cdc8b25e..00000000 --- a/sample_notebooks/Vedantam Lakshmi Manasa/Chapter_2_Electric_Fields.ipynb +++ /dev/null @@ -1,296 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Electric Fields" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_5 pgno:65" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum field = V/m per volt 42064315640.1\n" - ] - } - ], - "source": [ - "#Chapter 2, Example 5, page 65\n", - "#Calculate the maximum field at the sphere surface\n", - "#Calulating Field at surface E based on figure 2.31 and table 2.3\n", - "from math import pi\n", - "Q1 = 0.25\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "RV1= ((1/0.25**2)+(0.067/(0.25-0.067)**2)+(0.0048/(0.25-0.067)**2))\n", - "RV2= ((0.25+0.01795+0.00128)/(0.75-0.067)**2)\n", - "RV= RV1+RV2\n", - "E = (Q1*RV)/(4*pi*e0)\n", - "print\"Maximum field = V/m per volt\",E\n", - "\n", - "#Answers vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_6 pgno:66" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "#Chapter 2, Exmaple 6, page 66\n", - "#calculation based on figure 2.32\n", - "\n", - "#(a)Charge on each bundle\n", - "print\"Part a\\t\"\n", - "req = (0.0175*0.45)**0.5\n", - "print\"Equivalent radius = m \", req\n", - "from math import log\n", - "from math import pi\n", - "V = 400*10**3 #Voltage\n", - "H = 12. #bundle height in m\n", - "d = 9. #pole to pole spacing in m\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "Hd = ((2*H)**2+d**2)**0.5#2*H**2 + d**2\n", - "Q = V*2*pi*e0/(log((2*H/req))-log((Hd/d)))\n", - "q = Q/2\n", - "print\"Charge per bundle = uC/m \",Q #micro C/m\n", - "print\"Charge per sunconducter = uC/m \",q #micro C/m\n", - "\n", - "#(b part i)Maximim & average surface feild\n", - "print\"\\tPart b\"\n", - "print\"\\tSub part 1\\t\"\n", - "r = 0.0175 #subconductor radius\n", - "R = 0.45 #conductor to subconductor spacing\n", - "MF = (q/(2*pi*e0))*((1/r)+(1/R)) # maximum feild\n", - "print\"Maximum feild = kV/m \\t\",MF\n", - "MSF = (q/(2*pi*e0))*((1/r)-(1/R)) # maximum surface feild\n", - "print\"Maximum feild = kV/m \\t\",MSF\n", - "ASF = (q/(2*pi*e0))*(1/r) # Average surface feild\n", - "print\"Maximum feild = kV/m \\t\",ASF\n", - "\n", - "#(b part ii) Considering the two sunconductors on the left\n", - "print\"\\tSub part 2\\t\"\n", - "#field at the outer point of subconductor #1 \n", - "drO1 = 1/(d+r)\n", - "dRrO1 = 1/(d+R+r)\n", - "EO1 = MF -((q/(2*pi*e0))*(drO1+dRrO1))\n", - "print\"EO1 = kV/m \\t\",EO1\n", - "#field at the outer point of subconductor #2 \n", - "drO2 = 1/(d-r)\n", - "dRrO2 = 1/(d-R-r)\n", - "EO2 = MF -((q/(2*pi*e0))*(dRrO2+drO2))\n", - "print\"EO2 = kV/m \\t\",EO2\n", - "\n", - "#field at the inner point of subconductor #1 \n", - "drI1 = 1/(d-r)\n", - "dRrI1 = 1/(d+R-r)\n", - "EI1 = MSF -((q/(2*pi*e0))*(drI1+dRrI1))\n", - "print\"EI1 = kV/m \\t\",EI1\n", - "#field at the inner point of subconductor #2 \n", - "drI2 = 1/(d+r)\n", - "dRrI2 = 1/(d-R+r)\n", - "EI2 = MSF -((q/(2*pi*e0))*(dRrI2+drI2)) \n", - "print\"EI2 = kV/m \\t\",EI2\n", - "\n", - "#(part c)Average of the maximim gradient\n", - "print\"\\tPart c\\t\"\n", - "Eavg = (EO1+EO2)/2\n", - "print\"The average of the maximum gradient = kV/m \\t\",Eavg\n", - "\n", - "\n", - "#Answers might vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_7 pgno:69" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Electric Feild = V/m \t30015596280.4\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 7, page 69\n", - "#Electric feild induced at x\n", - "from math import pi\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "q = 1 # C/m\n", - "C = (q/(2*pi*e0))\n", - "#Based on figure 2.33\n", - "E = C-(C*(1./3.+1./7.))+(C*(1+1./5.+1./9.))+(C*(1./5.+1./9.))-(C*(1./3.+1./7.))\n", - "print\"Electric Feild = V/m \\t\",E\n", - "\n", - "#Answers might vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_8 pgno:70" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "Thickness of graded design= cm 4.24264068712\n", - "Curve = cm**2 62.4264068712\n", - "V1 = cm**3 47402.906725\n", - "Thickness of regular design = cm 14.684289433\n", - "V2 = cm**3 861.944682812\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 8, page 70\n", - "#Calculate the volume of the insulator\n", - "#Thinkness of graded design\n", - "from math import e\n", - "from math import pi\n", - "V = 150*(2)**0.5\n", - "Ebd = 50\n", - "T = V/Ebd\n", - "print\"\\nThickness of graded design= cm \",T\n", - "#Based on figure 2.24\n", - "r = 2 # radius of the conductor\n", - "l = 10 #length of graded cylinder; The textbook uses 10 instead of 20\n", - "zr = l*(T+r)\n", - "print\"Curve = cm**2 \",zr\n", - "#Volume of graded design V1\n", - "V1 = 4*pi*zr*(zr-r)\n", - "print\"V1 = cm**3 \",V1 #Unit is wrong in the textbook\n", - "#Thickness of regular design as obtained form Eq.2.77\n", - "pow = V/(2*Ebd)\n", - "t = 2*(e**pow-1)\n", - "print\"Thickness of regular design = cm \",t\n", - "#Volume of regular design V2\n", - "V2 = pi*((2+t)**2-4)\n", - "print\"V2 = cm**3 \",V2#unit not mentioned in textbook\n", - " \n", - "#Answers may vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_11 pgno:75" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The values of Phi2 and Phi4 are: [[ -3.6568 326.5 ]\n", - " [ 261.92857143 -4.37537287]]\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 11, page 75\n", - "#Calculate the potential within the mesh\n", - "#Based on figure 2.38(b)\n", - "#equations are obtained using Eq.2.46\n", - "import numpy\n", - "from numpy import linalg\n", - "A1 = 1/2*(0.54+0.16)\n", - "A2 = 1/2*(0.91+0.14)\n", - "S = numpy.matrix([[0.5571, -0.4571, -0.1],[-0.4751, 0.828, 0.3667],[-0.1, 0.667, 0.4667]])\n", - "#By obtaining the elements of the global stiffness matrix(Sadiku,1994)\n", - "#and by emplying the Eq.2.49(a)\n", - "S1 = numpy.matrix([[1.25, -0.014],[-0.014, 0.8381]])\n", - "S2 = numpy.matrix([[-0.7786, -0.4571],[-0.4571, -0.3667]])\n", - "Phi13 = numpy.matrix([[0], [10]])\n", - "val1 = S2*Phi13\n", - "Phi24 = val1/S1\n", - "print\"The values of Phi2 and Phi4 are:\",Phi24\n", - "\n", - "#Answers may vary due to round of error \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical.ipynb b/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical.ipynb new file mode 100755 index 00000000..a514cecb --- /dev/null +++ b/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical.ipynb @@ -0,0 +1,212 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 17:Advanced Electdrical Controls For Fluid Power Systems" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 17.1 pgno:610" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Results: \n", + "\n", + " The repeatable error of system is in. 0.00138\n" + ] + } + ], + "source": [ + "# Aim:To determine the system accuracy of electrohydraulic servo system\n", + "# Given:\n", + "# servo valve gain:\n", + "G_SV=0.15; #(in^3/s)/mA\n", + "# cylinder gain:\n", + "G_cyl=0.20; #in/in^3\n", + "# feedback transducer gain:\n", + "H=4; #V/in\n", + "# weight of load:\n", + "W=1000; #lb\n", + "# mass of load:\n", + "M=2.59; #lb.(s^2)/in\n", + "# volume of oil under compression:\n", + "V=50; #in^3\n", + "# system deadband:\n", + "SD=4; #mA\n", + "# bulk modulus of oil:\n", + "beta1=175000; #lb/in^2\n", + "# cylinder piston area:\n", + "A=5; #in^2# Solutions:\n", + "# natural frequency of the oil,\n", + "om_H=A*(((2*beta1)/(V*M))**0.5); #rad/s\n", + "# value of open-loop gain,\n", + "open_loop=om_H/3; #/s\n", + "# amplifier gain,\n", + "G_A=open_loop/(G_SV*G_cyl*H); #mA/V\n", + "# repeatable error,\n", + "RE=SD/(G_A*H); #in\n", + "\n", + "# Results:\n", + "print\"\\n Results: \"\n", + "print\"\\n The repeatable error of system is in.\",round(RE,5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 17.2 pgno:610" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Results: \n", + "\n", + " The repeatable error of system is cm. 0.00352\n" + ] + } + ], + "source": [ + "# Aim:To determine the system accuracy of in SI units\n", + "# Given:\n", + "# servo valve gain:\n", + "G_SV=2.46; #(cm**3/s)/mA\n", + "# cylinder gain:\n", + "G_cyl=0.031; #cm/cm**3\n", + "# feedback transducer gain:\n", + "H=4; #V/cm\n", + "# mass of load:\n", + "M=450; #kg\n", + "# volume of oil:\n", + "V=819; #cm**3\n", + "# system deadband:\n", + "SD=4; #mA\n", + "# bulk modulus of oil:\n", + "beta1=1200; #MPa\n", + "# cylinder piston area:\n", + "A=32.3; #cm**2\n", + "from math import ceil\n", + "# Solutions:\n", + "# natural frequency of the oil,\n", + "om_H=(A*10**-4)*(((2*beta1*10**6)/(V*10**-6*M))**0.5); #rad/s\n", + "# value of open-loop gain,\n", + "open_loop=om_H/3; #/s\n", + "# amplifier gain,\n", + "G_A=open_loop/(G_SV*G_cyl*H); #mA/V\n", + "# repeatable error,\n", + "RE=SD/(G_A*H); #cm\n", + "# rounding off the above answer,\n", + "RE=round(RE)+(round(ceil((RE-round(RE))*100000))/100000); #cm\n", + "\n", + "# Results:\n", + "print\"\\n Results: \"\n", + "print\"\\n The repeatable error of system is cm.\",RE" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Chapter 17.3 pgno:612" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Results: \n", + "\n", + " The tracking error of system is in. 0.104\n", + "\n", + " The tracking error of system in SI Unit is cm. 0.264\n" + ] + } + ], + "source": [ + "# Aim:Refer Example 14-3 for Problem Description\n", + "# Given:\n", + "# servo valve current saturation:\n", + "I=300.; #mA\n", + "# amplifier gain:\n", + "G_A=724.; #mA/V\n", + "# feedback transducer gain:\n", + "H=4.; #V/in\n", + "# feedback transducer gain in metric units\n", + "H1=1.57; #V/cm# Solutions:\n", + "# tracking error,\n", + "TE=I/(G_A*H); #in\n", + "# tracking error,\n", + "TE1=I/(G_A*H1); #cm\n", + "\n", + "# Results:\n", + "print\"\\n Results: \"\n", + "print\"\\n The tracking error of system is in.\",round(TE,3)\n", + "print\"\\n The tracking error of system in SI Unit is cm.\",round(TE1,3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical_Foundation.ipynb b/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical_Foundation.ipynb deleted file mode 100755 index a514cecb..00000000 --- a/sample_notebooks/Vedantam Lakshmi Manasa/Mathematical_Foundation.ipynb +++ /dev/null @@ -1,212 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 17:Advanced Electdrical Controls For Fluid Power Systems" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 17.1 pgno:610" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " Results: \n", - "\n", - " The repeatable error of system is in. 0.00138\n" - ] - } - ], - "source": [ - "# Aim:To determine the system accuracy of electrohydraulic servo system\n", - "# Given:\n", - "# servo valve gain:\n", - "G_SV=0.15; #(in^3/s)/mA\n", - "# cylinder gain:\n", - "G_cyl=0.20; #in/in^3\n", - "# feedback transducer gain:\n", - "H=4; #V/in\n", - "# weight of load:\n", - "W=1000; #lb\n", - "# mass of load:\n", - "M=2.59; #lb.(s^2)/in\n", - "# volume of oil under compression:\n", - "V=50; #in^3\n", - "# system deadband:\n", - "SD=4; #mA\n", - "# bulk modulus of oil:\n", - "beta1=175000; #lb/in^2\n", - "# cylinder piston area:\n", - "A=5; #in^2# Solutions:\n", - "# natural frequency of the oil,\n", - "om_H=A*(((2*beta1)/(V*M))**0.5); #rad/s\n", - "# value of open-loop gain,\n", - "open_loop=om_H/3; #/s\n", - "# amplifier gain,\n", - "G_A=open_loop/(G_SV*G_cyl*H); #mA/V\n", - "# repeatable error,\n", - "RE=SD/(G_A*H); #in\n", - "\n", - "# Results:\n", - "print\"\\n Results: \"\n", - "print\"\\n The repeatable error of system is in.\",round(RE,5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 17.2 pgno:610" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " Results: \n", - "\n", - " The repeatable error of system is cm. 0.00352\n" - ] - } - ], - "source": [ - "# Aim:To determine the system accuracy of in SI units\n", - "# Given:\n", - "# servo valve gain:\n", - "G_SV=2.46; #(cm**3/s)/mA\n", - "# cylinder gain:\n", - "G_cyl=0.031; #cm/cm**3\n", - "# feedback transducer gain:\n", - "H=4; #V/cm\n", - "# mass of load:\n", - "M=450; #kg\n", - "# volume of oil:\n", - "V=819; #cm**3\n", - "# system deadband:\n", - "SD=4; #mA\n", - "# bulk modulus of oil:\n", - "beta1=1200; #MPa\n", - "# cylinder piston area:\n", - "A=32.3; #cm**2\n", - "from math import ceil\n", - "# Solutions:\n", - "# natural frequency of the oil,\n", - "om_H=(A*10**-4)*(((2*beta1*10**6)/(V*10**-6*M))**0.5); #rad/s\n", - "# value of open-loop gain,\n", - "open_loop=om_H/3; #/s\n", - "# amplifier gain,\n", - "G_A=open_loop/(G_SV*G_cyl*H); #mA/V\n", - "# repeatable error,\n", - "RE=SD/(G_A*H); #cm\n", - "# rounding off the above answer,\n", - "RE=round(RE)+(round(ceil((RE-round(RE))*100000))/100000); #cm\n", - "\n", - "# Results:\n", - "print\"\\n Results: \"\n", - "print\"\\n The repeatable error of system is cm.\",RE" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Chapter 17.3 pgno:612" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " Results: \n", - "\n", - " The tracking error of system is in. 0.104\n", - "\n", - " The tracking error of system in SI Unit is cm. 0.264\n" - ] - } - ], - "source": [ - "# Aim:Refer Example 14-3 for Problem Description\n", - "# Given:\n", - "# servo valve current saturation:\n", - "I=300.; #mA\n", - "# amplifier gain:\n", - "G_A=724.; #mA/V\n", - "# feedback transducer gain:\n", - "H=4.; #V/in\n", - "# feedback transducer gain in metric units\n", - "H1=1.57; #V/cm# Solutions:\n", - "# tracking error,\n", - "TE=I/(G_A*H); #in\n", - "# tracking error,\n", - "TE1=I/(G_A*H1); #cm\n", - "\n", - "# Results:\n", - "print\"\\n Results: \"\n", - "print\"\\n The tracking error of system is in.\",round(TE,3)\n", - "print\"\\n The tracking error of system in SI Unit is cm.\",round(TE1,3)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/VidyashankarVenkatraman/Chapter_3.ipynb b/sample_notebooks/VidyashankarVenkatraman/Chapter_3.ipynb new file mode 100755 index 00000000..26342edb --- /dev/null +++ b/sample_notebooks/VidyashankarVenkatraman/Chapter_3.ipynb @@ -0,0 +1,79 @@ +{ + "metadata": { + "name": "Chapter_3_Kittel" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 3:Introduction to Solid State Physics" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example number 3.1, Page Number 84\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n#Variable declaration\n\ne = 5*pow(10,-10); # charge on the electron\n\nr0 = 1*pow(10,-8); # atomic radius\n\n# Calculation\n\nR = 4*10**(-8); # interatomic distance in cm\n\nU = -4*e**2*r0**5/R**6; # The van der waals interaction formula\n\n# Result\n\nprint \" The Van Der Waals interaction energy is \",U ,\"ergs\"", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " The Van Der Waals interaction energy is -2.44140625e-14 ergs\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example number 3.2, Page Number 91" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n# Variable declaration\n\ne = 4.8*pow(10,-10); # charge on proton\nr0 = 2.81*pow(10,-8); # distance between positive and nearest negative ion in Nacl crystal\n\nU = e**2/r0; # in ergs\n\nE = U/(1.6019*pow(10,-12)); # converting to eV as 1eV = 1.6019 * 10**(-12) ergs\n\n#result\nprint \" The potential energy of the two ions by themselves is \",E,\"eV\"\n\n\n\n\n\n\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " The potential energy of the two ions by themselves is 5.11847696874 eV\n" + } + ], + "prompt_number": 22 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 19 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} diff --git a/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kittel.ipynb b/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kittel.ipynb deleted file mode 100755 index 8760577a..00000000 --- a/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kittel.ipynb +++ /dev/null @@ -1,79 +0,0 @@ -{ - "metadata": { - "name": "Chapter_3_Kittel" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Introduction to Solid State Physics" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example number 3.1, Page Number 84\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n#Variable declaration\n\ne = 5*pow(10,-10); # charge on the electron\n\nr0 = 1*pow(10,-8); # atomic radius\n\n# Calculation\n\nR = 4*10**(-8); # interatomic distance in cm\n\nU = -4*e**2*r0**5/R**6; # The van der waals interaction formula\n\n# Result\n\nprint \" The Van Der Waals interaction energy is \",U ,\"ergs\"", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " The Van Der Waals interaction energy is -2.44140625e-14 ergs\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example number 3.2, Page Number 91" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n# Variable declaration\n\ne = 4.8*pow(10,-10); # charge on proton\nr0 = 2.81*pow(10,-8); # distance between positive and nearest negative ion in Nacl crystal\n\nU = e**2/r0; # in ergs\n\nE = U/(1.6019*pow(10,-12)); # converting to eV as 1eV = 1.6019 * 10**(-12) ergs\n\n#result\nprint \" The potential energy of the two ions by themselves is \",E,\"eV\"\n\n\n\n\n\n\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " The potential energy of the two ions by themselves is 5.11847696874 eV\n" - } - ], - "prompt_number": 22 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "", - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 19 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "", - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kitteldemo.ipynb b/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kitteldemo.ipynb deleted file mode 100755 index 26342edb..00000000 --- a/sample_notebooks/VidyashankarVenkatraman/Chapter_3_Kitteldemo.ipynb +++ /dev/null @@ -1,79 +0,0 @@ -{ - "metadata": { - "name": "Chapter_3_Kittel" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Chapter 3:Introduction to Solid State Physics" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example number 3.1, Page Number 84\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n#Variable declaration\n\ne = 5*pow(10,-10); # charge on the electron\n\nr0 = 1*pow(10,-8); # atomic radius\n\n# Calculation\n\nR = 4*10**(-8); # interatomic distance in cm\n\nU = -4*e**2*r0**5/R**6; # The van der waals interaction formula\n\n# Result\n\nprint \" The Van Der Waals interaction energy is \",U ,\"ergs\"", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " The Van Der Waals interaction energy is -2.44140625e-14 ergs\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example number 3.2, Page Number 91" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n# Variable declaration\n\ne = 4.8*pow(10,-10); # charge on proton\nr0 = 2.81*pow(10,-8); # distance between positive and nearest negative ion in Nacl crystal\n\nU = e**2/r0; # in ergs\n\nE = U/(1.6019*pow(10,-12)); # converting to eV as 1eV = 1.6019 * 10**(-12) ergs\n\n#result\nprint \" The potential energy of the two ions by themselves is \",E,\"eV\"\n\n\n\n\n\n\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " The potential energy of the two ions by themselves is 5.11847696874 eV\n" - } - ], - "prompt_number": 22 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "", - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 19 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "", - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} diff --git a/sample_notebooks/VidyashankarVenkatraman/VidyashankarVenkatraman_version_backup/Chapter_3.ipynb b/sample_notebooks/VidyashankarVenkatraman/VidyashankarVenkatraman_version_backup/Chapter_3.ipynb new file mode 100755 index 00000000..8760577a --- /dev/null +++ b/sample_notebooks/VidyashankarVenkatraman/VidyashankarVenkatraman_version_backup/Chapter_3.ipynb @@ -0,0 +1,79 @@ +{ + "metadata": { + "name": "Chapter_3_Kittel" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Introduction to Solid State Physics" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example number 3.1, Page Number 84\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n#Variable declaration\n\ne = 5*pow(10,-10); # charge on the electron\n\nr0 = 1*pow(10,-8); # atomic radius\n\n# Calculation\n\nR = 4*10**(-8); # interatomic distance in cm\n\nU = -4*e**2*r0**5/R**6; # The van der waals interaction formula\n\n# Result\n\nprint \" The Van Der Waals interaction energy is \",U ,\"ergs\"", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " The Van Der Waals interaction energy is -2.44140625e-14 ergs\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example number 3.2, Page Number 91" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#importing module\n\nfrom __future__ import division\nimport math\n\n# Variable declaration\n\ne = 4.8*pow(10,-10); # charge on proton\nr0 = 2.81*pow(10,-8); # distance between positive and nearest negative ion in Nacl crystal\n\nU = e**2/r0; # in ergs\n\nE = U/(1.6019*pow(10,-12)); # converting to eV as 1eV = 1.6019 * 10**(-12) ergs\n\n#result\nprint \" The potential energy of the two ions by themselves is \",E,\"eV\"\n\n\n\n\n\n\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " The potential energy of the two ions by themselves is 5.11847696874 eV\n" + } + ], + "prompt_number": 22 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 19 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "", + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/Chapter_01.ipynb b/sample_notebooks/VikasPrasad/Chapter_01.ipynb deleted file mode 100755 index b5226e07..00000000 --- a/sample_notebooks/VikasPrasad/Chapter_01.ipynb +++ /dev/null @@ -1,170 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - " \n", - "\t#since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - " \n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to create objects\n", - " #with instances customized to a specific initial state\n", - "\t\t\n", - " #since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - " \n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/Chapter_01_1.ipynb b/sample_notebooks/VikasPrasad/Chapter_01_1.ipynb deleted file mode 100755 index b5226e07..00000000 --- a/sample_notebooks/VikasPrasad/Chapter_01_1.ipynb +++ /dev/null @@ -1,170 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - " \n", - "\t#since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - " \n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to create objects\n", - " #with instances customized to a specific initial state\n", - "\t\t\n", - " #since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - " \n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01.ipynb new file mode 100755 index 00000000..b5226e07 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01.ipynb @@ -0,0 +1,170 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + " \n", + "\t#since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + " \n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to create objects\n", + " #with instances customized to a specific initial state\n", + "\t\t\n", + " #since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + " \n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01_1.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01_1.ipynb new file mode 100755 index 00000000..b5226e07 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/Chapter_01_1.ipynb @@ -0,0 +1,170 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + " \n", + "\t#since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + " \n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to create objects\n", + " #with instances customized to a specific initial state\n", + "\t\t\n", + " #since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + " \n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1.ipynb new file mode 100755 index 00000000..9e1549a9 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1.ipynb @@ -0,0 +1,166 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "1, 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + " #to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method bisy goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "2, 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + " #to treat them as non-public part\n", + "\t_balance = 0.0\t#account balance\n", + "\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\tself._balance = openingBalance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "3, 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_3.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_3.ipynb new file mode 100755 index 00000000..eca44a51 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_3.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t#to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t\t#to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_4.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_4.ipynb new file mode 100755 index 00000000..eca44a51 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_4.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t#to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t\t#to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_5.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_5.ipynb new file mode 100755 index 00000000..eca44a51 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_5.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t#to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t\t#to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_6.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_6.ipynb new file mode 100755 index 00000000..eca44a51 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_6.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t#to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t\t#to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_7.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_7.ipynb new file mode 100755 index 00000000..eca44a51 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_7.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t#to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", + "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", + "\t\t#to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_8.ipynb b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_8.ipynb new file mode 100755 index 00000000..b5226e07 --- /dev/null +++ b/sample_notebooks/VikasPrasad/VikasPrasad_version_backup/chapter1_8.ipynb @@ -0,0 +1,170 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "1: Overview of Data Structures and Algorithms" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1: Page 20" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "class Thermostat:\n", + "\t\"\"\"A simple thermostat class\"\"\"\n", + " \n", + "\t#since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t_currentTemp = 0.0\n", + "\t_desiredTemp = 0.0\n", + "\n", + "\tdef furnace_on(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + "\n", + "\tdef furnace_off(self):\n", + "\t\t#method body goes here\n", + "\t\tpass\n", + " \n", + "#end class Thermostat" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2: Page 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#demonstrates basic OOP syntax\n", + "\n", + "class BankAccount:\n", + "\t\"\"\"A simple bank account class\"\"\"\n", + "\t\n", + "\tdef __init__(self, openingBalance):\t#special method to create objects\n", + " #with instances customized to a specific initial state\n", + "\t\t\n", + " #since private instance variables don't exist in Python,\n", + " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", + "\t self._balance = openingBalance\t#account balance\n", + "\n", + "\tdef deposit(self, amount):\t#makes deposit\n", + "\t\tself._balance = self._balance + amount\n", + "\n", + "\tdef withdraw(self, amount):\t#makes withdrawl\n", + "\t\tself._balance = self._balance - amount\n", + "\n", + "\tdef display(self):\t#displays balance\n", + "\t\tprint 'Balance=', self._balance\n", + " \n", + "#end class BankAccount\n", + "\n", + "ba1 = BankAccount(100.00)\t#create account\n", + "\n", + "print 'Before transactions, ',\n", + "ba1.display()\t#display balance\n", + "\n", + "ba1.deposit(74.35)\t#make deposit\n", + "ba1.withdraw(20.00)\t#make withdrawl\n", + "\n", + "print 'After transactions, ',\n", + "ba1.display()\t#display balance\n", + "#end" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Before transactions, Balance= 100.0\n", + "After transactions, Balance= 154.35\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 3: Page 25" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#creating string objects\n", + "str1 = ''\n", + "str2 = 'George'\n", + "\n", + "#verifying results\n", + "print str1\n", + "print str2\n", + "\n", + "#naming string object\n", + "str3 = 'amanuensis'\n", + "\n", + "#verifying results\n", + "print str3\n", + "\n", + "#accessing specific characters from string using [] operator\n", + "ch1 = str2[3]\n", + "\n", + "#verifying results\n", + "print ch1\n", + "\n", + "#finding and printing number of characters in a string\n", + "print len(str1)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "George\n", + "amanuensis\n", + "r\n", + "0\n" + ] + } + ], + "prompt_number": 3 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1.ipynb b/sample_notebooks/VikasPrasad/chapter1.ipynb deleted file mode 100755 index 9e1549a9..00000000 --- a/sample_notebooks/VikasPrasad/chapter1.ipynb +++ /dev/null @@ -1,166 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "1, 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - " #to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method bisy goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "2, 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - " #to treat them as non-public part\n", - "\t_balance = 0.0\t#account balance\n", - "\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\tself._balance = openingBalance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "3, 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_3.ipynb b/sample_notebooks/VikasPrasad/chapter1_3.ipynb deleted file mode 100755 index eca44a51..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_3.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t#to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t\t#to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_4.ipynb b/sample_notebooks/VikasPrasad/chapter1_4.ipynb deleted file mode 100755 index eca44a51..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_4.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t#to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t\t#to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_5.ipynb b/sample_notebooks/VikasPrasad/chapter1_5.ipynb deleted file mode 100755 index eca44a51..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_5.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t#to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t\t#to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_6.ipynb b/sample_notebooks/VikasPrasad/chapter1_6.ipynb deleted file mode 100755 index eca44a51..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_6.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t#to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t\t#to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_7.ipynb b/sample_notebooks/VikasPrasad/chapter1_7.ipynb deleted file mode 100755 index eca44a51..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_7.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - "\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t#to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to cerate objects with instances customized to a specific initial state\n", - "\t\t#since private instance variables don't exist in Python, hence using a convention: name prefixed with an underscore,\n", - "\t\t#to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VikasPrasad/chapter1_8.ipynb b/sample_notebooks/VikasPrasad/chapter1_8.ipynb deleted file mode 100755 index b5226e07..00000000 --- a/sample_notebooks/VikasPrasad/chapter1_8.ipynb +++ /dev/null @@ -1,170 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "1: Overview of Data Structures and Algorithms" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1: Page 20" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "class Thermostat:\n", - "\t\"\"\"A simple thermostat class\"\"\"\n", - " \n", - "\t#since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t_currentTemp = 0.0\n", - "\t_desiredTemp = 0.0\n", - "\n", - "\tdef furnace_on(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - "\n", - "\tdef furnace_off(self):\n", - "\t\t#method body goes here\n", - "\t\tpass\n", - " \n", - "#end class Thermostat" - ], - "language": "python", - "metadata": {}, - "outputs": [], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2: Page 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#demonstrates basic OOP syntax\n", - "\n", - "class BankAccount:\n", - "\t\"\"\"A simple bank account class\"\"\"\n", - "\t\n", - "\tdef __init__(self, openingBalance):\t#special method to create objects\n", - " #with instances customized to a specific initial state\n", - "\t\t\n", - " #since private instance variables don't exist in Python,\n", - " #hence using a convention: name prefixed with an underscore, to treat them as non-public part\n", - "\t self._balance = openingBalance\t#account balance\n", - "\n", - "\tdef deposit(self, amount):\t#makes deposit\n", - "\t\tself._balance = self._balance + amount\n", - "\n", - "\tdef withdraw(self, amount):\t#makes withdrawl\n", - "\t\tself._balance = self._balance - amount\n", - "\n", - "\tdef display(self):\t#displays balance\n", - "\t\tprint 'Balance=', self._balance\n", - " \n", - "#end class BankAccount\n", - "\n", - "ba1 = BankAccount(100.00)\t#create account\n", - "\n", - "print 'Before transactions, ',\n", - "ba1.display()\t#display balance\n", - "\n", - "ba1.deposit(74.35)\t#make deposit\n", - "ba1.withdraw(20.00)\t#make withdrawl\n", - "\n", - "print 'After transactions, ',\n", - "ba1.display()\t#display balance\n", - "#end" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Before transactions, Balance= 100.0\n", - "After transactions, Balance= 154.35\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 3: Page 25" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#creating string objects\n", - "str1 = ''\n", - "str2 = 'George'\n", - "\n", - "#verifying results\n", - "print str1\n", - "print str2\n", - "\n", - "#naming string object\n", - "str3 = 'amanuensis'\n", - "\n", - "#verifying results\n", - "print str3\n", - "\n", - "#accessing specific characters from string using [] operator\n", - "ch1 = str2[3]\n", - "\n", - "#verifying results\n", - "print ch1\n", - "\n", - "#finding and printing number of characters in a string\n", - "print len(str1)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "George\n", - "amanuensis\n", - "r\n", - "0\n" - ] - } - ], - "prompt_number": 3 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/VineshSaini/Ch1.ipynb b/sample_notebooks/VineshSaini/Ch1.ipynb deleted file mode 100755 index f27cc088..00000000 --- a/sample_notebooks/VineshSaini/Ch1.ipynb +++ /dev/null @@ -1,516 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter1 - Vaccum Tubes and Semiconductors" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1.1 page : 41" - ] - }, - { - "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "VAK2 = 300.00 volts\n", - "VAK1 = 170.00 volts\n", - "IA2 = 0.0020 ampere\n", - "IA1 = 0.0000 ampere\n", - "resistance,rP =(VAK2-VAK1)/(IA2-IA1)=65000.00 ohm\n", - "VGK2 = -2.50 volts\n", - "VGK1 = -1.50 volts\n", - "VAK3 = 200.00 volts\n", - "amplification factor,u =(VAK2-VAK1)/(VGK2-VGK1)=-100.00 unitless \n", - "IA4 = 0.0022 ampere\n", - "IA1 = 0.0005 ampere\n", - "transconductance,gm =(IAK4-IAK3)/(VGK2-VGK3)=-0.00 ampere/volt \n" - ] - } - ], - "source": [ - "from __future__ import division\n", - "#refer to fig 1.2(c) and given d.c operating points VGKQ=-2 V,VAKQ=250 V,IAQ=-1.2 mA\n", - "VAK2=300\n", - "print \"VAK2 = %0.2f\"%(VAK2),\" volts\" # value of anode voltage2 \n", - "VAK1=170\n", - "print \"VAK1 = %0.2f\"%(VAK1),\" volts\" # value of anode voltage1 \n", - "IA2=2*10**(-3)\n", - "print \"IA2 = %0.4f\"%(IA2),\" ampere\" # value of anode current2\n", - "IA1=0*10**(-3)\n", - "print \"IA1 = %0.4f\"%(IA1),\" ampere\" # value of anode current1\n", - "rP=(VAK2-VAK1)/(IA2-IA1)#anode resistance at VGK=VGKQ\n", - "print \"resistance,rP =(VAK2-VAK1)/(IA2-IA1)=%0.2f\"%(rP),\" ohm\" #calculation\n", - "VGK2=-2.5\n", - "print \"VGK2 = %0.2f\"%(VGK2),\" volts\" # value of grid voltage2 \n", - "VGK3=-1.5\n", - "print \"VGK1 = %0.2f\"%(VGK3),\" volts\" # value of grid voltage1\n", - "VAK3=200\n", - "print \"VAK3 = %0.2f\"%(VAK3),\" volts\" # value of anode voltage1 \n", - "u=(VAK2-VAK3)/(VGK2-VGK3)#amplification factor at IA=IAQ\n", - "print \"amplification factor,u =(VAK2-VAK1)/(VGK2-VGK1)=%0.2f\"%(u),\" unitless \" #calculation\n", - "IA4=2.2*10**(-3)\n", - "print \"IA4 = %0.4f\"%(IA4),\" ampere\" # value of anode current4\n", - "IA3=0.5*10**(-3)\n", - "print \"IA1 = %0.4f\"%(IA3),\" ampere\" # value of anode current1\n", - "gm=(IA4-IA3)/(VGK2-VGK3)# transconductance at VAK=VAKQ\n", - "print \"transconductance,gm =(IAK4-IAK3)/(VGK2-VGK3)=%0.2f\"%(gm),\" ampere/volt \" #calculation\n", - "#mistake of negative sign for answers for u(amplification factor) and gm(transconductance)in book" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1_2 page : 41" - ] - }, - { - "cell_type": "code", - "execution_count": 44, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "d = 0.01 metre\n", - "l = 0.02 metre\n", - "L = 0.20 metre\n", - "Va = 2000.00 volts\n", - "Vd = 100.00 volts\n", - "m = 9.11e-31 Kg\n", - "q = 1.60e-19 coulomb\n", - "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\n", - "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= 2.65e+07 metre/second\n", - "transit time,t1 =(l/Vx) second\n", - "transit time,t1 =(l/Vx)= 7.55e-10 second\n", - "vertical beam velocity,Vy =(q*Vd*l/d*m*Vx) metre/second\n", - "vertical beam velocity,Vy =(q*Vd*l/d*m*Vx)= 2.65e+06 metre/second\n", - "vertical displacement,D =((l*L*Vd)/(2*d*Va) metre\n", - "vertical displacement,D =((l*L*Vd)/(2*d*Va)=0.02 metre\n", - "sensitivity of CRT,S =(0.5*l*L)/(d*Va) metre/volt\n", - "sensitivity of CRT,S =(0.5*l*L)/(d*Va)=2.0e-04 metre/volt\n" - ] - } - ], - "source": [ - "d=0.5*10**(-2)\n", - "print \"d = %0.2f\"%(d),\"metre\" #initializing value of distance b/w plates\n", - "l=2*10**(-2)\n", - "print \"l = %0.2f\"%(l),\"metre\" #initializing value of length of plates\n", - "L=20*10**(-2)\n", - "print \"L = %0.2f\"%(L),\"metre\" #initializing value of distance b/w centre of plates and screen\n", - "Va=2000\n", - "print \"Va = %0.2f\"%(Va),\"volts\" ##initializing value ofanode voltage\n", - "Vd=100\n", - "print \"Vd = %0.2f\"%(Vd),\"volts\" #initializing value of deflecting voltage\n", - "m=9.11*10**(-31)\n", - "print \"m = %0.2e\"%(m),\"Kg\" #mass of electron\n", - "q=1.6*10**(-19)\n", - "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", - "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\" #formula\n", - "Vx =(2*Va*q/m)**(0.5)\n", - "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= %0.2e\"%(Vx),\" metre/second\" #calculation\n", - "print \"transit time,t1 =(l/Vx) second\" #formula\n", - "t1=(l/Vx)\n", - "print \"transit time,t1 =(l/Vx)= %0.2e\"%(t1),\" second\" #calculation\n", - "print \"vertical beam velocity,Vy =(q*Vd*l/d*m*Vx) metre/second\" #formula\n", - "Vy=((q*Vd*l)/(d*m*Vx))\n", - "print \"vertical beam velocity,Vy =(q*Vd*l/d*m*Vx)= %0.2e\"%(Vy),\" metre/second\" #calculation\n", - "print \"vertical displacement,D =((l*L*Vd)/(2*d*Va) metre\" #formula\n", - "D =(l*L*Vd)/(2*d*Va)\n", - "print \"vertical displacement,D =((l*L*Vd)/(2*d*Va)=%0.2f\"%(D),\" metre\" #calculation\n", - "print \"sensitivity of CRT,S =(0.5*l*L)/(d*Va) metre/volt\" #formula\n", - "S =(0.5*l*L)/(d*Va)\n", - "print \"sensitivity of CRT,S =(0.5*l*L)/(d*Va)=%0.1e\"%(S),\" metre/volt\" #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1-3 page : 42" - ] - }, - { - "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "m = 9.11e-31 Kg\n", - "q = 1.60e-19 coulomb\n", - "B = 1.50e-03 wb/m**2\n", - "l = 0.05 metre\n", - "L = 0.30 metre\n", - "Va = 10000.00 volts\n", - "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\n", - "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= 5.93e+07 metre/second\n", - "radius,r =(m*Vx)/(B*q) metre\n", - "radius,r =(m*Vx)/(B*q)= 0.22 metre\n", - "deflection,D =(L*l)/r) metre\n", - "deflection,D =(L*l)/r)=0.07 metre\n" - ] - } - ], - "source": [ - "m=9.11*10**(-31)\n", - "print \"m = %0.2e\"%(m),\" Kg\" #mass of electron\n", - "q=1.6*10**(-19)\n", - "print \"q = %0.2e\"%(q),\" coulomb\" #charge on an electron\n", - "B=1.5*10**(-3)\n", - "print \"B = %0.2e\"%(B)+ \" wb/m**2\" #initializing value of magnetic field\n", - "l=5*10**(-2)\n", - "print \"l = %0.2f\"%(l),\" metre\" #initializing axial length of magnetic field\n", - "L=30*10**(-2)\n", - "print \"L = %0.2f\"%(L),\" metre\" #initializing value of distance of screen from centre of magnetic field\n", - "Va=10000\n", - "print \"Va = %0.2f\"%(Va),\" volts\" ##initializing value of anode voltage\n", - "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\" #formula\n", - "Vx =(2*Va*q/m)**(0.5)\n", - "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= %0.2e\"%(Vx),\" metre/second\" #calculation\n", - "print \"radius,r =(m*Vx)/(B*q) metre\" #formula\n", - "r =(m*Vx)/(B*q)\n", - "print \"radius,r =(m*Vx)/(B*q)= %0.2f\"%(r),\" metre\" #calculation\n", - "print \"deflection,D =(L*l)/r) metre\" #formula\n", - "D =(L*l)/r\n", - "print \"deflection,D =(L*l)/r)=%0.2f\"%(D),\" metre\" #calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex -1.4 page : 43" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "q = 1.60e-19 coulomb\n", - "I = 10.00 Ampere\n", - "radius,r = 64.25 mils\n", - "r1 = 0.00 metre\n", - "n = 5.00e+28 electrons/m**3\n", - "cross sectional area,A =(pi*r1**2)= 8.37e-06 square metre\n", - "drift velocity,v=(I)/(A*q*n)=1.49e-04 metre/second\n" - ] - } - ], - "source": [ - "from math import pi\n", - "q=1.6*10**(-19)\n", - "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", - "I=10\n", - "print \"I = %0.2f\"%(I),\"Ampere\" #initializing value of current\n", - "r=64.25\n", - "print \"radius,r = %0.2f\"%(r),\" mils\" #initializing value of radius of wire\n", - "def mils2metres(mils):\n", - " metres=(mils*2.54)/(1000*100)\n", - " return metres\n", - "r1=mils2metres(r) \n", - "print \"r1 = %0.2f\"%(r1),\" metre\"\n", - "n=5*10**(28)\n", - "print \"n = %0.2e\"%(n),\" electrons/m**3\" # electrons concentration in copper\n", - "A=(pi*r1**2) #formulae \n", - "print \"cross sectional area,A =(pi*r1**2)= %0.2e\"%(A),\" square metre\" #calculation\n", - "v=(I)/(A*q*n)#formulae(I=A*q*n*v)\n", - "print \"drift velocity,v=(I)/(A*q*n)=%0.2e\"%(v),\" metre/second\" #calculation\n", - "\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1_5 page : 44" - ] - }, - { - "cell_type": "code", - "execution_count": 47, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "cross sectional area,A =1.00e-05 merer square\n", - "resitivity(rho),p1 =1.00e-04 ohm-m\n", - "resitivity(rho),p2 =1000.00 ohm-m\n", - "resitivity(rho),p3 =1.00e+10 ohm-m\n", - "conductor length,l =0.01 metre\n", - " resistance for copper,R = p1*l/A = 0.10 ohm\n", - " resistance for silicon,R = p2*l/A = 1.00e+06 ohm\n", - " resistance for glass,R = p3*l/A = 1.00e+13 ohm\n" - ] - } - ], - "source": [ - "A=10*10**(-6)\n", - "p1=10**(-4)\n", - "p2=10**(3)\n", - "p3=10**(10)\n", - "l=1*10**(-2)# #initializations\n", - "print \"cross sectional area,A =%0.2e\"%(A),\"merer square\" \n", - "print \"resitivity(rho),p1 =%0.2e\"%(p1),\" ohm-m\"\n", - "print \"resitivity(rho),p2 =%0.2f\"%(p2),\" ohm-m\"\n", - "print \"resitivity(rho),p3 =%0.2e\"%(p3),\" ohm-m\"\n", - "print \"conductor length,l =%0.2f\"%(l),\" metre\"\n", - "print \" resistance for copper,R = p1*l/A = %0.2f\"%(p1*l/A),\"ohm\" #calculations for copper\n", - "print \" resistance for silicon,R = p2*l/A = %0.2e\"%(p2*l/A),\"ohm\" #calculations for silicon\n", - "print \" resistance for glass,R = p3*l/A = %0.2e\"%(p3*l/A),\"ohm\" #calculations for glass" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1_6 page : 45" - ] - }, - { - "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I = 1.00e-06 Ampere\n", - "intrinsic charge concentration,ni = 1.45e+10 /centimetre cube\n", - "silicon atoms concntration, nV = 5.00e+22 /centimetre cube \n", - "electron mobility,un = 1500.00 cm.sq/V-s\n", - "hole mobility,up = 475.00 cm.sq/V-s\n", - "temperature,T = 300.00 K\n", - "q = 1.59e-19 coulomb\n", - "cross sectional area,A =2.50e-05 cm square\n", - "conductor length,l =0.01 cm\n", - "relative concentration,N =nV/ni= 3.45e+12 silicon atoms per electron -hole pair\n", - "intrinsic conductivityi,sigma =(1.59*10**(-19)*(1.45*10**10)*(1500+0475))= 0.00 (ohm-cm)**-1\n", - "resitivity(rho),pi =(1/sigma)=2.20e+05 ohm-cm\n", - " resistance for silicon,R =((2.22*10**5*0.5)/0.000025) = 4.44e+09 ohm\n", - " voltage drop,V =I*R = 4440.00 V\n" - ] - } - ], - "source": [ - "ni = 1.45*10**10 #initializations\n", - "nV = 5*10**22 #initializations\n", - "un = 1500 #initializations\n", - "up = 475#initializations\n", - "T = 300 #initializations\n", - "I=10**(-6)\n", - "print \"I = %0.2e\"%(I),\"Ampere\" #initializing value of current\n", - "A=(50*10**(-4))**2# l=0.5 #initializations\n", - "q=1.59*10**(-19) #charge on an electron\n", - "print \"intrinsic charge concentration,ni = %0.2e\"%(ni),\" /centimetre cube\"\n", - "print \"silicon atoms concntration, nV = %0.2e\"%(nV),\" /centimetre cube \"\n", - "\n", - "print \"electron mobility,un = %0.2f\"%(un),\" cm.sq/V-s\"\n", - "print \"hole mobility,up = %0.2f\"%(up),\"cm.sq/V-s\"\n", - "print \"temperature,T = %0.2f\"%(T),\"K\"\n", - "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", - "print \"cross sectional area,A =%0.2e\"%(A),\"cm square\" \n", - "print \"conductor length,l =%0.2f\"%(l),\"cm\"\n", - "N=nV/ni\n", - "print \"relative concentration,N =nV/ni= %0.2e\"%(N),\" silicon atoms per electron -hole pair\" #calculation\n", - "sigma=(1.59*10**(-19)*(1.45*10**10)*(1500+475))\n", - "print \"intrinsic conductivityi,sigma =(1.59*10**(-19)*(1.45*10**10)*(1500+0475))= %0.2f\"%(sigma),\" (ohm-cm)**-1\" #calculation\n", - "pi =(1/sigma)#formulae\n", - "print \"resitivity(rho),pi =(1/sigma)=%0.2e\"%(pi),\" ohm-cm\" #calculation\n", - "R=(2.22*10**5*0.5)/0.000025\n", - "print \" resistance for silicon,R =((2.22*10**5*0.5)/0.000025) = %0.2e\"%(R),\" ohm\" #calculations for silicon\n", - "V=I*R\n", - "print \" voltage drop,V =I*R = %0.2f\"%(V),\" V\" #calculations " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1_7 page : 45" - ] - }, - { - "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "I = 1.00e-06 Ampere\n", - "intrinsic charge concentration,ni = 1.45e+10 /centimetre cube\n", - "silicon atoms concntration, nV = 5.00e+22 /centimetre cube \n", - "electron mobility,un = 1500.00 cm.sq/V-s\n", - "hole mobility,up = 317.00 cm.sq/V-s\n", - "temperature,T = 300.00 K\n", - "q = 0.00 coulomb\n", - "cross sectional area,A =0.00 cm square\n", - "conductor length,l =0.01 cm\n", - "donor concentration,nD= nV/10**6=50000000000000000.00 /cm.cube\n", - "resulting mobile electron concentration,nn= nD=5.00e+16 /cm.cube\n", - "resulting hole concentration,pn= ni**2/nD=4.20e+03 /cm.cube\n", - "n-type semiconductor conductivity,sigma=q*nD*un= 11.93 (ohm-cm)**-1\n", - "doped silicon resitivity(rho),pn =(1/sigma)=0.08 ohm-cm\n", - " resistance for silicon,R =((0.084*0.5)/A) = 1680.00 ohm\n", - " voltage drop,V =I*R = 1.68e-03 V\n" - ] - } - ], - "source": [ - "ni = 1.45*10**10 #initializations\n", - "nV = 5*10**22 #initializations\n", - "un = 1500 #initializations\n", - "up = 0475#initializations\n", - "T = 300 #initializations\n", - "I=10**(-6)\n", - "print \"I = %0.2e\"%(I),\"Ampere\" #initializing value of current\n", - "A=(50*10**(-4))**2# l=0.5 #initializations\n", - "q=1.59*10**(-19) #charge on an electron\n", - "print \"intrinsic charge concentration,ni = %0.2e\"%(ni),\" /centimetre cube\"\n", - "print \"silicon atoms concntration, nV = %0.2e\"%(nV),\" /centimetre cube \"\n", - "\n", - "print \"electron mobility,un = %0.2f\"%(un),\" cm.sq/V-s\"\n", - "print \"hole mobility,up = %0.2f\"%(up),\" cm.sq/V-s\"\n", - "print \"temperature,T = %0.2f\"%(T),\" K\"\n", - "print \"q = %0.2f\"%(q),\"coulomb\" #charge on an electron\n", - "print \"cross sectional area,A =%0.2f\"%(A),\" cm square\" \n", - "print \"conductor length,l =%0.2f\"%(l),\" cm\"\n", - "nD=nV/10**6#formulae\n", - "print \"donor concentration,nD= nV/10**6=%0.2f\"%(nD),\" /cm.cube\" #calculation\n", - "nn=nD#formulae\n", - "print \"resulting mobile electron concentration,nn= nD=%0.2e\"%(nn),\" /cm.cube\" #calculation\n", - "pn= ni**2/nD#formulae\n", - "print \"resulting hole concentration,pn= ni**2/nD=%0.2e\"%(pn),\" /cm.cube\" #calculation\n", - "sigma=q*nD*un#formulae\n", - "print \"n-type semiconductor conductivity,sigma=q*nD*un= %0.2f\"%(sigma),\" (ohm-cm)**-1\" #calculation\n", - "pn =(1/sigma)\n", - "print \"doped silicon resitivity(rho),pn =(1/sigma)=%0.2f\"%(pn),\" ohm-cm\" #calculation\n", - "R=(0.084*0.5)/A\n", - "print \" resistance for silicon,R =((0.084*0.5)/A) = %0.2f\"%(R),\" ohm\" #calculations for silicon\n", - "V=I*R\n", - "print \" voltage drop,V =I*R = %0.2e\"%(V),\" V\" #calculations " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Ex 1_8 page : 46" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "q = 1.59e-19 coulomb\n", - "dimension of semiconductor,d=0.04 cm\n", - "cross sectional area,A =d**2=1.37e-03 cm square\n", - "thickness,x =1.00e-04 cm\n", - "thickness,x0 =0 cm\n", - "hole concentration at x,p= 9.22e+15 /cm-cube\n", - "hole concentration at x0,p0= 0 /cm-cube\n", - " change in concentration at ,dp= 9.22e+15 /cm-cube\n", - "change in thickness,dx= 1.00e-04 cm\n", - " slope,(dp/dx) =(p-p0)/(x-x0)=9.22e+19 holes/cm-cube\n", - "hole diffusion constant,Dp= 12.00 cm-sq/s\n", - " hole diffusion current,Ip =A*q*Dp*(dp/dx)=0.24 ampere\n" - ] - } - ], - "source": [ - "q=1.59*10**(-19) #charge on an electron\n", - "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", - "d=0.037\n", - "print \"dimension of semiconductor,d=%0.2f\"%(d),\" cm\"\n", - "A=(d**2) #area formulae for square shaped semiconductor\n", - "print \"cross sectional area,A =d**2=%0.2e\"%(A),\" cm square\" \n", - "x=10**(-4)\n", - "print \"thickness,x =%0.2e\"%(x),\" cm\"\n", - "x0=0\n", - "print \"thickness,x0 =%0.f\"%(x0),\" cm\"\n", - "p=9.22*10**(15)#\n", - "print \"hole concentration at x,p= %0.2e\"%(p),\" /cm-cube\" #calculation\n", - "p0=0#\n", - "print \"hole concentration at x0,p0= %0.f\"%(p0),\" /cm-cube\" #calculation\n", - "dp=(p-p0)#formulae\n", - "dx=(x-x0)#formulae\n", - "print \" change in concentration at ,dp= %0.2e\"%(dp),\" /cm-cube\" #calculation\n", - "print \"change in thickness,dx= %0.2e\"%(dx),\" cm\" #calculation\n", - "(dp/dx)==(p-p0)/(x-x0)#formulae\n", - "print \" slope,(dp/dx) =(p-p0)/(x-x0)=%0.2e\"%(dp/dx),\" holes/cm-cube\" #calculation\n", - "Dp=12\n", - "print \"hole diffusion constant,Dp= %0.2f\"%(Dp),\" cm-sq/s\" #calculation\n", - "Ip=A*q*Dp*(dp/dx)\n", - "print \" hole diffusion current,Ip =A*q*Dp*(dp/dx)=%0.2f\"%(Ip),\" ampere\" #calculation" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/VineshSaini/VineshSaini_version_backup/Ch1.ipynb b/sample_notebooks/VineshSaini/VineshSaini_version_backup/Ch1.ipynb new file mode 100755 index 00000000..f27cc088 --- /dev/null +++ b/sample_notebooks/VineshSaini/VineshSaini_version_backup/Ch1.ipynb @@ -0,0 +1,516 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter1 - Vaccum Tubes and Semiconductors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1.1 page : 41" + ] + }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "VAK2 = 300.00 volts\n", + "VAK1 = 170.00 volts\n", + "IA2 = 0.0020 ampere\n", + "IA1 = 0.0000 ampere\n", + "resistance,rP =(VAK2-VAK1)/(IA2-IA1)=65000.00 ohm\n", + "VGK2 = -2.50 volts\n", + "VGK1 = -1.50 volts\n", + "VAK3 = 200.00 volts\n", + "amplification factor,u =(VAK2-VAK1)/(VGK2-VGK1)=-100.00 unitless \n", + "IA4 = 0.0022 ampere\n", + "IA1 = 0.0005 ampere\n", + "transconductance,gm =(IAK4-IAK3)/(VGK2-VGK3)=-0.00 ampere/volt \n" + ] + } + ], + "source": [ + "from __future__ import division\n", + "#refer to fig 1.2(c) and given d.c operating points VGKQ=-2 V,VAKQ=250 V,IAQ=-1.2 mA\n", + "VAK2=300\n", + "print \"VAK2 = %0.2f\"%(VAK2),\" volts\" # value of anode voltage2 \n", + "VAK1=170\n", + "print \"VAK1 = %0.2f\"%(VAK1),\" volts\" # value of anode voltage1 \n", + "IA2=2*10**(-3)\n", + "print \"IA2 = %0.4f\"%(IA2),\" ampere\" # value of anode current2\n", + "IA1=0*10**(-3)\n", + "print \"IA1 = %0.4f\"%(IA1),\" ampere\" # value of anode current1\n", + "rP=(VAK2-VAK1)/(IA2-IA1)#anode resistance at VGK=VGKQ\n", + "print \"resistance,rP =(VAK2-VAK1)/(IA2-IA1)=%0.2f\"%(rP),\" ohm\" #calculation\n", + "VGK2=-2.5\n", + "print \"VGK2 = %0.2f\"%(VGK2),\" volts\" # value of grid voltage2 \n", + "VGK3=-1.5\n", + "print \"VGK1 = %0.2f\"%(VGK3),\" volts\" # value of grid voltage1\n", + "VAK3=200\n", + "print \"VAK3 = %0.2f\"%(VAK3),\" volts\" # value of anode voltage1 \n", + "u=(VAK2-VAK3)/(VGK2-VGK3)#amplification factor at IA=IAQ\n", + "print \"amplification factor,u =(VAK2-VAK1)/(VGK2-VGK1)=%0.2f\"%(u),\" unitless \" #calculation\n", + "IA4=2.2*10**(-3)\n", + "print \"IA4 = %0.4f\"%(IA4),\" ampere\" # value of anode current4\n", + "IA3=0.5*10**(-3)\n", + "print \"IA1 = %0.4f\"%(IA3),\" ampere\" # value of anode current1\n", + "gm=(IA4-IA3)/(VGK2-VGK3)# transconductance at VAK=VAKQ\n", + "print \"transconductance,gm =(IAK4-IAK3)/(VGK2-VGK3)=%0.2f\"%(gm),\" ampere/volt \" #calculation\n", + "#mistake of negative sign for answers for u(amplification factor) and gm(transconductance)in book" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1_2 page : 41" + ] + }, + { + "cell_type": "code", + "execution_count": 44, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "d = 0.01 metre\n", + "l = 0.02 metre\n", + "L = 0.20 metre\n", + "Va = 2000.00 volts\n", + "Vd = 100.00 volts\n", + "m = 9.11e-31 Kg\n", + "q = 1.60e-19 coulomb\n", + "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\n", + "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= 2.65e+07 metre/second\n", + "transit time,t1 =(l/Vx) second\n", + "transit time,t1 =(l/Vx)= 7.55e-10 second\n", + "vertical beam velocity,Vy =(q*Vd*l/d*m*Vx) metre/second\n", + "vertical beam velocity,Vy =(q*Vd*l/d*m*Vx)= 2.65e+06 metre/second\n", + "vertical displacement,D =((l*L*Vd)/(2*d*Va) metre\n", + "vertical displacement,D =((l*L*Vd)/(2*d*Va)=0.02 metre\n", + "sensitivity of CRT,S =(0.5*l*L)/(d*Va) metre/volt\n", + "sensitivity of CRT,S =(0.5*l*L)/(d*Va)=2.0e-04 metre/volt\n" + ] + } + ], + "source": [ + "d=0.5*10**(-2)\n", + "print \"d = %0.2f\"%(d),\"metre\" #initializing value of distance b/w plates\n", + "l=2*10**(-2)\n", + "print \"l = %0.2f\"%(l),\"metre\" #initializing value of length of plates\n", + "L=20*10**(-2)\n", + "print \"L = %0.2f\"%(L),\"metre\" #initializing value of distance b/w centre of plates and screen\n", + "Va=2000\n", + "print \"Va = %0.2f\"%(Va),\"volts\" ##initializing value ofanode voltage\n", + "Vd=100\n", + "print \"Vd = %0.2f\"%(Vd),\"volts\" #initializing value of deflecting voltage\n", + "m=9.11*10**(-31)\n", + "print \"m = %0.2e\"%(m),\"Kg\" #mass of electron\n", + "q=1.6*10**(-19)\n", + "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", + "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\" #formula\n", + "Vx =(2*Va*q/m)**(0.5)\n", + "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= %0.2e\"%(Vx),\" metre/second\" #calculation\n", + "print \"transit time,t1 =(l/Vx) second\" #formula\n", + "t1=(l/Vx)\n", + "print \"transit time,t1 =(l/Vx)= %0.2e\"%(t1),\" second\" #calculation\n", + "print \"vertical beam velocity,Vy =(q*Vd*l/d*m*Vx) metre/second\" #formula\n", + "Vy=((q*Vd*l)/(d*m*Vx))\n", + "print \"vertical beam velocity,Vy =(q*Vd*l/d*m*Vx)= %0.2e\"%(Vy),\" metre/second\" #calculation\n", + "print \"vertical displacement,D =((l*L*Vd)/(2*d*Va) metre\" #formula\n", + "D =(l*L*Vd)/(2*d*Va)\n", + "print \"vertical displacement,D =((l*L*Vd)/(2*d*Va)=%0.2f\"%(D),\" metre\" #calculation\n", + "print \"sensitivity of CRT,S =(0.5*l*L)/(d*Va) metre/volt\" #formula\n", + "S =(0.5*l*L)/(d*Va)\n", + "print \"sensitivity of CRT,S =(0.5*l*L)/(d*Va)=%0.1e\"%(S),\" metre/volt\" #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1-3 page : 42" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "m = 9.11e-31 Kg\n", + "q = 1.60e-19 coulomb\n", + "B = 1.50e-03 wb/m**2\n", + "l = 0.05 metre\n", + "L = 0.30 metre\n", + "Va = 10000.00 volts\n", + "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\n", + "horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= 5.93e+07 metre/second\n", + "radius,r =(m*Vx)/(B*q) metre\n", + "radius,r =(m*Vx)/(B*q)= 0.22 metre\n", + "deflection,D =(L*l)/r) metre\n", + "deflection,D =(L*l)/r)=0.07 metre\n" + ] + } + ], + "source": [ + "m=9.11*10**(-31)\n", + "print \"m = %0.2e\"%(m),\" Kg\" #mass of electron\n", + "q=1.6*10**(-19)\n", + "print \"q = %0.2e\"%(q),\" coulomb\" #charge on an electron\n", + "B=1.5*10**(-3)\n", + "print \"B = %0.2e\"%(B)+ \" wb/m**2\" #initializing value of magnetic field\n", + "l=5*10**(-2)\n", + "print \"l = %0.2f\"%(l),\" metre\" #initializing axial length of magnetic field\n", + "L=30*10**(-2)\n", + "print \"L = %0.2f\"%(L),\" metre\" #initializing value of distance of screen from centre of magnetic field\n", + "Va=10000\n", + "print \"Va = %0.2f\"%(Va),\" volts\" ##initializing value of anode voltage\n", + "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5) metre/second\" #formula\n", + "Vx =(2*Va*q/m)**(0.5)\n", + "print \"horizontal beam velocity,Vx =(2*Va*q/m)**(0.5)= %0.2e\"%(Vx),\" metre/second\" #calculation\n", + "print \"radius,r =(m*Vx)/(B*q) metre\" #formula\n", + "r =(m*Vx)/(B*q)\n", + "print \"radius,r =(m*Vx)/(B*q)= %0.2f\"%(r),\" metre\" #calculation\n", + "print \"deflection,D =(L*l)/r) metre\" #formula\n", + "D =(L*l)/r\n", + "print \"deflection,D =(L*l)/r)=%0.2f\"%(D),\" metre\" #calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex -1.4 page : 43" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "q = 1.60e-19 coulomb\n", + "I = 10.00 Ampere\n", + "radius,r = 64.25 mils\n", + "r1 = 0.00 metre\n", + "n = 5.00e+28 electrons/m**3\n", + "cross sectional area,A =(pi*r1**2)= 8.37e-06 square metre\n", + "drift velocity,v=(I)/(A*q*n)=1.49e-04 metre/second\n" + ] + } + ], + "source": [ + "from math import pi\n", + "q=1.6*10**(-19)\n", + "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", + "I=10\n", + "print \"I = %0.2f\"%(I),\"Ampere\" #initializing value of current\n", + "r=64.25\n", + "print \"radius,r = %0.2f\"%(r),\" mils\" #initializing value of radius of wire\n", + "def mils2metres(mils):\n", + " metres=(mils*2.54)/(1000*100)\n", + " return metres\n", + "r1=mils2metres(r) \n", + "print \"r1 = %0.2f\"%(r1),\" metre\"\n", + "n=5*10**(28)\n", + "print \"n = %0.2e\"%(n),\" electrons/m**3\" # electrons concentration in copper\n", + "A=(pi*r1**2) #formulae \n", + "print \"cross sectional area,A =(pi*r1**2)= %0.2e\"%(A),\" square metre\" #calculation\n", + "v=(I)/(A*q*n)#formulae(I=A*q*n*v)\n", + "print \"drift velocity,v=(I)/(A*q*n)=%0.2e\"%(v),\" metre/second\" #calculation\n", + "\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1_5 page : 44" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cross sectional area,A =1.00e-05 merer square\n", + "resitivity(rho),p1 =1.00e-04 ohm-m\n", + "resitivity(rho),p2 =1000.00 ohm-m\n", + "resitivity(rho),p3 =1.00e+10 ohm-m\n", + "conductor length,l =0.01 metre\n", + " resistance for copper,R = p1*l/A = 0.10 ohm\n", + " resistance for silicon,R = p2*l/A = 1.00e+06 ohm\n", + " resistance for glass,R = p3*l/A = 1.00e+13 ohm\n" + ] + } + ], + "source": [ + "A=10*10**(-6)\n", + "p1=10**(-4)\n", + "p2=10**(3)\n", + "p3=10**(10)\n", + "l=1*10**(-2)# #initializations\n", + "print \"cross sectional area,A =%0.2e\"%(A),\"merer square\" \n", + "print \"resitivity(rho),p1 =%0.2e\"%(p1),\" ohm-m\"\n", + "print \"resitivity(rho),p2 =%0.2f\"%(p2),\" ohm-m\"\n", + "print \"resitivity(rho),p3 =%0.2e\"%(p3),\" ohm-m\"\n", + "print \"conductor length,l =%0.2f\"%(l),\" metre\"\n", + "print \" resistance for copper,R = p1*l/A = %0.2f\"%(p1*l/A),\"ohm\" #calculations for copper\n", + "print \" resistance for silicon,R = p2*l/A = %0.2e\"%(p2*l/A),\"ohm\" #calculations for silicon\n", + "print \" resistance for glass,R = p3*l/A = %0.2e\"%(p3*l/A),\"ohm\" #calculations for glass" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1_6 page : 45" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I = 1.00e-06 Ampere\n", + "intrinsic charge concentration,ni = 1.45e+10 /centimetre cube\n", + "silicon atoms concntration, nV = 5.00e+22 /centimetre cube \n", + "electron mobility,un = 1500.00 cm.sq/V-s\n", + "hole mobility,up = 475.00 cm.sq/V-s\n", + "temperature,T = 300.00 K\n", + "q = 1.59e-19 coulomb\n", + "cross sectional area,A =2.50e-05 cm square\n", + "conductor length,l =0.01 cm\n", + "relative concentration,N =nV/ni= 3.45e+12 silicon atoms per electron -hole pair\n", + "intrinsic conductivityi,sigma =(1.59*10**(-19)*(1.45*10**10)*(1500+0475))= 0.00 (ohm-cm)**-1\n", + "resitivity(rho),pi =(1/sigma)=2.20e+05 ohm-cm\n", + " resistance for silicon,R =((2.22*10**5*0.5)/0.000025) = 4.44e+09 ohm\n", + " voltage drop,V =I*R = 4440.00 V\n" + ] + } + ], + "source": [ + "ni = 1.45*10**10 #initializations\n", + "nV = 5*10**22 #initializations\n", + "un = 1500 #initializations\n", + "up = 475#initializations\n", + "T = 300 #initializations\n", + "I=10**(-6)\n", + "print \"I = %0.2e\"%(I),\"Ampere\" #initializing value of current\n", + "A=(50*10**(-4))**2# l=0.5 #initializations\n", + "q=1.59*10**(-19) #charge on an electron\n", + "print \"intrinsic charge concentration,ni = %0.2e\"%(ni),\" /centimetre cube\"\n", + "print \"silicon atoms concntration, nV = %0.2e\"%(nV),\" /centimetre cube \"\n", + "\n", + "print \"electron mobility,un = %0.2f\"%(un),\" cm.sq/V-s\"\n", + "print \"hole mobility,up = %0.2f\"%(up),\"cm.sq/V-s\"\n", + "print \"temperature,T = %0.2f\"%(T),\"K\"\n", + "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", + "print \"cross sectional area,A =%0.2e\"%(A),\"cm square\" \n", + "print \"conductor length,l =%0.2f\"%(l),\"cm\"\n", + "N=nV/ni\n", + "print \"relative concentration,N =nV/ni= %0.2e\"%(N),\" silicon atoms per electron -hole pair\" #calculation\n", + "sigma=(1.59*10**(-19)*(1.45*10**10)*(1500+475))\n", + "print \"intrinsic conductivityi,sigma =(1.59*10**(-19)*(1.45*10**10)*(1500+0475))= %0.2f\"%(sigma),\" (ohm-cm)**-1\" #calculation\n", + "pi =(1/sigma)#formulae\n", + "print \"resitivity(rho),pi =(1/sigma)=%0.2e\"%(pi),\" ohm-cm\" #calculation\n", + "R=(2.22*10**5*0.5)/0.000025\n", + "print \" resistance for silicon,R =((2.22*10**5*0.5)/0.000025) = %0.2e\"%(R),\" ohm\" #calculations for silicon\n", + "V=I*R\n", + "print \" voltage drop,V =I*R = %0.2f\"%(V),\" V\" #calculations " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1_7 page : 45" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "I = 1.00e-06 Ampere\n", + "intrinsic charge concentration,ni = 1.45e+10 /centimetre cube\n", + "silicon atoms concntration, nV = 5.00e+22 /centimetre cube \n", + "electron mobility,un = 1500.00 cm.sq/V-s\n", + "hole mobility,up = 317.00 cm.sq/V-s\n", + "temperature,T = 300.00 K\n", + "q = 0.00 coulomb\n", + "cross sectional area,A =0.00 cm square\n", + "conductor length,l =0.01 cm\n", + "donor concentration,nD= nV/10**6=50000000000000000.00 /cm.cube\n", + "resulting mobile electron concentration,nn= nD=5.00e+16 /cm.cube\n", + "resulting hole concentration,pn= ni**2/nD=4.20e+03 /cm.cube\n", + "n-type semiconductor conductivity,sigma=q*nD*un= 11.93 (ohm-cm)**-1\n", + "doped silicon resitivity(rho),pn =(1/sigma)=0.08 ohm-cm\n", + " resistance for silicon,R =((0.084*0.5)/A) = 1680.00 ohm\n", + " voltage drop,V =I*R = 1.68e-03 V\n" + ] + } + ], + "source": [ + "ni = 1.45*10**10 #initializations\n", + "nV = 5*10**22 #initializations\n", + "un = 1500 #initializations\n", + "up = 0475#initializations\n", + "T = 300 #initializations\n", + "I=10**(-6)\n", + "print \"I = %0.2e\"%(I),\"Ampere\" #initializing value of current\n", + "A=(50*10**(-4))**2# l=0.5 #initializations\n", + "q=1.59*10**(-19) #charge on an electron\n", + "print \"intrinsic charge concentration,ni = %0.2e\"%(ni),\" /centimetre cube\"\n", + "print \"silicon atoms concntration, nV = %0.2e\"%(nV),\" /centimetre cube \"\n", + "\n", + "print \"electron mobility,un = %0.2f\"%(un),\" cm.sq/V-s\"\n", + "print \"hole mobility,up = %0.2f\"%(up),\" cm.sq/V-s\"\n", + "print \"temperature,T = %0.2f\"%(T),\" K\"\n", + "print \"q = %0.2f\"%(q),\"coulomb\" #charge on an electron\n", + "print \"cross sectional area,A =%0.2f\"%(A),\" cm square\" \n", + "print \"conductor length,l =%0.2f\"%(l),\" cm\"\n", + "nD=nV/10**6#formulae\n", + "print \"donor concentration,nD= nV/10**6=%0.2f\"%(nD),\" /cm.cube\" #calculation\n", + "nn=nD#formulae\n", + "print \"resulting mobile electron concentration,nn= nD=%0.2e\"%(nn),\" /cm.cube\" #calculation\n", + "pn= ni**2/nD#formulae\n", + "print \"resulting hole concentration,pn= ni**2/nD=%0.2e\"%(pn),\" /cm.cube\" #calculation\n", + "sigma=q*nD*un#formulae\n", + "print \"n-type semiconductor conductivity,sigma=q*nD*un= %0.2f\"%(sigma),\" (ohm-cm)**-1\" #calculation\n", + "pn =(1/sigma)\n", + "print \"doped silicon resitivity(rho),pn =(1/sigma)=%0.2f\"%(pn),\" ohm-cm\" #calculation\n", + "R=(0.084*0.5)/A\n", + "print \" resistance for silicon,R =((0.084*0.5)/A) = %0.2f\"%(R),\" ohm\" #calculations for silicon\n", + "V=I*R\n", + "print \" voltage drop,V =I*R = %0.2e\"%(V),\" V\" #calculations " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Ex 1_8 page : 46" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "q = 1.59e-19 coulomb\n", + "dimension of semiconductor,d=0.04 cm\n", + "cross sectional area,A =d**2=1.37e-03 cm square\n", + "thickness,x =1.00e-04 cm\n", + "thickness,x0 =0 cm\n", + "hole concentration at x,p= 9.22e+15 /cm-cube\n", + "hole concentration at x0,p0= 0 /cm-cube\n", + " change in concentration at ,dp= 9.22e+15 /cm-cube\n", + "change in thickness,dx= 1.00e-04 cm\n", + " slope,(dp/dx) =(p-p0)/(x-x0)=9.22e+19 holes/cm-cube\n", + "hole diffusion constant,Dp= 12.00 cm-sq/s\n", + " hole diffusion current,Ip =A*q*Dp*(dp/dx)=0.24 ampere\n" + ] + } + ], + "source": [ + "q=1.59*10**(-19) #charge on an electron\n", + "print \"q = %0.2e\"%(q),\"coulomb\" #charge on an electron\n", + "d=0.037\n", + "print \"dimension of semiconductor,d=%0.2f\"%(d),\" cm\"\n", + "A=(d**2) #area formulae for square shaped semiconductor\n", + "print \"cross sectional area,A =d**2=%0.2e\"%(A),\" cm square\" \n", + "x=10**(-4)\n", + "print \"thickness,x =%0.2e\"%(x),\" cm\"\n", + "x0=0\n", + "print \"thickness,x0 =%0.f\"%(x0),\" cm\"\n", + "p=9.22*10**(15)#\n", + "print \"hole concentration at x,p= %0.2e\"%(p),\" /cm-cube\" #calculation\n", + "p0=0#\n", + "print \"hole concentration at x0,p0= %0.f\"%(p0),\" /cm-cube\" #calculation\n", + "dp=(p-p0)#formulae\n", + "dx=(x-x0)#formulae\n", + "print \" change in concentration at ,dp= %0.2e\"%(dp),\" /cm-cube\" #calculation\n", + "print \"change in thickness,dx= %0.2e\"%(dx),\" cm\" #calculation\n", + "(dp/dx)==(p-p0)/(x-x0)#formulae\n", + "print \" slope,(dp/dx) =(p-p0)/(x-x0)=%0.2e\"%(dp/dx),\" holes/cm-cube\" #calculation\n", + "Dp=12\n", + "print \"hole diffusion constant,Dp= %0.2f\"%(Dp),\" cm-sq/s\" #calculation\n", + "Ip=A*q*Dp*(dp/dx)\n", + "print \" hole diffusion current,Ip =A*q*Dp*(dp/dx)=%0.2f\"%(Ip),\" ampere\" #calculation" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/YogeshPatil/Chapter_11.ipynb b/sample_notebooks/YogeshPatil/Chapter_11.ipynb deleted file mode 100755 index f749209f..00000000 --- a/sample_notebooks/YogeshPatil/Chapter_11.ipynb +++ /dev/null @@ -1,494 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11: Voltage Regulators" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.1, Page No. 414" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# op-amp series voltage regulator design\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vin_min = 18-3 # min input voltage specification\n", - "Vin_max = 18+3 # max input voltage specification\n", - "Vout = 9 # output voltage specification\n", - "Iout_min = 10*10**-3 # min output current specification\n", - "Iout_max = 50*10**-3 # max output current specification\n", - "Vz = 5.6 # zener breakdown voltage\n", - "Pzmax = 0.5 # Maximum power dissipation in zener\n", - "\n", - "#Calculations\n", - "R1 = 10*10**3 # assumed\n", - "R2 = R1/((Vout/Vz)-1)\n", - "R3 = (Vin_min-Vz)/Iout_max\n", - "Iz = (Vin_max-Vz)/R3\n", - "Pd = Iz*Vz\n", - "beta = 30 # assumed\n", - "Ib = Iout_max/(beta+1)\n", - "\n", - "#Result\n", - "print(\"Element values for designed circuit are as follows:\\nR1 = %d k-ohm\\nR2 = %.2f k-ohm\"%(R1/1000,R2/1000))\n", - "print(\"R3 = %.3f k-ohm\\nIB = %.2f mA\"%(R3/1000,Ib*1000))\n", - "#Answer for R3 is wrong in the book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Element values for designed circuit are as follows:\n", - "R1 = 10 k-ohm\n", - "R2 = 16.47 k-ohm\n", - "R3 = 0.188 k-ohm\n", - "IB = 1.61 mA\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.2, Page No. 420" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulator using IC 723\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 5 # Required output voltage\n", - "Iout = 100*10**-3 # Required output current\n", - "Vin_min = 15-(0.2*15) # Min input voltage\n", - "Vin_max = 15+(0.2*15) # Max input voltage\n", - "Isc = 150*10**-3 # Short circuit current requirement\n", - "Vsense = 0.7 # short circuit voltage\n", - "Vref = 7.15 # reference votage for IC 723\n", - "Id = 1*10**-3 # potential divider current\n", - "\n", - "\n", - "#Calculation\n", - "Rsc = Vsense/Isc\n", - "R1 = (Vref-Vout)/Id\n", - "R1std = 2.2*10**3 \n", - "R2 = R1std/((Vref/Vout)-1)\n", - "R2std = 5.1*10**3 \n", - "R3 = R1std*R2std/(R1std+R2std)\n", - "R3std = 1.5*10**3 \n", - "\n", - "#Result\n", - "print(\"R1 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R1/1000,R1std/1000))\n", - "print(\"R2 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R2/1000,R2std/1000))\n", - "print(\"R3 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(math.floor((R3/1000)*1000)/1000,R3std/1000))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 2.150 k-ohm\t We use 2.2 k-ohm as standard resistor.\n", - "R2 = 5.116 k-ohm\t We use 5.1 k-ohm as standard resistor.\n", - "R3 = 1.536 k-ohm\t We use 1.5 k-ohm as standard resistor.\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.3, Page No. 421" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Ic 723 based positive voltage regulator\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 12.0 # output voltage\n", - "Il = 500*10**-3 # load current\n", - "Isc = 600*10**-3 # short circuit current\n", - "Vref = 7.0 # IC 723 reference voltage \n", - "Vsense = 0.6 # voltage at short circuit\n", - "\n", - "#Calculation\n", - "R1 = 4.7*10**3 # assumed\n", - "R2 = Vref*R1/(Vout-Vref)\n", - "R2std = 6.8*10**3 \n", - "Rsc = Vsense/Isc\n", - "R3 = R2std*R1/(R2std+R1)\n", - "Psc = Isc**2*Rsc*1000\n", - "I = Vout/(R1+R2std)\n", - "I= math.floor(I*10**6)/10**6\n", - "P1 = I**2*R1*1000\n", - "P2 = I**2*R2std*1000\n", - "\n", - "#Result\n", - "print(\"R1 = %.1f k-ohm\\nR2 = %.2f k-ohm = %.1f k-ohm(standard value)\\nRsc = %.1f ohm\"%(R1/1000,R2/1000,R2std/1000,Rsc))\n", - "print(\"\\nPower wattage:\\nPsc = %.0f mW\\nP1 = %.3f mW\\nP2 = %.3f mW\"%(Psc,math.floor(P1*1000)/1000,P2))\n", - "print(\"Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 4.7 k-ohm\n", - "R2 = 6.58 k-ohm = 6.8 k-ohm(standard value)\n", - "Rsc = 1.0 ohm\n", - "\n", - "Power wattage:\n", - "Psc = 360 mW\n", - "P1 = 5.112 mW\n", - "P2 = 7.397 mW\n", - "Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.4, Page No. 426" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulator design using IC 723(refer to fig. 11.26)\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 6 # output voltage\n", - "Il = 1 # load current\n", - "Isc = 0.250 # short circuit \n", - "Vref = 7 # reference voltage\n", - "Vbe = 0.7 # base-emitter junction voltage\n", - "\n", - "#Calculations\n", - "R1 = 2.7*10**3 # assumed\n", - "R2 = Vout*R1/(Vref-Vout)\n", - "kRsc = Vbe/Isc\n", - "k =1-(((Il-Isc)*kRsc)/Vout)\n", - "R4 = 10*10**3 # assumed \n", - "R3 = (1-k)*R4\n", - "Rsc = kRsc/k\n", - "R = (R1*R2)/(R1+R2)\n", - "\n", - "#Result\n", - "print(\"R1 = %.1f k-ohm\\nR2 = %.1f k-ohm\\nR3 = %.1f k-ohm\\nR4 = %.1f k-ohm\\nR = %.2f k-ohm\"%(R1/1000,R2/1000,R3/1000,R4/1000,R/1000))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 2.7 k-ohm\n", - "R2 = 16.2 k-ohm\n", - "R3 = 3.5 k-ohm\n", - "R4 = 10.0 k-ohm\n", - "R = 2.31 k-ohm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.5, Page No.432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Current source design using IC7812\n", - "\n", - "import math\n", - "#Variable declaration\n", - "RL = 25.0 # load resistance\n", - "P = 10.0 # power \n", - "I = 0.5 # current required\n", - "V = 12.0 # rated voltage\n", - "\n", - "#Calculations\n", - "R = V/I\n", - "Vout = V+(I*RL)\n", - "Vin = Vout+2\n", - "\n", - "#Result\n", - "print(\"R = %d ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R = 24 ohm\n", - "Vout = 24.5 V\n", - "Vin = 26.5 V\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.6, Page NO. 432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# min and max voltage of regulator(refer fig.11.34)\n", - "\n", - "import math\n", - "#variable declaration\n", - "Iq = 10*10**-3 # quiescent current\n", - "Vreg = 15.0 # regulated output voltage\n", - "R2 = 0 # min value of potentiometer\n", - "R1 = 40.0 # R1 resistor\n", - "\n", - "#Calculations\n", - "Vout = (1+(R2/R1))*Vreg+(Iq*R2)\n", - "\n", - "#Result\n", - "print(\"Vout = %d V\"%Vout)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Vout = 15 V\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.7, Page No. 432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# current source using 7805\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Il = 0.2 # required load current\n", - "RL = 22.0 # load resistance\n", - "P = 10.0 # required power\n", - "Iq = 4.2*10**-3 # quiescent current\n", - "Vr = 5 # regulated output voltage\n", - "\n", - "#Calculation\n", - "R = Vr/(Il-Iq)\n", - "Vout = Vr+Il*RL\n", - "Vin = Vout+2\n", - "\n", - "#Result\n", - "print(\"R = %f ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))\n", - "# Answer for R is wrong in the book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R = 25.536261 ohm\n", - "Vout = 9.4 V\n", - "Vin = 11.4 V\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.8, Page No.435" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulated outpuut voltage(refer fig. 11.38)\n", - "\n", - "import math\n", - "#Variable declaration\n", - "R1 = 220.0 # resistance R1\n", - "R2 = 1500.0 # Resistance R2\n", - "Iadj = 100*10**-6 # adj. current\n", - "\n", - "\n", - "#Calculartions\n", - "Vout = (1.25*(1+(R2/R1)))+(Iadj*R2)\n", - "\n", - "#Result\n", - "print(\"Vout = %.2f V\"%Vout)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Vout = 9.92 V\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.9, Page No. 435" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Output voltage range\n", - "\n", - "import math\n", - "#Variable declaration\n", - "R1 = 820.0 # resistance R1\n", - "R2min = 0 # min potentiometer resistance\n", - "R2max = 10*10**3 # max potentiometer resistance\n", - "Iadj = 100*10**-6 # adj. current\n", - "\n", - "#calculations\n", - "Vmin = 1.25*(1+(R2min/R1))+(Iadj*R2min)\n", - "Vmax = 1.25*(1+(R2max/R1))+(Iadj*R2max)\n", - "\n", - "#Result\n", - "print(\"The output can be varied in the range %.2f V to %.2f V\"%(Vmin,Vmax))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The output can be varied in the range 1.25 V to 17.49 V\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.10, Page No. 436" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Maximum load current\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vbe = 1.0 # base emitter junction voltage\n", - "beta = 15.0 # current gain\n", - "R1 = 7.0 # resistance R1\n", - "Iout = 1.0 # max output current from IC \n", - "#Calculations\n", - "Il = ((1+beta)*Iout) - beta*(Vbe/R1)\n", - "Il = math.floor(Il*100)/100\n", - "#Result\n", - "print(\"IC which can supply maximum 1A can supply maximum load of %.2f A, with the help of the current boosting arrangements\"%Il)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "IC which can supply maximum 1A can supply maximum load of 13.85 A, with the help of the current boosting arrangements\n" - ] - } - ], - "prompt_number": 12 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/YogeshPatil/Chapter_11_1.ipynb b/sample_notebooks/YogeshPatil/Chapter_11_1.ipynb deleted file mode 100755 index f749209f..00000000 --- a/sample_notebooks/YogeshPatil/Chapter_11_1.ipynb +++ /dev/null @@ -1,494 +0,0 @@ -{ - "metadata": { - "name": "" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 11: Voltage Regulators" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.1, Page No. 414" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# op-amp series voltage regulator design\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vin_min = 18-3 # min input voltage specification\n", - "Vin_max = 18+3 # max input voltage specification\n", - "Vout = 9 # output voltage specification\n", - "Iout_min = 10*10**-3 # min output current specification\n", - "Iout_max = 50*10**-3 # max output current specification\n", - "Vz = 5.6 # zener breakdown voltage\n", - "Pzmax = 0.5 # Maximum power dissipation in zener\n", - "\n", - "#Calculations\n", - "R1 = 10*10**3 # assumed\n", - "R2 = R1/((Vout/Vz)-1)\n", - "R3 = (Vin_min-Vz)/Iout_max\n", - "Iz = (Vin_max-Vz)/R3\n", - "Pd = Iz*Vz\n", - "beta = 30 # assumed\n", - "Ib = Iout_max/(beta+1)\n", - "\n", - "#Result\n", - "print(\"Element values for designed circuit are as follows:\\nR1 = %d k-ohm\\nR2 = %.2f k-ohm\"%(R1/1000,R2/1000))\n", - "print(\"R3 = %.3f k-ohm\\nIB = %.2f mA\"%(R3/1000,Ib*1000))\n", - "#Answer for R3 is wrong in the book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Element values for designed circuit are as follows:\n", - "R1 = 10 k-ohm\n", - "R2 = 16.47 k-ohm\n", - "R3 = 0.188 k-ohm\n", - "IB = 1.61 mA\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.2, Page No. 420" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulator using IC 723\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 5 # Required output voltage\n", - "Iout = 100*10**-3 # Required output current\n", - "Vin_min = 15-(0.2*15) # Min input voltage\n", - "Vin_max = 15+(0.2*15) # Max input voltage\n", - "Isc = 150*10**-3 # Short circuit current requirement\n", - "Vsense = 0.7 # short circuit voltage\n", - "Vref = 7.15 # reference votage for IC 723\n", - "Id = 1*10**-3 # potential divider current\n", - "\n", - "\n", - "#Calculation\n", - "Rsc = Vsense/Isc\n", - "R1 = (Vref-Vout)/Id\n", - "R1std = 2.2*10**3 \n", - "R2 = R1std/((Vref/Vout)-1)\n", - "R2std = 5.1*10**3 \n", - "R3 = R1std*R2std/(R1std+R2std)\n", - "R3std = 1.5*10**3 \n", - "\n", - "#Result\n", - "print(\"R1 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R1/1000,R1std/1000))\n", - "print(\"R2 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R2/1000,R2std/1000))\n", - "print(\"R3 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(math.floor((R3/1000)*1000)/1000,R3std/1000))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 2.150 k-ohm\t We use 2.2 k-ohm as standard resistor.\n", - "R2 = 5.116 k-ohm\t We use 5.1 k-ohm as standard resistor.\n", - "R3 = 1.536 k-ohm\t We use 1.5 k-ohm as standard resistor.\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.3, Page No. 421" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Ic 723 based positive voltage regulator\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 12.0 # output voltage\n", - "Il = 500*10**-3 # load current\n", - "Isc = 600*10**-3 # short circuit current\n", - "Vref = 7.0 # IC 723 reference voltage \n", - "Vsense = 0.6 # voltage at short circuit\n", - "\n", - "#Calculation\n", - "R1 = 4.7*10**3 # assumed\n", - "R2 = Vref*R1/(Vout-Vref)\n", - "R2std = 6.8*10**3 \n", - "Rsc = Vsense/Isc\n", - "R3 = R2std*R1/(R2std+R1)\n", - "Psc = Isc**2*Rsc*1000\n", - "I = Vout/(R1+R2std)\n", - "I= math.floor(I*10**6)/10**6\n", - "P1 = I**2*R1*1000\n", - "P2 = I**2*R2std*1000\n", - "\n", - "#Result\n", - "print(\"R1 = %.1f k-ohm\\nR2 = %.2f k-ohm = %.1f k-ohm(standard value)\\nRsc = %.1f ohm\"%(R1/1000,R2/1000,R2std/1000,Rsc))\n", - "print(\"\\nPower wattage:\\nPsc = %.0f mW\\nP1 = %.3f mW\\nP2 = %.3f mW\"%(Psc,math.floor(P1*1000)/1000,P2))\n", - "print(\"Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\")" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 4.7 k-ohm\n", - "R2 = 6.58 k-ohm = 6.8 k-ohm(standard value)\n", - "Rsc = 1.0 ohm\n", - "\n", - "Power wattage:\n", - "Psc = 360 mW\n", - "P1 = 5.112 mW\n", - "P2 = 7.397 mW\n", - "Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.4, Page No. 426" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulator design using IC 723(refer to fig. 11.26)\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vout = 6 # output voltage\n", - "Il = 1 # load current\n", - "Isc = 0.250 # short circuit \n", - "Vref = 7 # reference voltage\n", - "Vbe = 0.7 # base-emitter junction voltage\n", - "\n", - "#Calculations\n", - "R1 = 2.7*10**3 # assumed\n", - "R2 = Vout*R1/(Vref-Vout)\n", - "kRsc = Vbe/Isc\n", - "k =1-(((Il-Isc)*kRsc)/Vout)\n", - "R4 = 10*10**3 # assumed \n", - "R3 = (1-k)*R4\n", - "Rsc = kRsc/k\n", - "R = (R1*R2)/(R1+R2)\n", - "\n", - "#Result\n", - "print(\"R1 = %.1f k-ohm\\nR2 = %.1f k-ohm\\nR3 = %.1f k-ohm\\nR4 = %.1f k-ohm\\nR = %.2f k-ohm\"%(R1/1000,R2/1000,R3/1000,R4/1000,R/1000))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R1 = 2.7 k-ohm\n", - "R2 = 16.2 k-ohm\n", - "R3 = 3.5 k-ohm\n", - "R4 = 10.0 k-ohm\n", - "R = 2.31 k-ohm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.5, Page No.432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Current source design using IC7812\n", - "\n", - "import math\n", - "#Variable declaration\n", - "RL = 25.0 # load resistance\n", - "P = 10.0 # power \n", - "I = 0.5 # current required\n", - "V = 12.0 # rated voltage\n", - "\n", - "#Calculations\n", - "R = V/I\n", - "Vout = V+(I*RL)\n", - "Vin = Vout+2\n", - "\n", - "#Result\n", - "print(\"R = %d ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R = 24 ohm\n", - "Vout = 24.5 V\n", - "Vin = 26.5 V\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.6, Page NO. 432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# min and max voltage of regulator(refer fig.11.34)\n", - "\n", - "import math\n", - "#variable declaration\n", - "Iq = 10*10**-3 # quiescent current\n", - "Vreg = 15.0 # regulated output voltage\n", - "R2 = 0 # min value of potentiometer\n", - "R1 = 40.0 # R1 resistor\n", - "\n", - "#Calculations\n", - "Vout = (1+(R2/R1))*Vreg+(Iq*R2)\n", - "\n", - "#Result\n", - "print(\"Vout = %d V\"%Vout)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Vout = 15 V\n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.7, Page No. 432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# current source using 7805\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Il = 0.2 # required load current\n", - "RL = 22.0 # load resistance\n", - "P = 10.0 # required power\n", - "Iq = 4.2*10**-3 # quiescent current\n", - "Vr = 5 # regulated output voltage\n", - "\n", - "#Calculation\n", - "R = Vr/(Il-Iq)\n", - "Vout = Vr+Il*RL\n", - "Vin = Vout+2\n", - "\n", - "#Result\n", - "print(\"R = %f ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))\n", - "# Answer for R is wrong in the book" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "R = 25.536261 ohm\n", - "Vout = 9.4 V\n", - "Vin = 11.4 V\n" - ] - } - ], - "prompt_number": 23 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.8, Page No.435" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Regulated outpuut voltage(refer fig. 11.38)\n", - "\n", - "import math\n", - "#Variable declaration\n", - "R1 = 220.0 # resistance R1\n", - "R2 = 1500.0 # Resistance R2\n", - "Iadj = 100*10**-6 # adj. current\n", - "\n", - "\n", - "#Calculartions\n", - "Vout = (1.25*(1+(R2/R1)))+(Iadj*R2)\n", - "\n", - "#Result\n", - "print(\"Vout = %.2f V\"%Vout)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Vout = 9.92 V\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.9, Page No. 435" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Output voltage range\n", - "\n", - "import math\n", - "#Variable declaration\n", - "R1 = 820.0 # resistance R1\n", - "R2min = 0 # min potentiometer resistance\n", - "R2max = 10*10**3 # max potentiometer resistance\n", - "Iadj = 100*10**-6 # adj. current\n", - "\n", - "#calculations\n", - "Vmin = 1.25*(1+(R2min/R1))+(Iadj*R2min)\n", - "Vmax = 1.25*(1+(R2max/R1))+(Iadj*R2max)\n", - "\n", - "#Result\n", - "print(\"The output can be varied in the range %.2f V to %.2f V\"%(Vmin,Vmax))" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The output can be varied in the range 1.25 V to 17.49 V\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "example 11.10, Page No. 436" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "# Maximum load current\n", - "\n", - "import math\n", - "#Variable declaration\n", - "Vbe = 1.0 # base emitter junction voltage\n", - "beta = 15.0 # current gain\n", - "R1 = 7.0 # resistance R1\n", - "Iout = 1.0 # max output current from IC \n", - "#Calculations\n", - "Il = ((1+beta)*Iout) - beta*(Vbe/R1)\n", - "Il = math.floor(Il*100)/100\n", - "#Result\n", - "print(\"IC which can supply maximum 1A can supply maximum load of %.2f A, with the help of the current boosting arrangements\"%Il)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "IC which can supply maximum 1A can supply maximum load of 13.85 A, with the help of the current boosting arrangements\n" - ] - } - ], - "prompt_number": 12 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11.ipynb b/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11.ipynb new file mode 100755 index 00000000..f749209f --- /dev/null +++ b/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11.ipynb @@ -0,0 +1,494 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11: Voltage Regulators" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.1, Page No. 414" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# op-amp series voltage regulator design\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vin_min = 18-3 # min input voltage specification\n", + "Vin_max = 18+3 # max input voltage specification\n", + "Vout = 9 # output voltage specification\n", + "Iout_min = 10*10**-3 # min output current specification\n", + "Iout_max = 50*10**-3 # max output current specification\n", + "Vz = 5.6 # zener breakdown voltage\n", + "Pzmax = 0.5 # Maximum power dissipation in zener\n", + "\n", + "#Calculations\n", + "R1 = 10*10**3 # assumed\n", + "R2 = R1/((Vout/Vz)-1)\n", + "R3 = (Vin_min-Vz)/Iout_max\n", + "Iz = (Vin_max-Vz)/R3\n", + "Pd = Iz*Vz\n", + "beta = 30 # assumed\n", + "Ib = Iout_max/(beta+1)\n", + "\n", + "#Result\n", + "print(\"Element values for designed circuit are as follows:\\nR1 = %d k-ohm\\nR2 = %.2f k-ohm\"%(R1/1000,R2/1000))\n", + "print(\"R3 = %.3f k-ohm\\nIB = %.2f mA\"%(R3/1000,Ib*1000))\n", + "#Answer for R3 is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Element values for designed circuit are as follows:\n", + "R1 = 10 k-ohm\n", + "R2 = 16.47 k-ohm\n", + "R3 = 0.188 k-ohm\n", + "IB = 1.61 mA\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.2, Page No. 420" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulator using IC 723\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 5 # Required output voltage\n", + "Iout = 100*10**-3 # Required output current\n", + "Vin_min = 15-(0.2*15) # Min input voltage\n", + "Vin_max = 15+(0.2*15) # Max input voltage\n", + "Isc = 150*10**-3 # Short circuit current requirement\n", + "Vsense = 0.7 # short circuit voltage\n", + "Vref = 7.15 # reference votage for IC 723\n", + "Id = 1*10**-3 # potential divider current\n", + "\n", + "\n", + "#Calculation\n", + "Rsc = Vsense/Isc\n", + "R1 = (Vref-Vout)/Id\n", + "R1std = 2.2*10**3 \n", + "R2 = R1std/((Vref/Vout)-1)\n", + "R2std = 5.1*10**3 \n", + "R3 = R1std*R2std/(R1std+R2std)\n", + "R3std = 1.5*10**3 \n", + "\n", + "#Result\n", + "print(\"R1 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R1/1000,R1std/1000))\n", + "print(\"R2 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R2/1000,R2std/1000))\n", + "print(\"R3 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(math.floor((R3/1000)*1000)/1000,R3std/1000))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 2.150 k-ohm\t We use 2.2 k-ohm as standard resistor.\n", + "R2 = 5.116 k-ohm\t We use 5.1 k-ohm as standard resistor.\n", + "R3 = 1.536 k-ohm\t We use 1.5 k-ohm as standard resistor.\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.3, Page No. 421" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Ic 723 based positive voltage regulator\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 12.0 # output voltage\n", + "Il = 500*10**-3 # load current\n", + "Isc = 600*10**-3 # short circuit current\n", + "Vref = 7.0 # IC 723 reference voltage \n", + "Vsense = 0.6 # voltage at short circuit\n", + "\n", + "#Calculation\n", + "R1 = 4.7*10**3 # assumed\n", + "R2 = Vref*R1/(Vout-Vref)\n", + "R2std = 6.8*10**3 \n", + "Rsc = Vsense/Isc\n", + "R3 = R2std*R1/(R2std+R1)\n", + "Psc = Isc**2*Rsc*1000\n", + "I = Vout/(R1+R2std)\n", + "I= math.floor(I*10**6)/10**6\n", + "P1 = I**2*R1*1000\n", + "P2 = I**2*R2std*1000\n", + "\n", + "#Result\n", + "print(\"R1 = %.1f k-ohm\\nR2 = %.2f k-ohm = %.1f k-ohm(standard value)\\nRsc = %.1f ohm\"%(R1/1000,R2/1000,R2std/1000,Rsc))\n", + "print(\"\\nPower wattage:\\nPsc = %.0f mW\\nP1 = %.3f mW\\nP2 = %.3f mW\"%(Psc,math.floor(P1*1000)/1000,P2))\n", + "print(\"Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 4.7 k-ohm\n", + "R2 = 6.58 k-ohm = 6.8 k-ohm(standard value)\n", + "Rsc = 1.0 ohm\n", + "\n", + "Power wattage:\n", + "Psc = 360 mW\n", + "P1 = 5.112 mW\n", + "P2 = 7.397 mW\n", + "Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.4, Page No. 426" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulator design using IC 723(refer to fig. 11.26)\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 6 # output voltage\n", + "Il = 1 # load current\n", + "Isc = 0.250 # short circuit \n", + "Vref = 7 # reference voltage\n", + "Vbe = 0.7 # base-emitter junction voltage\n", + "\n", + "#Calculations\n", + "R1 = 2.7*10**3 # assumed\n", + "R2 = Vout*R1/(Vref-Vout)\n", + "kRsc = Vbe/Isc\n", + "k =1-(((Il-Isc)*kRsc)/Vout)\n", + "R4 = 10*10**3 # assumed \n", + "R3 = (1-k)*R4\n", + "Rsc = kRsc/k\n", + "R = (R1*R2)/(R1+R2)\n", + "\n", + "#Result\n", + "print(\"R1 = %.1f k-ohm\\nR2 = %.1f k-ohm\\nR3 = %.1f k-ohm\\nR4 = %.1f k-ohm\\nR = %.2f k-ohm\"%(R1/1000,R2/1000,R3/1000,R4/1000,R/1000))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 2.7 k-ohm\n", + "R2 = 16.2 k-ohm\n", + "R3 = 3.5 k-ohm\n", + "R4 = 10.0 k-ohm\n", + "R = 2.31 k-ohm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.5, Page No.432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Current source design using IC7812\n", + "\n", + "import math\n", + "#Variable declaration\n", + "RL = 25.0 # load resistance\n", + "P = 10.0 # power \n", + "I = 0.5 # current required\n", + "V = 12.0 # rated voltage\n", + "\n", + "#Calculations\n", + "R = V/I\n", + "Vout = V+(I*RL)\n", + "Vin = Vout+2\n", + "\n", + "#Result\n", + "print(\"R = %d ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R = 24 ohm\n", + "Vout = 24.5 V\n", + "Vin = 26.5 V\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.6, Page NO. 432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# min and max voltage of regulator(refer fig.11.34)\n", + "\n", + "import math\n", + "#variable declaration\n", + "Iq = 10*10**-3 # quiescent current\n", + "Vreg = 15.0 # regulated output voltage\n", + "R2 = 0 # min value of potentiometer\n", + "R1 = 40.0 # R1 resistor\n", + "\n", + "#Calculations\n", + "Vout = (1+(R2/R1))*Vreg+(Iq*R2)\n", + "\n", + "#Result\n", + "print(\"Vout = %d V\"%Vout)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vout = 15 V\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.7, Page No. 432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# current source using 7805\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Il = 0.2 # required load current\n", + "RL = 22.0 # load resistance\n", + "P = 10.0 # required power\n", + "Iq = 4.2*10**-3 # quiescent current\n", + "Vr = 5 # regulated output voltage\n", + "\n", + "#Calculation\n", + "R = Vr/(Il-Iq)\n", + "Vout = Vr+Il*RL\n", + "Vin = Vout+2\n", + "\n", + "#Result\n", + "print(\"R = %f ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))\n", + "# Answer for R is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R = 25.536261 ohm\n", + "Vout = 9.4 V\n", + "Vin = 11.4 V\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.8, Page No.435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulated outpuut voltage(refer fig. 11.38)\n", + "\n", + "import math\n", + "#Variable declaration\n", + "R1 = 220.0 # resistance R1\n", + "R2 = 1500.0 # Resistance R2\n", + "Iadj = 100*10**-6 # adj. current\n", + "\n", + "\n", + "#Calculartions\n", + "Vout = (1.25*(1+(R2/R1)))+(Iadj*R2)\n", + "\n", + "#Result\n", + "print(\"Vout = %.2f V\"%Vout)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vout = 9.92 V\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.9, Page No. 435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Output voltage range\n", + "\n", + "import math\n", + "#Variable declaration\n", + "R1 = 820.0 # resistance R1\n", + "R2min = 0 # min potentiometer resistance\n", + "R2max = 10*10**3 # max potentiometer resistance\n", + "Iadj = 100*10**-6 # adj. current\n", + "\n", + "#calculations\n", + "Vmin = 1.25*(1+(R2min/R1))+(Iadj*R2min)\n", + "Vmax = 1.25*(1+(R2max/R1))+(Iadj*R2max)\n", + "\n", + "#Result\n", + "print(\"The output can be varied in the range %.2f V to %.2f V\"%(Vmin,Vmax))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The output can be varied in the range 1.25 V to 17.49 V\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.10, Page No. 436" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Maximum load current\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vbe = 1.0 # base emitter junction voltage\n", + "beta = 15.0 # current gain\n", + "R1 = 7.0 # resistance R1\n", + "Iout = 1.0 # max output current from IC \n", + "#Calculations\n", + "Il = ((1+beta)*Iout) - beta*(Vbe/R1)\n", + "Il = math.floor(Il*100)/100\n", + "#Result\n", + "print(\"IC which can supply maximum 1A can supply maximum load of %.2f A, with the help of the current boosting arrangements\"%Il)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "IC which can supply maximum 1A can supply maximum load of 13.85 A, with the help of the current boosting arrangements\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11_1.ipynb b/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11_1.ipynb new file mode 100755 index 00000000..f749209f --- /dev/null +++ b/sample_notebooks/YogeshPatil/YogeshPatil_version_backup/Chapter_11_1.ipynb @@ -0,0 +1,494 @@ +{ + "metadata": { + "name": "" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 11: Voltage Regulators" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.1, Page No. 414" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# op-amp series voltage regulator design\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vin_min = 18-3 # min input voltage specification\n", + "Vin_max = 18+3 # max input voltage specification\n", + "Vout = 9 # output voltage specification\n", + "Iout_min = 10*10**-3 # min output current specification\n", + "Iout_max = 50*10**-3 # max output current specification\n", + "Vz = 5.6 # zener breakdown voltage\n", + "Pzmax = 0.5 # Maximum power dissipation in zener\n", + "\n", + "#Calculations\n", + "R1 = 10*10**3 # assumed\n", + "R2 = R1/((Vout/Vz)-1)\n", + "R3 = (Vin_min-Vz)/Iout_max\n", + "Iz = (Vin_max-Vz)/R3\n", + "Pd = Iz*Vz\n", + "beta = 30 # assumed\n", + "Ib = Iout_max/(beta+1)\n", + "\n", + "#Result\n", + "print(\"Element values for designed circuit are as follows:\\nR1 = %d k-ohm\\nR2 = %.2f k-ohm\"%(R1/1000,R2/1000))\n", + "print(\"R3 = %.3f k-ohm\\nIB = %.2f mA\"%(R3/1000,Ib*1000))\n", + "#Answer for R3 is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Element values for designed circuit are as follows:\n", + "R1 = 10 k-ohm\n", + "R2 = 16.47 k-ohm\n", + "R3 = 0.188 k-ohm\n", + "IB = 1.61 mA\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.2, Page No. 420" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulator using IC 723\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 5 # Required output voltage\n", + "Iout = 100*10**-3 # Required output current\n", + "Vin_min = 15-(0.2*15) # Min input voltage\n", + "Vin_max = 15+(0.2*15) # Max input voltage\n", + "Isc = 150*10**-3 # Short circuit current requirement\n", + "Vsense = 0.7 # short circuit voltage\n", + "Vref = 7.15 # reference votage for IC 723\n", + "Id = 1*10**-3 # potential divider current\n", + "\n", + "\n", + "#Calculation\n", + "Rsc = Vsense/Isc\n", + "R1 = (Vref-Vout)/Id\n", + "R1std = 2.2*10**3 \n", + "R2 = R1std/((Vref/Vout)-1)\n", + "R2std = 5.1*10**3 \n", + "R3 = R1std*R2std/(R1std+R2std)\n", + "R3std = 1.5*10**3 \n", + "\n", + "#Result\n", + "print(\"R1 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R1/1000,R1std/1000))\n", + "print(\"R2 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(R2/1000,R2std/1000))\n", + "print(\"R3 = %.3f k-ohm\\t We use %.1f k-ohm as standard resistor.\"%(math.floor((R3/1000)*1000)/1000,R3std/1000))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 2.150 k-ohm\t We use 2.2 k-ohm as standard resistor.\n", + "R2 = 5.116 k-ohm\t We use 5.1 k-ohm as standard resistor.\n", + "R3 = 1.536 k-ohm\t We use 1.5 k-ohm as standard resistor.\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.3, Page No. 421" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Ic 723 based positive voltage regulator\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 12.0 # output voltage\n", + "Il = 500*10**-3 # load current\n", + "Isc = 600*10**-3 # short circuit current\n", + "Vref = 7.0 # IC 723 reference voltage \n", + "Vsense = 0.6 # voltage at short circuit\n", + "\n", + "#Calculation\n", + "R1 = 4.7*10**3 # assumed\n", + "R2 = Vref*R1/(Vout-Vref)\n", + "R2std = 6.8*10**3 \n", + "Rsc = Vsense/Isc\n", + "R3 = R2std*R1/(R2std+R1)\n", + "Psc = Isc**2*Rsc*1000\n", + "I = Vout/(R1+R2std)\n", + "I= math.floor(I*10**6)/10**6\n", + "P1 = I**2*R1*1000\n", + "P2 = I**2*R2std*1000\n", + "\n", + "#Result\n", + "print(\"R1 = %.1f k-ohm\\nR2 = %.2f k-ohm = %.1f k-ohm(standard value)\\nRsc = %.1f ohm\"%(R1/1000,R2/1000,R2std/1000,Rsc))\n", + "print(\"\\nPower wattage:\\nPsc = %.0f mW\\nP1 = %.3f mW\\nP2 = %.3f mW\"%(Psc,math.floor(P1*1000)/1000,P2))\n", + "print(\"Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\")" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 4.7 k-ohm\n", + "R2 = 6.58 k-ohm = 6.8 k-ohm(standard value)\n", + "Rsc = 1.0 ohm\n", + "\n", + "Power wattage:\n", + "Psc = 360 mW\n", + "P1 = 5.112 mW\n", + "P2 = 7.397 mW\n", + "Hence, both R1 and R2 may be selected safely of 1/16th watt power rating.\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.4, Page No. 426" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulator design using IC 723(refer to fig. 11.26)\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vout = 6 # output voltage\n", + "Il = 1 # load current\n", + "Isc = 0.250 # short circuit \n", + "Vref = 7 # reference voltage\n", + "Vbe = 0.7 # base-emitter junction voltage\n", + "\n", + "#Calculations\n", + "R1 = 2.7*10**3 # assumed\n", + "R2 = Vout*R1/(Vref-Vout)\n", + "kRsc = Vbe/Isc\n", + "k =1-(((Il-Isc)*kRsc)/Vout)\n", + "R4 = 10*10**3 # assumed \n", + "R3 = (1-k)*R4\n", + "Rsc = kRsc/k\n", + "R = (R1*R2)/(R1+R2)\n", + "\n", + "#Result\n", + "print(\"R1 = %.1f k-ohm\\nR2 = %.1f k-ohm\\nR3 = %.1f k-ohm\\nR4 = %.1f k-ohm\\nR = %.2f k-ohm\"%(R1/1000,R2/1000,R3/1000,R4/1000,R/1000))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R1 = 2.7 k-ohm\n", + "R2 = 16.2 k-ohm\n", + "R3 = 3.5 k-ohm\n", + "R4 = 10.0 k-ohm\n", + "R = 2.31 k-ohm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.5, Page No.432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Current source design using IC7812\n", + "\n", + "import math\n", + "#Variable declaration\n", + "RL = 25.0 # load resistance\n", + "P = 10.0 # power \n", + "I = 0.5 # current required\n", + "V = 12.0 # rated voltage\n", + "\n", + "#Calculations\n", + "R = V/I\n", + "Vout = V+(I*RL)\n", + "Vin = Vout+2\n", + "\n", + "#Result\n", + "print(\"R = %d ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R = 24 ohm\n", + "Vout = 24.5 V\n", + "Vin = 26.5 V\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.6, Page NO. 432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# min and max voltage of regulator(refer fig.11.34)\n", + "\n", + "import math\n", + "#variable declaration\n", + "Iq = 10*10**-3 # quiescent current\n", + "Vreg = 15.0 # regulated output voltage\n", + "R2 = 0 # min value of potentiometer\n", + "R1 = 40.0 # R1 resistor\n", + "\n", + "#Calculations\n", + "Vout = (1+(R2/R1))*Vreg+(Iq*R2)\n", + "\n", + "#Result\n", + "print(\"Vout = %d V\"%Vout)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vout = 15 V\n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.7, Page No. 432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# current source using 7805\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Il = 0.2 # required load current\n", + "RL = 22.0 # load resistance\n", + "P = 10.0 # required power\n", + "Iq = 4.2*10**-3 # quiescent current\n", + "Vr = 5 # regulated output voltage\n", + "\n", + "#Calculation\n", + "R = Vr/(Il-Iq)\n", + "Vout = Vr+Il*RL\n", + "Vin = Vout+2\n", + "\n", + "#Result\n", + "print(\"R = %f ohm\\nVout = %.1f V\\nVin = %.1f V\"%(R,Vout,Vin))\n", + "# Answer for R is wrong in the book" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "R = 25.536261 ohm\n", + "Vout = 9.4 V\n", + "Vin = 11.4 V\n" + ] + } + ], + "prompt_number": 23 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.8, Page No.435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Regulated outpuut voltage(refer fig. 11.38)\n", + "\n", + "import math\n", + "#Variable declaration\n", + "R1 = 220.0 # resistance R1\n", + "R2 = 1500.0 # Resistance R2\n", + "Iadj = 100*10**-6 # adj. current\n", + "\n", + "\n", + "#Calculartions\n", + "Vout = (1.25*(1+(R2/R1)))+(Iadj*R2)\n", + "\n", + "#Result\n", + "print(\"Vout = %.2f V\"%Vout)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Vout = 9.92 V\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.9, Page No. 435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Output voltage range\n", + "\n", + "import math\n", + "#Variable declaration\n", + "R1 = 820.0 # resistance R1\n", + "R2min = 0 # min potentiometer resistance\n", + "R2max = 10*10**3 # max potentiometer resistance\n", + "Iadj = 100*10**-6 # adj. current\n", + "\n", + "#calculations\n", + "Vmin = 1.25*(1+(R2min/R1))+(Iadj*R2min)\n", + "Vmax = 1.25*(1+(R2max/R1))+(Iadj*R2max)\n", + "\n", + "#Result\n", + "print(\"The output can be varied in the range %.2f V to %.2f V\"%(Vmin,Vmax))" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The output can be varied in the range 1.25 V to 17.49 V\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "example 11.10, Page No. 436" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "# Maximum load current\n", + "\n", + "import math\n", + "#Variable declaration\n", + "Vbe = 1.0 # base emitter junction voltage\n", + "beta = 15.0 # current gain\n", + "R1 = 7.0 # resistance R1\n", + "Iout = 1.0 # max output current from IC \n", + "#Calculations\n", + "Il = ((1+beta)*Iout) - beta*(Vbe/R1)\n", + "Il = math.floor(Il*100)/100\n", + "#Result\n", + "print(\"IC which can supply maximum 1A can supply maximum load of %.2f A, with the help of the current boosting arrangements\"%Il)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "IC which can supply maximum 1A can supply maximum load of 13.85 A, with the help of the current boosting arrangements\n" + ] + } + ], + "prompt_number": 12 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/abhishekchauhan/Chapter10.ipynb b/sample_notebooks/abhishekchauhan/Chapter10.ipynb deleted file mode 100755 index 57ba73b4..00000000 --- a/sample_notebooks/abhishekchauhan/Chapter10.ipynb +++ /dev/null @@ -1,214 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:0eeff07c73d261b2e49c40ad723e136f854d13621a90d210aa99f3bc3ba2476a" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter10:MOSFET:TECHNOLOGY DRIVER" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "\n", - "Ex10.1:pg-432" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "K_dash = 25*10**-6\n", - "VT = 1.0\n", - "Z_by_L = 2.0 \n", - "VDD = 5.0\n", - "VOH = 5.0\n", - "RL = 100*10**3\n", - "k=K_dash*Z_by_L\n", - "print\"k = \",round(k,8)\n", - "VOL = VDD/(1+(k*RL*(VDD-VT)))\n", - "print\"The voltage in outout load is ,VOL = \",round(VOL,2),\"Volts\"\n", - "VIL = (1/(k*RL))+VT\n", - "print\"The low input value is ,VIL = \",round(VIL,3),\"Volts\"\n", - "#VIH_VT = VIH-VT \n", - "#Using the relation between Vout and Vin, we have \n", - "#(k/2)*((3/4)*(VIH_VT)**2)+((VIH_VT)/(2*RL))-(VDD/RL)\n", - "#solving using physically correct solution\n", - "VIH_VT = (-0.2+2.45)/1.5\n", - "VIH = VIH_VT + VT\n", - "print\"The high input value is ,VIH = \",round(VIH,3),\"Volts\"\n", - "#Equting the Current in the load and the transistor yields \n", - "#(k/2)*(VM-VT)**2 = ((VDD-VM)/RL)\n", - "#solving using physically correct solution\n", - "VM = 2.08 \n", - "NML = VIL-VOL\n", - "print\"The low noise margin of the device is ,NML = \",round(NML,2),\"V\"\n", - "NMH = VOH-VIH\n", - "print\"The high noise margin of the device is ,NMH = \",round(NMH,3),\"V\"\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "k = 5e-05\n", - "The voltage in outout load is ,VOL = 0.24 Volts\n", - "The low input value is ,VIL = 1.2 Volts\n", - "The high input value is ,VIH = 2.5 Volts\n", - "The low noise margin of the device is ,NML = 0.96 V\n", - "The high noise margin of the device is ,NMH = 2.5 V\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex10.2:pg-434" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "K_dash = 25*10**-6\n", - "VT = 1.0\n", - "VDD = 5.0\n", - "VOL= 0.24\n", - "RL = 10**5\n", - "VGS = 4.7\n", - "KL = (2*((VDD-VOL)/RL))/(VGS-VT)**2\n", - "print\"The parameter of load transistor is ,KL = \",round(KL,8),\"A/V**2\"\n", - "Z_by_L = KL/K_dash\n", - "print\"Z_by_L= \",round(Z_by_L,2)\n", - "#NOTE: let \n", - "L = 10*10**-6\n", - "Z = Z_by_L*L\n", - "print\"the width of transistor is Z = Z_by_L*L= \"\"{:.0e}\".format(Z),\"m\"\n", - "#NOTE: let \n", - "Z_by_L = 2.0\n", - "L1 = 3*10**-6\n", - "Z1 = Z_by_L*L1\n", - "print\"the width of transistor is Z1 = Z_by_L*L1= \",round(Z1,8),\"m\"\n", - "# Note : due to different precisions taken by me and the author ... my answer differ and author also takes the approximate values \n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The parameter of load transistor is ,KL = 6.95e-06 A/V**2\n", - "Z_by_L= 0.28\n", - "the width of transistor is Z = Z_by_L*L= 3e-06 m\n", - "the width of transistor is Z1 = Z_by_L*L1= 6e-06 m\n" - ] - } - ], - "prompt_number": 16 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex10.3:pg-435" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import numpy\n", - "VTO = 1.5\n", - "Two_Phi_F =0.7 \n", - "Gamma =0.4\n", - "VDD = 5.0\n", - "#VOH = VDD-(VTO+(Gamma*(sqrt(VOH+Two_Phi_F)-sqrt(Two_Phi_F))))\n", - "#By putting all the values in the equation, we get\n", - "print\"Voh=3.16+0.4*sqrt(Voh+1.4)\"\n", - "#squaring both sides and result in quad equation\n", - "print\"VOH**2-6.72VOH+9.42\"\n", - "a=1.0\n", - "b=-6.72;\n", - "c=9.42;\n", - "VOH = ((-b+math.sqrt(b**2-4*a*c))/2*a)-0.6 #0.6 is the error coefficient\n", - "\n", - "print\"The output high is VOH = \",round(VOH,1),\"Volts\"\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Voh=3.16+0.4*sqrt(Voh+1.4)\n", - "VOH**2-6.72VOH+9.42\n", - "The output high is VOH = 4.1 Volts\n" - ] - } - ], - "prompt_number": 37 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex10.4:pg-440" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "mu_n=700.0\n", - "VT = 1.5\n", - "VG=3.0\n", - "vs = 10**7\n", - "L = 10**-4\n", - "fT1 = (mu_n*(VG-VT))/(2*math.pi*(L**2))\n", - "print\"The cutoff frequency of the device in the constant mobility model is ,fT1= \"\"{:.2e}\".format(fT1)\n", - "fT2 = vs/(2*math.pi*L)\n", - "print\"The cutoff frequency of the device in the saturation velocity model is, fT2= \"\"{:.2e}\".format(fT2)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The cutoff frequency of the device in the constant mobility model is ,fT1= 1.67e+10\n", - "The cutoff frequency of the device in the saturation velocity model is, fT2= 1.59e+10\n" - ] - } - ], - "prompt_number": 22 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/abhishekchauhan/abhishekchauhan_version_backup/Chapter10.ipynb b/sample_notebooks/abhishekchauhan/abhishekchauhan_version_backup/Chapter10.ipynb new file mode 100755 index 00000000..57ba73b4 --- /dev/null +++ b/sample_notebooks/abhishekchauhan/abhishekchauhan_version_backup/Chapter10.ipynb @@ -0,0 +1,214 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:0eeff07c73d261b2e49c40ad723e136f854d13621a90d210aa99f3bc3ba2476a" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter10:MOSFET:TECHNOLOGY DRIVER" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "\n", + "Ex10.1:pg-432" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "K_dash = 25*10**-6\n", + "VT = 1.0\n", + "Z_by_L = 2.0 \n", + "VDD = 5.0\n", + "VOH = 5.0\n", + "RL = 100*10**3\n", + "k=K_dash*Z_by_L\n", + "print\"k = \",round(k,8)\n", + "VOL = VDD/(1+(k*RL*(VDD-VT)))\n", + "print\"The voltage in outout load is ,VOL = \",round(VOL,2),\"Volts\"\n", + "VIL = (1/(k*RL))+VT\n", + "print\"The low input value is ,VIL = \",round(VIL,3),\"Volts\"\n", + "#VIH_VT = VIH-VT \n", + "#Using the relation between Vout and Vin, we have \n", + "#(k/2)*((3/4)*(VIH_VT)**2)+((VIH_VT)/(2*RL))-(VDD/RL)\n", + "#solving using physically correct solution\n", + "VIH_VT = (-0.2+2.45)/1.5\n", + "VIH = VIH_VT + VT\n", + "print\"The high input value is ,VIH = \",round(VIH,3),\"Volts\"\n", + "#Equting the Current in the load and the transistor yields \n", + "#(k/2)*(VM-VT)**2 = ((VDD-VM)/RL)\n", + "#solving using physically correct solution\n", + "VM = 2.08 \n", + "NML = VIL-VOL\n", + "print\"The low noise margin of the device is ,NML = \",round(NML,2),\"V\"\n", + "NMH = VOH-VIH\n", + "print\"The high noise margin of the device is ,NMH = \",round(NMH,3),\"V\"\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "k = 5e-05\n", + "The voltage in outout load is ,VOL = 0.24 Volts\n", + "The low input value is ,VIL = 1.2 Volts\n", + "The high input value is ,VIH = 2.5 Volts\n", + "The low noise margin of the device is ,NML = 0.96 V\n", + "The high noise margin of the device is ,NMH = 2.5 V\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex10.2:pg-434" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "K_dash = 25*10**-6\n", + "VT = 1.0\n", + "VDD = 5.0\n", + "VOL= 0.24\n", + "RL = 10**5\n", + "VGS = 4.7\n", + "KL = (2*((VDD-VOL)/RL))/(VGS-VT)**2\n", + "print\"The parameter of load transistor is ,KL = \",round(KL,8),\"A/V**2\"\n", + "Z_by_L = KL/K_dash\n", + "print\"Z_by_L= \",round(Z_by_L,2)\n", + "#NOTE: let \n", + "L = 10*10**-6\n", + "Z = Z_by_L*L\n", + "print\"the width of transistor is Z = Z_by_L*L= \"\"{:.0e}\".format(Z),\"m\"\n", + "#NOTE: let \n", + "Z_by_L = 2.0\n", + "L1 = 3*10**-6\n", + "Z1 = Z_by_L*L1\n", + "print\"the width of transistor is Z1 = Z_by_L*L1= \",round(Z1,8),\"m\"\n", + "# Note : due to different precisions taken by me and the author ... my answer differ and author also takes the approximate values \n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The parameter of load transistor is ,KL = 6.95e-06 A/V**2\n", + "Z_by_L= 0.28\n", + "the width of transistor is Z = Z_by_L*L= 3e-06 m\n", + "the width of transistor is Z1 = Z_by_L*L1= 6e-06 m\n" + ] + } + ], + "prompt_number": 16 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex10.3:pg-435" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import numpy\n", + "VTO = 1.5\n", + "Two_Phi_F =0.7 \n", + "Gamma =0.4\n", + "VDD = 5.0\n", + "#VOH = VDD-(VTO+(Gamma*(sqrt(VOH+Two_Phi_F)-sqrt(Two_Phi_F))))\n", + "#By putting all the values in the equation, we get\n", + "print\"Voh=3.16+0.4*sqrt(Voh+1.4)\"\n", + "#squaring both sides and result in quad equation\n", + "print\"VOH**2-6.72VOH+9.42\"\n", + "a=1.0\n", + "b=-6.72;\n", + "c=9.42;\n", + "VOH = ((-b+math.sqrt(b**2-4*a*c))/2*a)-0.6 #0.6 is the error coefficient\n", + "\n", + "print\"The output high is VOH = \",round(VOH,1),\"Volts\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Voh=3.16+0.4*sqrt(Voh+1.4)\n", + "VOH**2-6.72VOH+9.42\n", + "The output high is VOH = 4.1 Volts\n" + ] + } + ], + "prompt_number": 37 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex10.4:pg-440" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "mu_n=700.0\n", + "VT = 1.5\n", + "VG=3.0\n", + "vs = 10**7\n", + "L = 10**-4\n", + "fT1 = (mu_n*(VG-VT))/(2*math.pi*(L**2))\n", + "print\"The cutoff frequency of the device in the constant mobility model is ,fT1= \"\"{:.2e}\".format(fT1)\n", + "fT2 = vs/(2*math.pi*L)\n", + "print\"The cutoff frequency of the device in the saturation velocity model is, fT2= \"\"{:.2e}\".format(fT2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The cutoff frequency of the device in the constant mobility model is ,fT1= 1.67e+10\n", + "The cutoff frequency of the device in the saturation velocity model is, fT2= 1.59e+10\n" + ] + } + ], + "prompt_number": 22 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ajinkyakhair/Untitled3.ipynb b/sample_notebooks/ajinkyakhair/Untitled3.ipynb deleted file mode 100755 index c9360e01..00000000 --- a/sample_notebooks/ajinkyakhair/Untitled3.ipynb +++ /dev/null @@ -1,105 +0,0 @@ -{ - "metadata": { - "celltoolbar": "Raw Cell Format", - "name": "", - "signature": "sha256:1b9250434a66c555344f74813ca967ce998b1c86d33424d56ca71d7c748c63ce" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1: Interference" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, Page number 1-19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#Given Data:\n", - "i=30 #angle of incidence\n", - "u=1.43 #Refractive index of a soap film\n", - "lamda=6*10**-7 #wavelength of light\n", - "n=1 #For minimum thickness\n", - "\n", - "#Calculations:\n", - "#u=sin i/sin r #Snell's law .So,\n", - "r=math.degrees(math.asin(math.sin(i)/u)) #angle of reflection\n", - "\n", - "#Now, condition of minima in transmitted system is\n", - "#2ut*cos(r)=(2n-1)lam/2\n", - "t=lamda/(2*2*u*math.cos(r)) #minimum thickness of film\n", - "print\"Minimum thickness of film is \",t,\"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Minimum thickness of film is 1.09096619878e-07 m\n" - ] - } - ], - "prompt_number": 17 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.8, Page number 1-19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given Data:\n", - "\n", - "lamda = 5893*10**-10 #Wavelength of light\n", - "theta = 1 #assuming value of theta\n", - "\n", - "#We know, B=lam/(2*u*theta). Here u=1\n", - "B = lamda/(2*theta) #fringe spacing\n", - "n=20 #interference fringes\n", - "\n", - "#Calculations:\n", - "#t=n*B*tan(theta)\n", - "t = 20*B*theta #Thickness of wire\n", - "print\"Thickness of wire is =\",t,\"m\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thickness of wire is = 5.893e-06 m\n" - ] - } - ], - "prompt_number": 18 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/Untitled3.ipynb b/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/Untitled3.ipynb new file mode 100755 index 00000000..c9360e01 --- /dev/null +++ b/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/Untitled3.ipynb @@ -0,0 +1,105 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:1b9250434a66c555344f74813ca967ce998b1c86d33424d56ca71d7c748c63ce" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1: Interference" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, Page number 1-19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math \n", + "#Given Data:\n", + "i=30 #angle of incidence\n", + "u=1.43 #Refractive index of a soap film\n", + "lamda=6*10**-7 #wavelength of light\n", + "n=1 #For minimum thickness\n", + "\n", + "#Calculations:\n", + "#u=sin i/sin r #Snell's law .So,\n", + "r=math.degrees(math.asin(math.sin(i)/u)) #angle of reflection\n", + "\n", + "#Now, condition of minima in transmitted system is\n", + "#2ut*cos(r)=(2n-1)lam/2\n", + "t=lamda/(2*2*u*math.cos(r)) #minimum thickness of film\n", + "print\"Minimum thickness of film is \",t,\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum thickness of film is 1.09096619878e-07 m\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.8, Page number 1-19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given Data:\n", + "\n", + "lamda = 5893*10**-10 #Wavelength of light\n", + "theta = 1 #assuming value of theta\n", + "\n", + "#We know, B=lam/(2*u*theta). Here u=1\n", + "B = lamda/(2*theta) #fringe spacing\n", + "n=20 #interference fringes\n", + "\n", + "#Calculations:\n", + "#t=n*B*tan(theta)\n", + "t = 20*B*theta #Thickness of wire\n", + "print\"Thickness of wire is =\",t,\"m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thickness of wire is = 5.893e-06 m\n" + ] + } + ], + "prompt_number": 18 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/chapter2.ipynb b/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/chapter2.ipynb new file mode 100755 index 00000000..8b221e49 --- /dev/null +++ b/sample_notebooks/ajinkyakhair/ajinkyakhair_version_backup/chapter2.ipynb @@ -0,0 +1,240 @@ +{ + "metadata": { + "celltoolbar": "Raw Cell Format", + "name": "", + "signature": "sha256:4fe36e3e0da1a77ee9793bbcdad9ed8d44455b05327e70b42ad389ca8fb3e239" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2: Semiconductor Physics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.21.1,Page number 2-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given Data:\n", + "\n", + "ro=1.72*10**-8 #resistivity of Cu\n", + "s=1/ro #conductivity of Cu\n", + "n=10.41*10**28 #no of electron per unit volume\n", + "e=1.6*10**-19 #charge on electron\n", + "\n", + "u=s/(n*e)\n", + "print\"mobility of electron in Cu =\",round(u,4),\"m**2/volt-sec\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "mobility of electron in Cu = 0.0035 m**2/volt-sec\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.21.2,Page number 2-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given Data:\n", + "\n", + "m=63.5 #atomic weight\n", + "u=43.3 #mobility of electron\n", + "e=1.6*10**-19 #charge on electron\n", + "N=6.02*10**23 #Avogadro's number\n", + "d=8.96 #density\n", + "\n", + "Ad=N*d/m #Atomic density\n", + "n=1*Ad\n", + "\n", + "ro=1/(n*e*u)\n", + "\n", + "print\"Resistivity of Cu =\",\"{0:.3e}\".format(ro),\"ohm-cm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resistivity of Cu = 1.699e-06 ohm-cm\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.21.3,Page number 2-47" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given Data:\n", + "\n", + "e=1.6*10**-19 #charge on electron\n", + "ne=2.5*10**19 #density of carriers\n", + "nh=ne #for intrinsic semiconductor\n", + "ue=0.39 #mobility of electron\n", + "uh=0.19 #mobility of hole\n", + "\n", + "s=ne*e*ue+nh*e*uh #conductivity of Ge\n", + "ro=1/s #resistivity of Ge\n", + "\n", + "print\"Resistivity of Ge =\",round(ro,4),\"ohm-m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Resistivity of Ge = 0.431 ohm-m\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.21.6,Page number 2-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given Data:\n", + "\n", + "c=5*10**28 #concentration of Si atoms\n", + "e=1.6*10**-19 #charge on electron\n", + "u=0.048 #mobility of hole\n", + "s=4.4*10**-4 #conductivity of Si\n", + "\n", + "#since millionth Si atom is replaced by an indium atom\n", + "\n", + "n=c*10**-6\n", + "sp=u*e*n #conductivity of resultant\n", + "\n", + "print\"conductivity =\",sp,\"mho/m\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "conductivity = 384.0 mho/m\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.21.7,Page number 2-49" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#Given Data:\n", + "\n", + "m=28.1 #atomic weight of Si\n", + "e=1.6*10**-19 #charge on electron\n", + "N=6.02*10**26 #Avogadro's number\n", + "d=2.4*10**3 #density of Si\n", + "p=0.25 #resistivity\n", + "\n", + "#no. of Si atom/m**3\n", + "Ad=N*d/m #Atomic density\n", + "\n", + "#impurity level is 0.01 ppm i.e. 1 atom in every 10**8 atoms of Si\n", + "n=Ad/10**8 #no of impurity atoms\n", + "\n", + "#since each impurity produce 1 hole\n", + "nh=n\n", + "print\"1) hole concentration =\",\"{0:.3e}\".format(n),\"holes/m**3\"\n", + "up=1/(e*p*nh)\n", + "print\"2) mobility =\",round(up,4),\"m**2/volt.sec\"\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "1) hole concentration = 5.142e+20 holes/m**3\n", + "2) mobility = 0.0486 m**2/volt.sec\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ajinkyakhair/chapter2.ipynb b/sample_notebooks/ajinkyakhair/chapter2.ipynb old mode 100755 new mode 100644 index 8b221e49..5bd122ad --- a/sample_notebooks/ajinkyakhair/chapter2.ipynb +++ b/sample_notebooks/ajinkyakhair/chapter2.ipynb @@ -1,8 +1,7 @@ { "metadata": { - "celltoolbar": "Raw Cell Format", "name": "", - "signature": "sha256:4fe36e3e0da1a77ee9793bbcdad9ed8d44455b05327e70b42ad389ca8fb3e239" + "signature": "sha256:74a00fabf3de3a229499fd336c46d9a546ea42ad7cb4fbe98a92a6ea72f21fa8" }, "nbformat": 3, "nbformat_minor": 0, @@ -14,7 +13,7 @@ "level": 1, "metadata": {}, "source": [ - "Chapter 2: Semiconductor Physics" + "Chapter 2: Bonding in Solids" ] }, { @@ -22,7 +21,7 @@ "level": 2, "metadata": {}, "source": [ - "Example 2.21.1,Page number 2-47" + "Example 2.1,Page number 62" ] }, { @@ -31,15 +30,14 @@ "input": [ "import math\n", "\n", - "#Given Data:\n", - "\n", - "ro=1.72*10**-8 #resistivity of Cu\n", - "s=1/ro #conductivity of Cu\n", - "n=10.41*10**28 #no of electron per unit volume\n", - "e=1.6*10**-19 #charge on electron\n", - "\n", - "u=s/(n*e)\n", - "print\"mobility of electron in Cu =\",round(u,4),\"m**2/volt-sec\"" + "#Given Data\n", + "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "r = 3.147*10**-10; # Nearest neighbour distance for KCl, m\n", + "n = 9.1; # Repulsive exponent of KCl\n", + "A = 1.748; # Madelung constant for lattice binding energy\n", + "E = A*e**2/(4*math.pi*epsilon_0*r)*(n-1)/n/e; # Binding energy of KCl, eV\n", + "print\"The binding energy of KCl = \",round(E,4),\"eV\";\n" ], "language": "python", "metadata": {}, @@ -48,18 +46,18 @@ "output_type": "stream", "stream": "stdout", "text": [ - "mobility of electron in Cu = 0.0035 m**2/volt-sec\n" + "The binding energy of KCl = 7.10982502818 eV\n" ] } ], - "prompt_number": 2 + "prompt_number": 5 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Example 2.21.2,Page number 2-47" + "Example 2.2,Page number 62" ] }, { @@ -68,20 +66,56 @@ "input": [ "import math\n", "\n", - "#Given Data:\n", - "\n", - "m=63.5 #atomic weight\n", - "u=43.3 #mobility of electron\n", - "e=1.6*10**-19 #charge on electron\n", - "N=6.02*10**23 #Avogadro's number\n", - "d=8.96 #density\n", + "#Given Data\n", "\n", - "Ad=N*d/m #Atomic density\n", - "n=1*Ad\n", + "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", + "N = 6.023*10**23; # Avogadro's number\n", + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "a0 = 5.63*10**-10; # Lattice parameter of NaCl, m\n", + "r0 = a0/2; # Nearest neighbour distance for NaCl, m\n", + "n = 8.4; # Repulsive exponent of NaCl\n", + "A = 1.748; # Madelung constant for lattice binding energy\n", + "E = A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n/e; # Binding energy of NaCl, eV\n", + "print\"The binding energy of NaCl = \",round(E*N*e/(4.186*1000),4),\"kcal/mol\" ;\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The binding energy of NaCl = 181.1005 kcal/mol\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3,Page number 62" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", "\n", - "ro=1/(n*e*u)\n", + "#Given Data\n", "\n", - "print\"Resistivity of Cu =\",\"{0:.3e}\".format(ro),\"ohm-cm\"" + "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", + "N = 6.023*10**23; # Avogadro's number\n", + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "E = 162.9*10**3; # Binding energy of KCl, cal/mol\n", + "n = 8.6; # Repulsive exponent of KCl\n", + "A = 1.747; # Madelung constant for lattice binding energy\n", + "# As lattice binding energy, E = A*e**2/(4*%pi*epsilon_0*r0)*(n-1)/n, solving for r0\n", + "r0 = A*N*e**2/(4*pi*epsilon_0*E*4.186)*(n-1)/n; # Nearest neighbour distance of KCl, m\n", + "print\"The nearest neighbour distance of KCl = \",round(r0*10**10,4),\"angstorm\";\n" ], "language": "python", "metadata": {}, @@ -90,18 +124,18 @@ "output_type": "stream", "stream": "stdout", "text": [ - "Resistivity of Cu = 1.699e-06 ohm-cm\n" + "The nearest neighbour distance of KCl = 3.1376 angstorm\n" ] } ], - "prompt_number": 4 + "prompt_number": 12 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Example 2.21.3,Page number 2-47" + "Example 2.4,Page number 63" ] }, { @@ -110,18 +144,18 @@ "input": [ "import math\n", "\n", - "#Given Data:\n", + "#Given Data\n", "\n", - "e=1.6*10**-19 #charge on electron\n", - "ne=2.5*10**19 #density of carriers\n", - "nh=ne #for intrinsic semiconductor\n", - "ue=0.39 #mobility of electron\n", - "uh=0.19 #mobility of hole\n", + "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", + "N = 6.023*10**23; # Avogadro's number\n", + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "E = 152*10**3; # Binding energy of CsCl, cal/mol\n", + "n = 10.6; # Repulsive exponent of CsCl\n", + "A = 1.763; # Madelung constant for lattice binding energy\n", "\n", - "s=ne*e*ue+nh*e*uh #conductivity of Ge\n", - "ro=1/s #resistivity of Ge\n", - "\n", - "print\"Resistivity of Ge =\",round(ro,4),\"ohm-m\"" + "# As lattice binding energy, E = A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n, solving for r0\n", + "r0 = A*N*e**2/(4*pi*epsilon_0*E*4.186)*(n-1)/n; # Nearest neighbour distance of CsCl, m\n", + "print\"The nearest neighbour distance of CsCl = \",round(r0*10**10,4),\"angstrom\";\n" ], "language": "python", "metadata": {}, @@ -130,18 +164,18 @@ "output_type": "stream", "stream": "stdout", "text": [ - "Resistivity of Ge = 0.431 ohm-m\n" + "The nearest neighbour distance of CsCl = 3.4776 angstrom\n" ] } ], - "prompt_number": 6 + "prompt_number": 13 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Example 2.21.6,Page number 2-49" + "Example 2.5,Page number 63" ] }, { @@ -150,19 +184,57 @@ "input": [ "import math\n", "\n", - "#Given Data:\n", + "#Given Data\n", "\n", - "c=5*10**28 #concentration of Si atoms\n", - "e=1.6*10**-19 #charge on electron\n", - "u=0.048 #mobility of hole\n", - "s=4.4*10**-4 #conductivity of Si\n", + "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", + "N = 6.023*10**23; # Avogadro's number\n", + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "r0 = 6.46*10**-10; # Nearest neighbour distance of NaI\n", + "E = 157.1*10**3; # Binding energy of NaI, cal/mol\n", + "A = 1.747; # Madelung constant for lattice binding energy\n", "\n", - "#since millionth Si atom is replaced by an indium atom\n", + "# As lattice binding energy, E = -A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n, solving for n\n", + "n = 1/(1+(4.186*E*4*pi*epsilon_0*r0)/(N*A*e**2)); # Repulsive exponent of NaI\n", + "print\"\\nThe repulsive exponent of NaI = \",round(n,4);" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "The repulsive exponent of NaI = 0.363\n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6,Page number 63" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", "\n", - "n=c*10**-6\n", - "sp=u*e*n #conductivity of resultant\n", + "#Given Data\n", "\n", - "print\"conductivity =\",sp,\"mho/m\"" + "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", + "a0 = 2.8158*10**-10; # Nearest neighbour distance of solid\n", + "A = 1.747; # Madelung constant for lattice binding energy\n", + "n = 8.6; # The repulsive exponent of solid\n", + "c = 2; # Structural factor for rocksalt\n", + "# As n = 1 + (9*c*a0**4)/(K0*e**2*A), solving for K0\n", + "K0 = 9*c*a0**4/((n-1)*e**2*A); # Compressibility of solid, metre square per newton\n", + "print\"The compressibility of the solid = \", \"{0:.3e}\".format(K0),\"metre square per newton\";" ], "language": "python", "metadata": {}, @@ -171,18 +243,18 @@ "output_type": "stream", "stream": "stdout", "text": [ - "conductivity = 384.0 mho/m\n" + "The compressibility of the solid = 3.329e-01 metre square per newton\n" ] } ], - "prompt_number": 10 + "prompt_number": 18 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Example 2.21.7,Page number 2-49" + "Example 2.7,Page number 69" ] }, { @@ -191,25 +263,50 @@ "input": [ "import math\n", "\n", - "#Given Data:\n", + "#Given Data\n", "\n", - "m=28.1 #atomic weight of Si\n", - "e=1.6*10**-19 #charge on electron\n", - "N=6.02*10**26 #Avogadro's number\n", - "d=2.4*10**3 #density of Si\n", - "p=0.25 #resistivity\n", + "chi_diff = 1; # Electronegativity difference between the constituent of elements of solid\n", + "percent_ion = 100*(1-math.e**(-(0.25*chi_diff**2))); # Percentage ionic character present in solid given by Pauling\n", + "print\"The percentage ionic character present in solid = \",round(percent_ion,2),\"percent \";\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The percentage ionic character present in solid = 22.12 percent \n" + ] + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8,Page number 69" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", "\n", - "#no. of Si atom/m**3\n", - "Ad=N*d/m #Atomic density\n", + "#Given Data\n", "\n", - "#impurity level is 0.01 ppm i.e. 1 atom in every 10**8 atoms of Si\n", - "n=Ad/10**8 #no of impurity atoms\n", + "Eh_GaAs = 4.3; # Homopolar gap of GaAs compound, eV\n", + "C_GaAs = 2.90; # Ionic gap of GaAs compound, eV\n", + "Eh_CdTe = 3.08; # Homopolar gap of CdTe compound, eV\n", + "C_CdTe = 4.90; # Ionic gap of CdTe compound, eV\n", "\n", - "#since each impurity produce 1 hole\n", - "nh=n\n", - "print\"1) hole concentration =\",\"{0:.3e}\".format(n),\"holes/m**3\"\n", - "up=1/(e*p*nh)\n", - "print\"2) mobility =\",round(up,4),\"m**2/volt.sec\"\n" + "fi_GaAs = C_GaAs**2/(Eh_GaAs**2 + C_GaAs**2);\n", + "fi_CdTe = C_CdTe**2/(Eh_CdTe**2 + C_CdTe**2);\n", + "print\"The fractional ionicity of GaAs = \",round(fi_GaAs,4);\n", + "print\"The fractional ionicity of CdTe = \",round(fi_CdTe,4);\n" ], "language": "python", "metadata": {}, @@ -218,12 +315,12 @@ "output_type": "stream", "stream": "stdout", "text": [ - "1) hole concentration = 5.142e+20 holes/m**3\n", - "2) mobility = 0.0486 m**2/volt.sec\n" + "The fractional ionicity of GaAs = 0.3126\n", + "The fractional ionicity of CdTe = 0.7168\n" ] } ], - "prompt_number": 12 + "prompt_number": 3 }, { "cell_type": "code", diff --git a/sample_notebooks/ajinkyakhair/chapter2_8f8MyfH.ipynb b/sample_notebooks/ajinkyakhair/chapter2_8f8MyfH.ipynb deleted file mode 100644 index 5bd122ad..00000000 --- a/sample_notebooks/ajinkyakhair/chapter2_8f8MyfH.ipynb +++ /dev/null @@ -1,337 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:74a00fabf3de3a229499fd336c46d9a546ea42ad7cb4fbe98a92a6ea72f21fa8" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2: Bonding in Solids" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.1,Page number 62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "r = 3.147*10**-10; # Nearest neighbour distance for KCl, m\n", - "n = 9.1; # Repulsive exponent of KCl\n", - "A = 1.748; # Madelung constant for lattice binding energy\n", - "E = A*e**2/(4*math.pi*epsilon_0*r)*(n-1)/n/e; # Binding energy of KCl, eV\n", - "print\"The binding energy of KCl = \",round(E,4),\"eV\";\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The binding energy of KCl = 7.10982502818 eV\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2,Page number 62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", - "N = 6.023*10**23; # Avogadro's number\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "a0 = 5.63*10**-10; # Lattice parameter of NaCl, m\n", - "r0 = a0/2; # Nearest neighbour distance for NaCl, m\n", - "n = 8.4; # Repulsive exponent of NaCl\n", - "A = 1.748; # Madelung constant for lattice binding energy\n", - "E = A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n/e; # Binding energy of NaCl, eV\n", - "print\"The binding energy of NaCl = \",round(E*N*e/(4.186*1000),4),\"kcal/mol\" ;\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The binding energy of NaCl = 181.1005 kcal/mol\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3,Page number 62" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", - "N = 6.023*10**23; # Avogadro's number\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "E = 162.9*10**3; # Binding energy of KCl, cal/mol\n", - "n = 8.6; # Repulsive exponent of KCl\n", - "A = 1.747; # Madelung constant for lattice binding energy\n", - "# As lattice binding energy, E = A*e**2/(4*%pi*epsilon_0*r0)*(n-1)/n, solving for r0\n", - "r0 = A*N*e**2/(4*pi*epsilon_0*E*4.186)*(n-1)/n; # Nearest neighbour distance of KCl, m\n", - "print\"The nearest neighbour distance of KCl = \",round(r0*10**10,4),\"angstorm\";\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The nearest neighbour distance of KCl = 3.1376 angstorm\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4,Page number 63" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", - "N = 6.023*10**23; # Avogadro's number\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "E = 152*10**3; # Binding energy of CsCl, cal/mol\n", - "n = 10.6; # Repulsive exponent of CsCl\n", - "A = 1.763; # Madelung constant for lattice binding energy\n", - "\n", - "# As lattice binding energy, E = A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n, solving for r0\n", - "r0 = A*N*e**2/(4*pi*epsilon_0*E*4.186)*(n-1)/n; # Nearest neighbour distance of CsCl, m\n", - "print\"The nearest neighbour distance of CsCl = \",round(r0*10**10,4),\"angstrom\";\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The nearest neighbour distance of CsCl = 3.4776 angstrom\n" - ] - } - ], - "prompt_number": 13 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5,Page number 63" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "epsilon_0 = 8.854*10**-12; # Absolute electrical permittivity of free space, F/m\n", - "N = 6.023*10**23; # Avogadro's number\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "r0 = 6.46*10**-10; # Nearest neighbour distance of NaI\n", - "E = 157.1*10**3; # Binding energy of NaI, cal/mol\n", - "A = 1.747; # Madelung constant for lattice binding energy\n", - "\n", - "# As lattice binding energy, E = -A*e**2/(4*pi*epsilon_0*r0)*(n-1)/n, solving for n\n", - "n = 1/(1+(4.186*E*4*pi*epsilon_0*r0)/(N*A*e**2)); # Repulsive exponent of NaI\n", - "print\"\\nThe repulsive exponent of NaI = \",round(n,4);" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "The repulsive exponent of NaI = 0.363\n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6,Page number 63" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "e = 1.6*10**-19; # Energy equivalent of 1 eV, eV/J\n", - "a0 = 2.8158*10**-10; # Nearest neighbour distance of solid\n", - "A = 1.747; # Madelung constant for lattice binding energy\n", - "n = 8.6; # The repulsive exponent of solid\n", - "c = 2; # Structural factor for rocksalt\n", - "# As n = 1 + (9*c*a0**4)/(K0*e**2*A), solving for K0\n", - "K0 = 9*c*a0**4/((n-1)*e**2*A); # Compressibility of solid, metre square per newton\n", - "print\"The compressibility of the solid = \", \"{0:.3e}\".format(K0),\"metre square per newton\";" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The compressibility of the solid = 3.329e-01 metre square per newton\n" - ] - } - ], - "prompt_number": 18 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7,Page number 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "chi_diff = 1; # Electronegativity difference between the constituent of elements of solid\n", - "percent_ion = 100*(1-math.e**(-(0.25*chi_diff**2))); # Percentage ionic character present in solid given by Pauling\n", - "print\"The percentage ionic character present in solid = \",round(percent_ion,2),\"percent \";\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The percentage ionic character present in solid = 22.12 percent \n" - ] - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8,Page number 69" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#Given Data\n", - "\n", - "Eh_GaAs = 4.3; # Homopolar gap of GaAs compound, eV\n", - "C_GaAs = 2.90; # Ionic gap of GaAs compound, eV\n", - "Eh_CdTe = 3.08; # Homopolar gap of CdTe compound, eV\n", - "C_CdTe = 4.90; # Ionic gap of CdTe compound, eV\n", - "\n", - "fi_GaAs = C_GaAs**2/(Eh_GaAs**2 + C_GaAs**2);\n", - "fi_CdTe = C_CdTe**2/(Eh_CdTe**2 + C_CdTe**2);\n", - "print\"The fractional ionicity of GaAs = \",round(fi_GaAs,4);\n", - "print\"The fractional ionicity of CdTe = \",round(fi_CdTe,4);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The fractional ionicity of GaAs = 0.3126\n", - "The fractional ionicity of CdTe = 0.7168\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/anubhav gupta/anubhav gupta_version_backup/chapter15.ipynb b/sample_notebooks/anubhav gupta/anubhav gupta_version_backup/chapter15.ipynb new file mode 100755 index 00000000..6b74bd3d --- /dev/null +++ b/sample_notebooks/anubhav gupta/anubhav gupta_version_backup/chapter15.ipynb @@ -0,0 +1,318 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:e4b81aad84d58dd6a5380406939aae9ead38ccfe59091c46f280bef86ba6a2d7" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter15:POWER SYSTEMS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.1:pg-207" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "V1=250\n", + "V2=480\n", + "Vol2_by_Vol1=V1/V2\n", + "\n", + "sav=(1-Vol2_by_Vol1)*100\n", + "print(sav)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "100\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.2:pg-207" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "P=5E6\n", + "pf=0.85\n", + "V=33000\n", + "l=50000\n", + "rho=3E-8\n", + "Pt=P*pf\n", + "Pl=Pt*0.1\n", + "I=P/V\n", + "A1=2*I*I*rho*l/Pl\n", + "Vol1=2*l*A1\n", + "print(Vol1)\n", + "Il=P/sqrt(3)/V\n", + "A2=3*Il*Il*rho*l/Pl\n", + "Vol2=3*l*A2\n", + "print(Vol2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.3:pg-208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "f=50\n", + "w=2*math.pi*f\n", + "I=0.8\n", + "V=220\n", + "P=75\n", + "phi=math.acos(P/V/I)\n", + "\n", + "phi_new=math.acos(0.9)\n", + "Ic=I*cos(phi)*(tan(phi)-tan(phi_new))\n", + "C=Ic/V/w\n", + "print\"C=\",round(C,8)\n", + "\n", + "phi_new=math.acos(1)\n", + "Ic=I*cos(phi)*(tan(phi)-tan(phi_new))\n", + "C=Ic/V/w\n", + "print\"C=\",round(C,8)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "C= 1.157e-05\n", + "C= 1.157e-05\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.4:pg-208" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "Cond_cost=100\n", + "charge=60\n", + "phi2=math.asin(0.1*Cond_cost/charge)\n", + "pf=cos(phi2)\n", + "print(pf)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "0.986013297183\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.5:pg-209" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "\n", + "Oc=400000\n", + "pf1=0.8\n", + "phi1=math.acos(pf1)\n", + "ab=Oc/cos(phi1)*sin(phi1)\n", + "pf2=0.25\n", + "phi3=math.acos(pf2)\n", + "pf2=0.484\n", + "\n", + "gammaa=(ab-pf2*Oc)/(pf2*cos(phi3)+sin(phi3))\n", + "print(gammaa)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "97682.2645812\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.6:pg-209" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "f=50\n", + "w=2*math.pi*f\n", + "P=2E6\n", + "V=11000\n", + "pf=0.8\n", + "phi=math.acos(pf)\n", + "Xl=10\n", + "IR=P/sqrt(3)/V/pf\n", + "Vr=V/sqrt(3)\n", + "Vs=Vr+IR*Xl*sin(phi)\n", + "Vsll=Vs*sqrt(3)\n", + "print(Vsll)\n", + "VR=Vsll/V-1\n", + "print(VR)\n", + "\n", + "pf=1\n", + "print(pf)\n", + "Qc=P*tan(phi)\n", + "C=Qc/V/V/w\n", + "print(C)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "12363.6363636\n", + "0.123966942149\n", + "1\n", + "3.94599032459e-05\n" + ] + } + ], + "prompt_number": 10 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex15.7:pg-210" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "f=50\n", + "w=2*math.pi*f\n", + "V=33000\n", + "Vr=V/sqrt(3)\n", + "P=24E6/3\n", + "pf=0.8\n", + "phi=math.acos(pf)\n", + "Ia=P/Vr/pf\n", + "Rl=4.0\n", + "Xl=20\n", + "Vs=Vr+Ia*(Xl*sin(phi)+Rl*cos(phi))\n", + "Vsll=sqrt(3)*Vs\n", + "VR=Vsll/V-1\n", + "print(Vsll)\n", + "Ia=Ia*exp(-1j*phi)\n", + "print(norm(Ia))\n", + "\n", + "phi1=math.atan(-Rl/Xl)\n", + "pf=cos(phi1)\n", + "Ia1=P/Vr/pf\n", + "Ia1=Ia1*exp(-1j*phi1) #calculation mistake in the book at this step\n", + "\n", + "Ic=Ia1-Ia\n", + "C=norm(Ic/w/Vr)\n", + "print(C)\n", + "\n", + "LL1=norm(Ia*Ia*Rl)\n", + "effi1=P/(P+LL1)\n", + "LL2=norm(Ia1*Ia1*Rl)\n", + "effi2=P/(P+LL2)\n", + "print(effi1)\n", + "print(effi2)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "46818.1818182\n", + "524.863881081" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + "6.66433921487e-05\n", + "0.878934624697\n", + "0.916018976481\n" + ] + } + ], + "prompt_number": 11 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/anubhav gupta/chapter15.ipynb b/sample_notebooks/anubhav gupta/chapter15.ipynb deleted file mode 100755 index 6b74bd3d..00000000 --- a/sample_notebooks/anubhav gupta/chapter15.ipynb +++ /dev/null @@ -1,318 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:e4b81aad84d58dd6a5380406939aae9ead38ccfe59091c46f280bef86ba6a2d7" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter15:POWER SYSTEMS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.1:pg-207" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "V1=250\n", - "V2=480\n", - "Vol2_by_Vol1=V1/V2\n", - "\n", - "sav=(1-Vol2_by_Vol1)*100\n", - "print(sav)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "100\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.2:pg-207" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "P=5E6\n", - "pf=0.85\n", - "V=33000\n", - "l=50000\n", - "rho=3E-8\n", - "Pt=P*pf\n", - "Pl=Pt*0.1\n", - "I=P/V\n", - "A1=2*I*I*rho*l/Pl\n", - "Vol1=2*l*A1\n", - "print(Vol1)\n", - "Il=P/sqrt(3)/V\n", - "A2=3*Il*Il*rho*l/Pl\n", - "Vol2=3*l*A2\n", - "print(Vol2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.3:pg-208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "f=50\n", - "w=2*math.pi*f\n", - "I=0.8\n", - "V=220\n", - "P=75\n", - "phi=math.acos(P/V/I)\n", - "\n", - "phi_new=math.acos(0.9)\n", - "Ic=I*cos(phi)*(tan(phi)-tan(phi_new))\n", - "C=Ic/V/w\n", - "print\"C=\",round(C,8)\n", - "\n", - "phi_new=math.acos(1)\n", - "Ic=I*cos(phi)*(tan(phi)-tan(phi_new))\n", - "C=Ic/V/w\n", - "print\"C=\",round(C,8)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "C= 1.157e-05\n", - "C= 1.157e-05\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.4:pg-208" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "Cond_cost=100\n", - "charge=60\n", - "phi2=math.asin(0.1*Cond_cost/charge)\n", - "pf=cos(phi2)\n", - "print(pf)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "0.986013297183\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.5:pg-209" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "\n", - "Oc=400000\n", - "pf1=0.8\n", - "phi1=math.acos(pf1)\n", - "ab=Oc/cos(phi1)*sin(phi1)\n", - "pf2=0.25\n", - "phi3=math.acos(pf2)\n", - "pf2=0.484\n", - "\n", - "gammaa=(ab-pf2*Oc)/(pf2*cos(phi3)+sin(phi3))\n", - "print(gammaa)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "97682.2645812\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.6:pg-209" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "f=50\n", - "w=2*math.pi*f\n", - "P=2E6\n", - "V=11000\n", - "pf=0.8\n", - "phi=math.acos(pf)\n", - "Xl=10\n", - "IR=P/sqrt(3)/V/pf\n", - "Vr=V/sqrt(3)\n", - "Vs=Vr+IR*Xl*sin(phi)\n", - "Vsll=Vs*sqrt(3)\n", - "print(Vsll)\n", - "VR=Vsll/V-1\n", - "print(VR)\n", - "\n", - "pf=1\n", - "print(pf)\n", - "Qc=P*tan(phi)\n", - "C=Qc/V/V/w\n", - "print(C)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "12363.6363636\n", - "0.123966942149\n", - "1\n", - "3.94599032459e-05\n" - ] - } - ], - "prompt_number": 10 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex15.7:pg-210" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "f=50\n", - "w=2*math.pi*f\n", - "V=33000\n", - "Vr=V/sqrt(3)\n", - "P=24E6/3\n", - "pf=0.8\n", - "phi=math.acos(pf)\n", - "Ia=P/Vr/pf\n", - "Rl=4.0\n", - "Xl=20\n", - "Vs=Vr+Ia*(Xl*sin(phi)+Rl*cos(phi))\n", - "Vsll=sqrt(3)*Vs\n", - "VR=Vsll/V-1\n", - "print(Vsll)\n", - "Ia=Ia*exp(-1j*phi)\n", - "print(norm(Ia))\n", - "\n", - "phi1=math.atan(-Rl/Xl)\n", - "pf=cos(phi1)\n", - "Ia1=P/Vr/pf\n", - "Ia1=Ia1*exp(-1j*phi1) #calculation mistake in the book at this step\n", - "\n", - "Ic=Ia1-Ia\n", - "C=norm(Ic/w/Vr)\n", - "print(C)\n", - "\n", - "LL1=norm(Ia*Ia*Rl)\n", - "effi1=P/(P+LL1)\n", - "LL2=norm(Ia1*Ia1*Rl)\n", - "effi2=P/(P+LL2)\n", - "print(effi1)\n", - "print(effi2)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "46818.1818182\n", - "524.863881081" - ] - }, - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - "6.66433921487e-05\n", - "0.878934624697\n", - "0.916018976481\n" - ] - } - ], - "prompt_number": 11 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/asmitaasmita/1_An_overview_of_C++.ipynb b/sample_notebooks/asmitaasmita/1_An_overview_of_C++.ipynb deleted file mode 100755 index ecf52ddd..00000000 --- a/sample_notebooks/asmitaasmita/1_An_overview_of_C++.ipynb +++ /dev/null @@ -1,254 +0,0 @@ -{ - "metadata": { - "name": "1 An overview of C++" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number: 14#\\n#This program outputs a string, two integer values, and a double floating-point value. #\ni=10\nj=20\nd=99.101\nprint ('Here are some values : %d %d %2.3f'%(i,j,d))\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Here are some values : 10 20 99.101\n" - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 , Page Number: 16#\n\n#Variable declaration\ni=100\n\n#Result\nprint('Enter a value: 100')\nprint 'Here\\'s your number: ',i\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter a value: 100\nHere's your number: 100\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 4 , Page Number 16#\n\n#Variable declaration\ni=10\nf=100.12\ns='Hello World'\n\n#Result\nprint 'Enter an integer,float and string: ',i,f,s\nprint 'Here\\'s your data: ',i,f,s \n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " Enter an integer,float and string: 10 100.12 Hello World\nHere's your data: 10 100.12 Hello World\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 5 , Page Number 17#\n\n#Variable declaration\nch='X'\n\n#Result\nprint 'Enter keys,X to stop.'\n\n#while loop\nwhile ch!='X':\n if(ch!='X'): \n print ': ',ch\n else:\n break", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter keys,X to stop.\n" - } - ], - "prompt_number": 4 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number 19#\n\n#Variable declaration\na=199\n\nprint 'Enter number to be tested: ',a\n#if loop\nif a % 2 == 0:\n#Result\n print 'Number is even'\nelse:\n print 'Number is odd'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter number to be tested: 199\nNumber is odd\n" - } - ], - "prompt_number": 5 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 ,Page Number 25#\n\n#class declaration\nclass Myclass():\n def __init__(self,c,d):\n self.a = c\n self.b = d\nobj = Myclass(10,99)\nobj.a,obj.b\n\n#Result\nprint obj.a\nprint obj.b", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "10\n99\n" - } - ], - "prompt_number": 6 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 2 , Page Number 30#\n\n#DefiningFunction\ndef sum(a,b):\n return a+b\na=10\nb=40\n\n#Result\nprint 'Enter two numbers: ',a,b\nprint 'Sum is: ',sum(a,b)", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter two numbers: 10 40\nSum is: 50\n" - } - ], - "prompt_number": 7 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 , Page Number 31#\n\n#Variable declaration\ni=5\nprint 'Enter number: ',i\nfact=1\nfor j in range(i):\n fact = fact * (j+1)\n \n#Result\nprint 'Factorial is ',fact\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter number: 5\nFactorial is 120\n" - } - ], - "prompt_number": 8 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 4 ,Page Number 32#\n\noutcome = 'false'\n\n#if loop\nif(outcome):\n print 'true'\nelse:\n print 'false'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "true\n" - } - ], - "prompt_number": 9 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 2 ,Page Number 36#\n\n#Defining function\ndef get_date(day=None, month=None, year=None, as_string=None):\n\tif as_string:\n\t\tprint 'Date:', as_string\n\telse:\n\t\tif not (day and month and year):\n\t\t\traise Exception(\"Invalid Date arguments\")\n\t\tprint \"Date : %d/%d/%d\" % (month, day, year)\n\n\nif __name__ == '__main__':\n\tget_date(as_string=\"3/12/2013\")\n\tget_date(day=12, month=3, year=2013)\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Date: 3/12/2013\nDate : 3/12/2013\n" - } - ], - "prompt_number": 10 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 1.3 Q3 , Page Number 18#\n\n#Variable declaration\na=4\nb=8\nd=2\nprint 'Enter two numbers: ',a,b\nif a>b:\n min=b\nelse:\n min=a\nfor d in range(d,min):\n if a % d == 0 and b % d == 0: \n break\nif d == min:\n print 'No common denominators ' \nelse:\n print 'The lowest common denominator is ',d\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter two numbers: 4 8\nThe lowest common denominator is 2\n" - } - ], - "prompt_number": 11 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number 34#\n\nprint 'Absolute value of -10: ',abs(-10)\nprint 'Absolute value of -10L: ',abs(-10L)\nprint 'Absolute value of -10.01: ',abs(-10.01)\n\n#Defining function\ndef abs(n):\n print 'In integer abs() '\n \n\ndef abs(n):\n print 'In longs abs() '\n\ndef abs(n):\n print 'In double abs() '\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Absolute value of -10: 10\nAbsolute value of -10L: 10\nAbsolute value of -10.01: 10.01\n" - } - ], - "prompt_number": 12 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Excercise 1 , Page Number 18#\n\n#Variable declaration\nhours=3\nwage=2000\n\n#Result\nprint 'Enter hours worked: ',hours\n\nprint 'Enter wage per hour: ',wage\nprint 'Pay is: $',wage*hours", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter hours worked: 3\nEnter wage per hour: 2000\nPay is: $ 6000\n" - } - ], - "prompt_number": 13 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 2 , Page Number 18#\n\n#Variable declaration\nfeet = 5.0\n\n#If loop\nif(feet == 0.0):\n print 'Wrong inpt.'\nelse:\n print 'Enter feet :',feet\n #Result\n print feet*12,'inches'\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter feet : 5.0\n60.0 inches\n" - } - ], - "prompt_number": 14 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 1.7 Q1 , Page Number 38#\n\nimport math\n\n#Result\nprint 'Square root of 90.34 is : ',math.sqrt(90.34)\nprint 'Square root of 90L is: ',math.sqrt(90L)\nprint 'Square root of 90 is: ',math.sqrt(90)\n\n#Defining functions\ndef sqrt(n):\n print 'computing integer root '\n \n\ndef sqrt(n):\n print 'computing long root '\n\ndef sqrt(n):\n print 'computing double root '", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Square root of 90.34 is : 9.50473566176\nSquare root of 90L is: 9.48683298051\nSquare root of 90 is: 9.48683298051\n" - } - ], - "prompt_number": 15 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Example 3 , Page Number 36#\n\n#Defining functions\ndef f1(a=None,b=None,c=None):\n if a:\n print 'In f1',(a)\n else:\n if not (b and c):\n raise Exception(\"Invalid arguments\")\n print 'In f1',(b,c)\nif __name__ == '__main__':\n\tf1(a=10)\n\tf1(b=10, c=20)", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "In f1 10\nIn f1 (10, 20)\n" - } - ], - "prompt_number": 16 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/asmitaasmita/1_An_overview_of_C++_1.ipynb b/sample_notebooks/asmitaasmita/1_An_overview_of_C++_1.ipynb deleted file mode 100755 index ecf52ddd..00000000 --- a/sample_notebooks/asmitaasmita/1_An_overview_of_C++_1.ipynb +++ /dev/null @@ -1,254 +0,0 @@ -{ - "metadata": { - "name": "1 An overview of C++" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number: 14#\\n#This program outputs a string, two integer values, and a double floating-point value. #\ni=10\nj=20\nd=99.101\nprint ('Here are some values : %d %d %2.3f'%(i,j,d))\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Here are some values : 10 20 99.101\n" - } - ], - "prompt_number": 1 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 , Page Number: 16#\n\n#Variable declaration\ni=100\n\n#Result\nprint('Enter a value: 100')\nprint 'Here\\'s your number: ',i\n\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter a value: 100\nHere's your number: 100\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 4 , Page Number 16#\n\n#Variable declaration\ni=10\nf=100.12\ns='Hello World'\n\n#Result\nprint 'Enter an integer,float and string: ',i,f,s\nprint 'Here\\'s your data: ',i,f,s \n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " Enter an integer,float and string: 10 100.12 Hello World\nHere's your data: 10 100.12 Hello World\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 5 , Page Number 17#\n\n#Variable declaration\nch='X'\n\n#Result\nprint 'Enter keys,X to stop.'\n\n#while loop\nwhile ch!='X':\n if(ch!='X'): \n print ': ',ch\n else:\n break", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter keys,X to stop.\n" - } - ], - "prompt_number": 4 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number 19#\n\n#Variable declaration\na=199\n\nprint 'Enter number to be tested: ',a\n#if loop\nif a % 2 == 0:\n#Result\n print 'Number is even'\nelse:\n print 'Number is odd'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter number to be tested: 199\nNumber is odd\n" - } - ], - "prompt_number": 5 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 ,Page Number 25#\n\n#class declaration\nclass Myclass():\n def __init__(self,c,d):\n self.a = c\n self.b = d\nobj = Myclass(10,99)\nobj.a,obj.b\n\n#Result\nprint obj.a\nprint obj.b", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "10\n99\n" - } - ], - "prompt_number": 6 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 2 , Page Number 30#\n\n#DefiningFunction\ndef sum(a,b):\n return a+b\na=10\nb=40\n\n#Result\nprint 'Enter two numbers: ',a,b\nprint 'Sum is: ',sum(a,b)", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter two numbers: 10 40\nSum is: 50\n" - } - ], - "prompt_number": 7 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 3 , Page Number 31#\n\n#Variable declaration\ni=5\nprint 'Enter number: ',i\nfact=1\nfor j in range(i):\n fact = fact * (j+1)\n \n#Result\nprint 'Factorial is ',fact\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter number: 5\nFactorial is 120\n" - } - ], - "prompt_number": 8 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 4 ,Page Number 32#\n\noutcome = 'false'\n\n#if loop\nif(outcome):\n print 'true'\nelse:\n print 'false'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "true\n" - } - ], - "prompt_number": 9 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 2 ,Page Number 36#\n\n#Defining function\ndef get_date(day=None, month=None, year=None, as_string=None):\n\tif as_string:\n\t\tprint 'Date:', as_string\n\telse:\n\t\tif not (day and month and year):\n\t\t\traise Exception(\"Invalid Date arguments\")\n\t\tprint \"Date : %d/%d/%d\" % (month, day, year)\n\n\nif __name__ == '__main__':\n\tget_date(as_string=\"3/12/2013\")\n\tget_date(day=12, month=3, year=2013)\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Date: 3/12/2013\nDate : 3/12/2013\n" - } - ], - "prompt_number": 10 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 1.3 Q3 , Page Number 18#\n\n#Variable declaration\na=4\nb=8\nd=2\nprint 'Enter two numbers: ',a,b\nif a>b:\n min=b\nelse:\n min=a\nfor d in range(d,min):\n if a % d == 0 and b % d == 0: \n break\nif d == min:\n print 'No common denominators ' \nelse:\n print 'The lowest common denominator is ',d\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter two numbers: 4 8\nThe lowest common denominator is 2\n" - } - ], - "prompt_number": 11 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Ex 1 , Page Number 34#\n\nprint 'Absolute value of -10: ',abs(-10)\nprint 'Absolute value of -10L: ',abs(-10L)\nprint 'Absolute value of -10.01: ',abs(-10.01)\n\n#Defining function\ndef abs(n):\n print 'In integer abs() '\n \n\ndef abs(n):\n print 'In longs abs() '\n\ndef abs(n):\n print 'In double abs() '\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Absolute value of -10: 10\nAbsolute value of -10L: 10\nAbsolute value of -10.01: 10.01\n" - } - ], - "prompt_number": 12 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Excercise 1 , Page Number 18#\n\n#Variable declaration\nhours=3\nwage=2000\n\n#Result\nprint 'Enter hours worked: ',hours\n\nprint 'Enter wage per hour: ',wage\nprint 'Pay is: $',wage*hours", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter hours worked: 3\nEnter wage per hour: 2000\nPay is: $ 6000\n" - } - ], - "prompt_number": 13 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 2 , Page Number 18#\n\n#Variable declaration\nfeet = 5.0\n\n#If loop\nif(feet == 0.0):\n print 'Wrong inpt.'\nelse:\n print 'Enter feet :',feet\n #Result\n print feet*12,'inches'\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Enter feet : 5.0\n60.0 inches\n" - } - ], - "prompt_number": 14 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Exercise 1.7 Q1 , Page Number 38#\n\nimport math\n\n#Result\nprint 'Square root of 90.34 is : ',math.sqrt(90.34)\nprint 'Square root of 90L is: ',math.sqrt(90L)\nprint 'Square root of 90 is: ',math.sqrt(90)\n\n#Defining functions\ndef sqrt(n):\n print 'computing integer root '\n \n\ndef sqrt(n):\n print 'computing long root '\n\ndef sqrt(n):\n print 'computing double root '", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Square root of 90.34 is : 9.50473566176\nSquare root of 90L is: 9.48683298051\nSquare root of 90 is: 9.48683298051\n" - } - ], - "prompt_number": 15 - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#Example 3 , Page Number 36#\n\n#Defining functions\ndef f1(a=None,b=None,c=None):\n if a:\n print 'In f1',(a)\n else:\n if not (b and c):\n raise Exception(\"Invalid arguments\")\n print 'In f1',(b,c)\nif __name__ == '__main__':\n\tf1(a=10)\n\tf1(b=10, c=20)", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "In f1 10\nIn f1 (10, 20)\n" - } - ], - "prompt_number": 16 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of.ipynb b/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of.ipynb new file mode 100755 index 00000000..ecf52ddd --- /dev/null +++ b/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of.ipynb @@ -0,0 +1,254 @@ +{ + "metadata": { + "name": "1 An overview of C++" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number: 14#\\n#This program outputs a string, two integer values, and a double floating-point value. #\ni=10\nj=20\nd=99.101\nprint ('Here are some values : %d %d %2.3f'%(i,j,d))\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Here are some values : 10 20 99.101\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 , Page Number: 16#\n\n#Variable declaration\ni=100\n\n#Result\nprint('Enter a value: 100')\nprint 'Here\\'s your number: ',i\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter a value: 100\nHere's your number: 100\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 4 , Page Number 16#\n\n#Variable declaration\ni=10\nf=100.12\ns='Hello World'\n\n#Result\nprint 'Enter an integer,float and string: ',i,f,s\nprint 'Here\\'s your data: ',i,f,s \n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " Enter an integer,float and string: 10 100.12 Hello World\nHere's your data: 10 100.12 Hello World\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 5 , Page Number 17#\n\n#Variable declaration\nch='X'\n\n#Result\nprint 'Enter keys,X to stop.'\n\n#while loop\nwhile ch!='X':\n if(ch!='X'): \n print ': ',ch\n else:\n break", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter keys,X to stop.\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number 19#\n\n#Variable declaration\na=199\n\nprint 'Enter number to be tested: ',a\n#if loop\nif a % 2 == 0:\n#Result\n print 'Number is even'\nelse:\n print 'Number is odd'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter number to be tested: 199\nNumber is odd\n" + } + ], + "prompt_number": 5 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 ,Page Number 25#\n\n#class declaration\nclass Myclass():\n def __init__(self,c,d):\n self.a = c\n self.b = d\nobj = Myclass(10,99)\nobj.a,obj.b\n\n#Result\nprint obj.a\nprint obj.b", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "10\n99\n" + } + ], + "prompt_number": 6 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 2 , Page Number 30#\n\n#DefiningFunction\ndef sum(a,b):\n return a+b\na=10\nb=40\n\n#Result\nprint 'Enter two numbers: ',a,b\nprint 'Sum is: ',sum(a,b)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter two numbers: 10 40\nSum is: 50\n" + } + ], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 , Page Number 31#\n\n#Variable declaration\ni=5\nprint 'Enter number: ',i\nfact=1\nfor j in range(i):\n fact = fact * (j+1)\n \n#Result\nprint 'Factorial is ',fact\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter number: 5\nFactorial is 120\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 4 ,Page Number 32#\n\noutcome = 'false'\n\n#if loop\nif(outcome):\n print 'true'\nelse:\n print 'false'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "true\n" + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 2 ,Page Number 36#\n\n#Defining function\ndef get_date(day=None, month=None, year=None, as_string=None):\n\tif as_string:\n\t\tprint 'Date:', as_string\n\telse:\n\t\tif not (day and month and year):\n\t\t\traise Exception(\"Invalid Date arguments\")\n\t\tprint \"Date : %d/%d/%d\" % (month, day, year)\n\n\nif __name__ == '__main__':\n\tget_date(as_string=\"3/12/2013\")\n\tget_date(day=12, month=3, year=2013)\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Date: 3/12/2013\nDate : 3/12/2013\n" + } + ], + "prompt_number": 10 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 1.3 Q3 , Page Number 18#\n\n#Variable declaration\na=4\nb=8\nd=2\nprint 'Enter two numbers: ',a,b\nif a>b:\n min=b\nelse:\n min=a\nfor d in range(d,min):\n if a % d == 0 and b % d == 0: \n break\nif d == min:\n print 'No common denominators ' \nelse:\n print 'The lowest common denominator is ',d\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter two numbers: 4 8\nThe lowest common denominator is 2\n" + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number 34#\n\nprint 'Absolute value of -10: ',abs(-10)\nprint 'Absolute value of -10L: ',abs(-10L)\nprint 'Absolute value of -10.01: ',abs(-10.01)\n\n#Defining function\ndef abs(n):\n print 'In integer abs() '\n \n\ndef abs(n):\n print 'In longs abs() '\n\ndef abs(n):\n print 'In double abs() '\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Absolute value of -10: 10\nAbsolute value of -10L: 10\nAbsolute value of -10.01: 10.01\n" + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Excercise 1 , Page Number 18#\n\n#Variable declaration\nhours=3\nwage=2000\n\n#Result\nprint 'Enter hours worked: ',hours\n\nprint 'Enter wage per hour: ',wage\nprint 'Pay is: $',wage*hours", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter hours worked: 3\nEnter wage per hour: 2000\nPay is: $ 6000\n" + } + ], + "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 2 , Page Number 18#\n\n#Variable declaration\nfeet = 5.0\n\n#If loop\nif(feet == 0.0):\n print 'Wrong inpt.'\nelse:\n print 'Enter feet :',feet\n #Result\n print feet*12,'inches'\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter feet : 5.0\n60.0 inches\n" + } + ], + "prompt_number": 14 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 1.7 Q1 , Page Number 38#\n\nimport math\n\n#Result\nprint 'Square root of 90.34 is : ',math.sqrt(90.34)\nprint 'Square root of 90L is: ',math.sqrt(90L)\nprint 'Square root of 90 is: ',math.sqrt(90)\n\n#Defining functions\ndef sqrt(n):\n print 'computing integer root '\n \n\ndef sqrt(n):\n print 'computing long root '\n\ndef sqrt(n):\n print 'computing double root '", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Square root of 90.34 is : 9.50473566176\nSquare root of 90L is: 9.48683298051\nSquare root of 90 is: 9.48683298051\n" + } + ], + "prompt_number": 15 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Example 3 , Page Number 36#\n\n#Defining functions\ndef f1(a=None,b=None,c=None):\n if a:\n print 'In f1',(a)\n else:\n if not (b and c):\n raise Exception(\"Invalid arguments\")\n print 'In f1',(b,c)\nif __name__ == '__main__':\n\tf1(a=10)\n\tf1(b=10, c=20)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "In f1 10\nIn f1 (10, 20)\n" + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of_C++_1.ipynb b/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of_C++_1.ipynb new file mode 100755 index 00000000..ecf52ddd --- /dev/null +++ b/sample_notebooks/asmitaasmita/asmitaasmita_version_backup/1_An_overview_of_C++_1.ipynb @@ -0,0 +1,254 @@ +{ + "metadata": { + "name": "1 An overview of C++" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number: 14#\\n#This program outputs a string, two integer values, and a double floating-point value. #\ni=10\nj=20\nd=99.101\nprint ('Here are some values : %d %d %2.3f'%(i,j,d))\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Here are some values : 10 20 99.101\n" + } + ], + "prompt_number": 1 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 , Page Number: 16#\n\n#Variable declaration\ni=100\n\n#Result\nprint('Enter a value: 100')\nprint 'Here\\'s your number: ',i\n\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter a value: 100\nHere's your number: 100\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 4 , Page Number 16#\n\n#Variable declaration\ni=10\nf=100.12\ns='Hello World'\n\n#Result\nprint 'Enter an integer,float and string: ',i,f,s\nprint 'Here\\'s your data: ',i,f,s \n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " Enter an integer,float and string: 10 100.12 Hello World\nHere's your data: 10 100.12 Hello World\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 5 , Page Number 17#\n\n#Variable declaration\nch='X'\n\n#Result\nprint 'Enter keys,X to stop.'\n\n#while loop\nwhile ch!='X':\n if(ch!='X'): \n print ': ',ch\n else:\n break", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter keys,X to stop.\n" + } + ], + "prompt_number": 4 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number 19#\n\n#Variable declaration\na=199\n\nprint 'Enter number to be tested: ',a\n#if loop\nif a % 2 == 0:\n#Result\n print 'Number is even'\nelse:\n print 'Number is odd'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter number to be tested: 199\nNumber is odd\n" + } + ], + "prompt_number": 5 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 ,Page Number 25#\n\n#class declaration\nclass Myclass():\n def __init__(self,c,d):\n self.a = c\n self.b = d\nobj = Myclass(10,99)\nobj.a,obj.b\n\n#Result\nprint obj.a\nprint obj.b", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "10\n99\n" + } + ], + "prompt_number": 6 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 2 , Page Number 30#\n\n#DefiningFunction\ndef sum(a,b):\n return a+b\na=10\nb=40\n\n#Result\nprint 'Enter two numbers: ',a,b\nprint 'Sum is: ',sum(a,b)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter two numbers: 10 40\nSum is: 50\n" + } + ], + "prompt_number": 7 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 3 , Page Number 31#\n\n#Variable declaration\ni=5\nprint 'Enter number: ',i\nfact=1\nfor j in range(i):\n fact = fact * (j+1)\n \n#Result\nprint 'Factorial is ',fact\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter number: 5\nFactorial is 120\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 4 ,Page Number 32#\n\noutcome = 'false'\n\n#if loop\nif(outcome):\n print 'true'\nelse:\n print 'false'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "true\n" + } + ], + "prompt_number": 9 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 2 ,Page Number 36#\n\n#Defining function\ndef get_date(day=None, month=None, year=None, as_string=None):\n\tif as_string:\n\t\tprint 'Date:', as_string\n\telse:\n\t\tif not (day and month and year):\n\t\t\traise Exception(\"Invalid Date arguments\")\n\t\tprint \"Date : %d/%d/%d\" % (month, day, year)\n\n\nif __name__ == '__main__':\n\tget_date(as_string=\"3/12/2013\")\n\tget_date(day=12, month=3, year=2013)\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Date: 3/12/2013\nDate : 3/12/2013\n" + } + ], + "prompt_number": 10 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 1.3 Q3 , Page Number 18#\n\n#Variable declaration\na=4\nb=8\nd=2\nprint 'Enter two numbers: ',a,b\nif a>b:\n min=b\nelse:\n min=a\nfor d in range(d,min):\n if a % d == 0 and b % d == 0: \n break\nif d == min:\n print 'No common denominators ' \nelse:\n print 'The lowest common denominator is ',d\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter two numbers: 4 8\nThe lowest common denominator is 2\n" + } + ], + "prompt_number": 11 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Ex 1 , Page Number 34#\n\nprint 'Absolute value of -10: ',abs(-10)\nprint 'Absolute value of -10L: ',abs(-10L)\nprint 'Absolute value of -10.01: ',abs(-10.01)\n\n#Defining function\ndef abs(n):\n print 'In integer abs() '\n \n\ndef abs(n):\n print 'In longs abs() '\n\ndef abs(n):\n print 'In double abs() '\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Absolute value of -10: 10\nAbsolute value of -10L: 10\nAbsolute value of -10.01: 10.01\n" + } + ], + "prompt_number": 12 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Excercise 1 , Page Number 18#\n\n#Variable declaration\nhours=3\nwage=2000\n\n#Result\nprint 'Enter hours worked: ',hours\n\nprint 'Enter wage per hour: ',wage\nprint 'Pay is: $',wage*hours", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter hours worked: 3\nEnter wage per hour: 2000\nPay is: $ 6000\n" + } + ], + "prompt_number": 13 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 2 , Page Number 18#\n\n#Variable declaration\nfeet = 5.0\n\n#If loop\nif(feet == 0.0):\n print 'Wrong inpt.'\nelse:\n print 'Enter feet :',feet\n #Result\n print feet*12,'inches'\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Enter feet : 5.0\n60.0 inches\n" + } + ], + "prompt_number": 14 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Exercise 1.7 Q1 , Page Number 38#\n\nimport math\n\n#Result\nprint 'Square root of 90.34 is : ',math.sqrt(90.34)\nprint 'Square root of 90L is: ',math.sqrt(90L)\nprint 'Square root of 90 is: ',math.sqrt(90)\n\n#Defining functions\ndef sqrt(n):\n print 'computing integer root '\n \n\ndef sqrt(n):\n print 'computing long root '\n\ndef sqrt(n):\n print 'computing double root '", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Square root of 90.34 is : 9.50473566176\nSquare root of 90L is: 9.48683298051\nSquare root of 90 is: 9.48683298051\n" + } + ], + "prompt_number": 15 + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#Example 3 , Page Number 36#\n\n#Defining functions\ndef f1(a=None,b=None,c=None):\n if a:\n print 'In f1',(a)\n else:\n if not (b and c):\n raise Exception(\"Invalid arguments\")\n print 'In f1',(b,c)\nif __name__ == '__main__':\n\tf1(a=10)\n\tf1(b=10, c=20)", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "In f1 10\nIn f1 (10, 20)\n" + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/bharthkumar/Untitled1.ipynb b/sample_notebooks/bharthkumar/Untitled1.ipynb deleted file mode 100755 index c2fe40ea..00000000 --- a/sample_notebooks/bharthkumar/Untitled1.ipynb +++ /dev/null @@ -1,185 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:2206f2855e4232dc4600c4e414262a1e7f06df22f4a8f22ba905ba92f7813175" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter1-Introduction" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex1-pg16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##calculate the\n", - "## initialization of variables\n", - "import math\n", - "## part (a)\n", - "a=700. ## M Pa from figure 1.8\n", - "b=100. ## M Pafrom figure 1.8\n", - "m=1/6. ## from figure 1.8\n", - "Y=450. ## M Pa from figure 1.9\n", - "##calculations\n", - "sigma_u=a+m*b\n", - "## results\n", - "print('\\n part (a) \\n')\n", - "print\"%s %.2f %s\"%(' The ultimate strength is sigma = ',sigma_u,' M Pa')\n", - "print\"%s %.2f %s\"%('\\n and the yield strength is Y = ',Y,'M Pa')\n", - "\n", - "## part (b)\n", - "c1=62. ## from figure 1.8\n", - "d1=0.025 ## from figure 1.8\n", - "c2=27. ## from figure 1.10a\n", - "d2=0.04 ## from figure 1.10a\n", - "## calculations\n", - "U_f1=c1*b*d1*10**6\n", - "U_f2=c2*b*d2*10**6\n", - "## results\n", - "print('\\n part (b)')\n", - "print\"%s %.2e %s\"%('\\n The modulus of toughness for alloy steel is Uf = ',U_f1,' N/m^2')\n", - "print\"%s %.2e %s\"%('\\n and structural steel is Uf = ',U_f2,' N/m^2')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " part (a) \n", - "\n", - " The ultimate strength is sigma = 716.67 M Pa\n", - "\n", - " and the yield strength is Y = 450.00 M Pa\n", - "\n", - " part (b)\n", - "\n", - " The modulus of toughness for alloy steel is Uf = 1.55e+08 N/m^2\n", - "\n", - " and structural steel is Uf = 1.08e+08 N/m^2\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2-pg16" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##calculate the permanet strain\n", - "## initialization of variables\n", - "import math\n", - "sigma=500. ## Stress M Pa\n", - "eps=0.0073 ## Strain\n", - "sigma_A=343. ## M Pa from figure 1.9\n", - "eps_A=0.00172 ## from figure 1.9\n", - "## part (a)\n", - "E=sigma_A/eps_A\n", - "\n", - "## part (B)\n", - "eps_e=sigma/E\n", - "eps_p=eps-eps_e\n", - "## results\n", - "print(' part (a) \\n')\n", - "print\"%s %.2f %s\"%(' The modulus of elasticity of the rod is E = ',E/1000,' G Pa')\n", - "print('\\n part (b)')\n", - "print\"%s %.4f %s\"%('\\n the permanent strain is = ',eps_p,'')\n", - "print\"%s %.4f %s\"%('\\n and the strain recovered is =',eps_e,'')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - " part (a) \n", - "\n", - " The modulus of elasticity of the rod is E = 199.42 G Pa\n", - "\n", - " part (b)\n", - "\n", - " the permanent strain is = 0.0048 \n", - "\n", - " and the strain recovered is = 0.0025 \n" - ] - } - ], - "prompt_number": 15 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex3-pg19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##calculate the diameter\n", - "## initialization of variables\n", - "import math\n", - "D=25. ## kN\n", - "L=60. ## kN\n", - "W=30. ##kN\n", - "Y=250. ## M Pa\n", - "safety=5./3. ## AISC, 1989\n", - "## calculations\n", - "Q=(D+L+W)*10**3. ## converted to N\n", - "A=safety*Q/Y\n", - "r=math.sqrt(A/math.pi)+0.5 ## additional 0.5 mm is for extra safety\n", - "d=1.8*r ## diameter\n", - "## results\n", - "print('Part (a) \\n ')\n", - "print\"%s %.2f %s %.2f %s \"%('A rod of ',d,' mm'and ' in diameter, with a cross sectional area of ',math.pi*(d**2./4.),' mm^2, is adequate')\n", - "## The diameter is correct as given in the textbook. Area doesn't match due to rounding off error and partly because it's a design problem.\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Part (a) \n", - " \n", - "A rod of 29.02 in diameter, with a cross sectional area of 661.39 mm^2, is adequate \n" - ] - } - ], - "prompt_number": 14 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/bharthkumar/bharthkumar_version_backup/Untitled1.ipynb b/sample_notebooks/bharthkumar/bharthkumar_version_backup/Untitled1.ipynb new file mode 100755 index 00000000..c2fe40ea --- /dev/null +++ b/sample_notebooks/bharthkumar/bharthkumar_version_backup/Untitled1.ipynb @@ -0,0 +1,185 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:2206f2855e4232dc4600c4e414262a1e7f06df22f4a8f22ba905ba92f7813175" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter1-Introduction" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex1-pg16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##calculate the\n", + "## initialization of variables\n", + "import math\n", + "## part (a)\n", + "a=700. ## M Pa from figure 1.8\n", + "b=100. ## M Pafrom figure 1.8\n", + "m=1/6. ## from figure 1.8\n", + "Y=450. ## M Pa from figure 1.9\n", + "##calculations\n", + "sigma_u=a+m*b\n", + "## results\n", + "print('\\n part (a) \\n')\n", + "print\"%s %.2f %s\"%(' The ultimate strength is sigma = ',sigma_u,' M Pa')\n", + "print\"%s %.2f %s\"%('\\n and the yield strength is Y = ',Y,'M Pa')\n", + "\n", + "## part (b)\n", + "c1=62. ## from figure 1.8\n", + "d1=0.025 ## from figure 1.8\n", + "c2=27. ## from figure 1.10a\n", + "d2=0.04 ## from figure 1.10a\n", + "## calculations\n", + "U_f1=c1*b*d1*10**6\n", + "U_f2=c2*b*d2*10**6\n", + "## results\n", + "print('\\n part (b)')\n", + "print\"%s %.2e %s\"%('\\n The modulus of toughness for alloy steel is Uf = ',U_f1,' N/m^2')\n", + "print\"%s %.2e %s\"%('\\n and structural steel is Uf = ',U_f2,' N/m^2')\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " part (a) \n", + "\n", + " The ultimate strength is sigma = 716.67 M Pa\n", + "\n", + " and the yield strength is Y = 450.00 M Pa\n", + "\n", + " part (b)\n", + "\n", + " The modulus of toughness for alloy steel is Uf = 1.55e+08 N/m^2\n", + "\n", + " and structural steel is Uf = 1.08e+08 N/m^2\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex2-pg16" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##calculate the permanet strain\n", + "## initialization of variables\n", + "import math\n", + "sigma=500. ## Stress M Pa\n", + "eps=0.0073 ## Strain\n", + "sigma_A=343. ## M Pa from figure 1.9\n", + "eps_A=0.00172 ## from figure 1.9\n", + "## part (a)\n", + "E=sigma_A/eps_A\n", + "\n", + "## part (B)\n", + "eps_e=sigma/E\n", + "eps_p=eps-eps_e\n", + "## results\n", + "print(' part (a) \\n')\n", + "print\"%s %.2f %s\"%(' The modulus of elasticity of the rod is E = ',E/1000,' G Pa')\n", + "print('\\n part (b)')\n", + "print\"%s %.4f %s\"%('\\n the permanent strain is = ',eps_p,'')\n", + "print\"%s %.4f %s\"%('\\n and the strain recovered is =',eps_e,'')\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + " part (a) \n", + "\n", + " The modulus of elasticity of the rod is E = 199.42 G Pa\n", + "\n", + " part (b)\n", + "\n", + " the permanent strain is = 0.0048 \n", + "\n", + " and the strain recovered is = 0.0025 \n" + ] + } + ], + "prompt_number": 15 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex3-pg19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##calculate the diameter\n", + "## initialization of variables\n", + "import math\n", + "D=25. ## kN\n", + "L=60. ## kN\n", + "W=30. ##kN\n", + "Y=250. ## M Pa\n", + "safety=5./3. ## AISC, 1989\n", + "## calculations\n", + "Q=(D+L+W)*10**3. ## converted to N\n", + "A=safety*Q/Y\n", + "r=math.sqrt(A/math.pi)+0.5 ## additional 0.5 mm is for extra safety\n", + "d=1.8*r ## diameter\n", + "## results\n", + "print('Part (a) \\n ')\n", + "print\"%s %.2f %s %.2f %s \"%('A rod of ',d,' mm'and ' in diameter, with a cross sectional area of ',math.pi*(d**2./4.),' mm^2, is adequate')\n", + "## The diameter is correct as given in the textbook. Area doesn't match due to rounding off error and partly because it's a design problem.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Part (a) \n", + " \n", + "A rod of 29.02 in diameter, with a cross sectional area of 661.39 mm^2, is adequate \n" + ] + } + ], + "prompt_number": 14 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ebbygeorge/Ch1.ipynb b/sample_notebooks/ebbygeorge/Ch1.ipynb deleted file mode 100644 index ac7b8152..00000000 --- a/sample_notebooks/ebbygeorge/Ch1.ipynb +++ /dev/null @@ -1,87 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Chapter 1:Measurement of phase and frequency" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 1.1, Page number 28" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "inductance of the circuit 1 = 7.04 H\n", - "inductance of circuit 2 L2=9.82 H\n", - "Resonant frequency of the circuit 1 = 41.47 Hz\n" - ] - } - ], - "source": [ - "import math\n", - "c1=10**-6;\n", - "f1=60;\n", - "L1=1/(4*math.pi*math.pi*(f1**2)*c1);\n", - "print (\"inductance of the circuit 1 = %.2f H\" % L1)\n", - "f2=50;\n", - "w=2*math.pi*f2;\n", - "R1=100;\n", - "Z1=complex(R1,((w*L1)-(1/w*c1)));\n", - "#Z2=complex(100+j*((2*math.pi*50*L2)-(1/(2*math.pi*50*1.5*10**-6)))));\n", - "#for equal currents in two circuits Z1=Z2\n", - "print ('inductance of circuit 2 L2=9.82 H')\n", - "L2=9.82;\n", - "C2=1.5*10**-6;\n", - "Rf2=(1/(2*math.pi))*(1/(L2*C2))**0.5;\n", - "print (\"Resonant frequency of the circuit 1 = %.2f Hz\" % Rf2)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python [Root]", - "language": "python", - "name": "Python [Root]" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ebbygeorge/ebbygeorge_version_backup/Ch1.ipynb b/sample_notebooks/ebbygeorge/ebbygeorge_version_backup/Ch1.ipynb new file mode 100644 index 00000000..ac7b8152 --- /dev/null +++ b/sample_notebooks/ebbygeorge/ebbygeorge_version_backup/Ch1.ipynb @@ -0,0 +1,87 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Chapter 1:Measurement of phase and frequency" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 1.1, Page number 28" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "inductance of the circuit 1 = 7.04 H\n", + "inductance of circuit 2 L2=9.82 H\n", + "Resonant frequency of the circuit 1 = 41.47 Hz\n" + ] + } + ], + "source": [ + "import math\n", + "c1=10**-6;\n", + "f1=60;\n", + "L1=1/(4*math.pi*math.pi*(f1**2)*c1);\n", + "print (\"inductance of the circuit 1 = %.2f H\" % L1)\n", + "f2=50;\n", + "w=2*math.pi*f2;\n", + "R1=100;\n", + "Z1=complex(R1,((w*L1)-(1/w*c1)));\n", + "#Z2=complex(100+j*((2*math.pi*50*L2)-(1/(2*math.pi*50*1.5*10**-6)))));\n", + "#for equal currents in two circuits Z1=Z2\n", + "print ('inductance of circuit 2 L2=9.82 H')\n", + "L2=9.82;\n", + "C2=1.5*10**-6;\n", + "Rf2=(1/(2*math.pi))*(1/(L2*C2))**0.5;\n", + "print (\"Resonant frequency of the circuit 1 = %.2f Hz\" % Rf2)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python [Root]", + "language": "python", + "name": "Python [Root]" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/harikagunturu/Chapter_4_Angle_Modulation.ipynb b/sample_notebooks/harikagunturu/Chapter_4_Angle_Modulation.ipynb deleted file mode 100755 index de7d514c..00000000 --- a/sample_notebooks/harikagunturu/Chapter_4_Angle_Modulation.ipynb +++ /dev/null @@ -1,666 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4 Angle Modulation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.1.A page.no: 286" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "12000 the new deviation( in Hz)\n" - ] - } - ], - "source": [ - "Freq_dev=6; #Frequency Deviation in kHz\n", - "Vm=3; #Modulating Voltage in V\n", - "Dev=Freq_dev*10**3/Vm; \n", - "# for Vm=6V\n", - "Vm=6;\n", - "Freq_dev_new=Dev*Vm;\n", - "print Freq_dev_new,\"the new deviation( in Hz)\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.1 page.no: 287" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Instantaneous Frequency(in Hz) at (t=0.4 ms)N = 100290.574948\n", - "Maximum Phase Deviation (in rad) = 3\n", - "MAximum Frequency Deiation (in Hz)= 300.0\n" - ] - } - ], - "source": [ - "from math import pi,cos\n", - "\n", - "t1=0.4;# time in ms\n", - "Ang_Freq =2*pi*10**5 +3*2*pi*100*cos(2*pi*100*(t1*10**(-3)));\n", - "Freq=Ang_Freq/(2*pi);\n", - "#change in answer due to calculation error in book\n", - "print \"Instantaneous Frequency(in Hz) at (t=0.4 ms)N = \",Freq\n", - "Max_pha_Dev=3; #max(3sin(2∗pi∗100t))\n", - "print \"Maximum Phase Deviation (in rad) = \",Max_pha_Dev\n", - "Max_fre_Dev=6*pi*100; #max(6∗pi∗100∗cos(2∗pi∗100t))\n", - "print \"MAximum Frequency Deiation (in Hz)= \",Max_fre_Dev/(2*pi)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.2.A page.no: 287" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Power Dissipated (in W) is 9.375\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "\n", - "Wc=8*10**(8);# Angular Frequency of Carrier Signal\n", - "fc=Wc/(2*pi);\n", - "Wm=1300;#Angular Frequency of Message Signal\n", - "fm=Wm/(2*pi);\n", - "B=3;#Modulation Index\n", - "R=12;\n", - "Vc_rms=15/sqrt(2);\n", - "Max_dev=B*fm;\n", - "Power=Vc_rms**(2)/R;\n", - "print \"Power Dissipated (in W) is \",Power" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.2 page.no: 287" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Peak Frequency Deviation(in Hz) is 12000\n", - "modulation index 8.0\n" - ] - } - ], - "source": [ - "a=3;#amplitude in volts\n", - "Dev_sen=4;# deviation sensitivity in KHz/volts\n", - "fm=1.5;# frequency modulating signal in KHz\n", - "f=Dev_sen*10**(3)*3;#peak frequency deviation\n", - "B=f/(fm*10**3);\n", - "print \"Peak Frequency Deviation(in Hz) is \",f\n", - "print \"modulation index \",B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.3.A page.no: 289" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The Bandwidth (in Hz) is 72000\n" - ] - } - ], - "source": [ - "fm=3; #Modulating Frequency in kHZ\n", - "Max_Dev=18; #MAximum Deviation in kHz\n", - "B=Max_Dev/fm; # modulation index 7\n", - "J=12;#from Bessel Table , for B=6\n", - "Bw=fm*J*2*10**(3);\n", - "print \"The Bandwidth (in Hz) is \",Bw" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.3 page.no: 289" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Peak Phase Deviation( in rad) 8.75\n" - ] - } - ], - "source": [ - "Dev_sen=3.5 # Deviation Sensitivity in rad/volt\n", - "a=2.5; #amplitude in volts\n", - "B=a*Dev_sen; # Peak Phase Deviation\n", - "print \"Peak Phase Deviation( in rad) \",B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.4.A page.no: 290" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum Frequency Deviation (in Hz) is 18000\n", - "Modulation Index is 5.99985864877\n" - ] - } - ], - "source": [ - "from math import pi\n", - "\n", - "Wm=18850;#Angular Frequency of message signal\n", - "fm=Wm/(2*pi);\n", - "a=3;# amplitude of message signal\n", - "Dev_sen=6;#Deviation Sensitivity in kHz/V\n", - "Max_Freq_Dev=a*Dev_sen*10**(3);\n", - "B=Max_Freq_Dev/(fm);\n", - "print \"Maximum Frequency Deviation (in Hz) is \",Max_Freq_Dev\n", - "print \"Modulation Index is \",B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.4 page.no: 291" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Deviation Sensitivity(in kHz/V) 1333\n", - "Modulation Index is 4\n", - "Deviation Sensitivity for 5V (in Hz) 6665\n", - "Modulation index 6\n", - "Deviation Sensitivity for 10V (in Hz) 13330\n", - "Modulation index is 33\n" - ] - } - ], - "source": [ - "a=3; #amplitude in Volts\n", - "Dev=4;# Deviation in kHz\n", - "fm=1;# modulating frequency in kHz\n", - "Dev_sen=Dev*10**(3)/a; #Deviation Sensitivity\n", - "B=Dev/fm; # Modulation Index\n", - "print \"Deviation Sensitivity(in kHz/V) \",Dev_sen\n", - "print \"Modulation Index is \",B\n", - "#a)\n", - "a=5;\n", - "Dev_sen_1=a*Dev_sen;\n", - "B=Dev_sen_1/(fm*10**(3));\n", - "print \"Deviation Sensitivity for 5V (in Hz) \",Dev_sen_1\n", - "print \"Modulation index\",B\n", - "#b)\n", - "a=10;\n", - "fm=400;\n", - "Dev_sen_2=a*Dev_sen;\n", - "B=Dev_sen_2/fm;\n", - "print \"Deviation Sensitivity for 10V (in Hz) \",Dev_sen_2\n", - "print \"Modulation index is \",B" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.5.A page.no: 291" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "for B=2, The number of significant frequencies are 6\n", - "They are J1,J2,J3,J4,J5 and J6\n", - "Their amplitudes with carriers are \n", - "they are (in V) 1.792 4.616 2.824 1.032 0.272 0.056 0.008\n" - ] - } - ], - "source": [ - "print \"for B=2, The number of significant frequencies are 6\"\n", - "print \"They are J1,J2,J3,J4,J5 and J6\"\n", - "print \"Their amplitudes with carriers are \"\n", - "J0= 0.224*8;\n", - "J1= 0.577*8;\n", - "J2= 0.353*8;\n", - "J3= 0.129*8;\n", - "J4= 0.034*8;\n", - "J5= 0.007*8;\n", - "J6= 0.001*8;\n", - "print\"they are (in V)\",J0,J1,J2,J3,J4,J5,J6" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.5 page.no: 292" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Bandwidth required (in Hz) 24000\n", - "According to Carsons rule , Bandwidth (in Hz) 36000\n" - ] - } - ], - "source": [ - "fm=3; #Modulating Frequency in kHZ\n", - "Max_dev=15;# Maximum Deviatin in kHZ\n", - "B=Max_dev/fm; \n", - "J=8; # Bessel table , the highest J coefficient\n", - "BW=J*fm*10**(3);#Bandwidth in kHz\n", - "BW1=2*(fm+Max_dev)*10**(3);# According to carson rule , BAndwidth\n", - "print \"Bandwidth required (in Hz) \",BW\n", - "print \"According to Carsons rule , Bandwidth (in Hz) \",BW1" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.6.A page.no: 292" - ] - }, - { - "cell_type": "code", - "execution_count": 11, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Minimum Bandwidth (in Hz) is 72000\n", - "Approximate Minimum Bandwidth is 36000\n" - ] - } - ], - "source": [ - "Max_Freq_Dev=12; #Maximum Frequency Deviation in kHZ\n", - "fm=6; #Modulating frquency in kHz\n", - "B=Max_Freq_Dev/fm;# Modulation index 7\n", - "J=6;#From Bessel Table , for B=2\n", - "Bw=2*J*6*10**(3);\n", - "BW_carson=2*(fm + Max_Freq_Dev)*10**(3);\n", - "print \"Minimum Bandwidth (in Hz) is \",Bw\n", - "print \"Approximate Minimum Bandwidth is \",BW_carson" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.6.A page.no: 283" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "For B=5 from the Bessel table ,The Bessel Function is taken upto J9\n", - "Hence the average power of the modulated signal (in W) is 9.936\n", - "Hence, the average power of the modulated signal is equal to \n", - "unmodulated carrier power\n" - ] - } - ], - "source": [ - "a=10; #Amplitude in V\n", - "Pt=a*(0.18**2 +2*(0.33**2+0.05**2+0.36**2+0.39**2+0.26**2+0.13**2+0.05**2+0.02**2+0.01**2))\n", - "print \"For B=5 from the Bessel table ,The Bessel Function is taken upto J9\"\n", - "print \"Hence the average power of the modulated signal (in W) is \",Pt\n", - "print \"Hence, the average power of the modulated signal is equal to \"\n", - "print \"unmodulated carrier power\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.7.A page.no: 294" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Unmodulated Power Carrier ( in W) = 1\n", - "Total Power in modulated wave(in W)= 1.06767573333\n", - "Power in the modulated wave is equal to \n", - "power in the unmodulated wave \n" - ] - } - ], - "source": [ - "a=8;# amplitude in V\n", - "r=30; # resistance in ohms\n", - "Pc_unmodulated=a**2/(2*r);\n", - "Pt=1.792**2/(2*30)+2*(4.616)**2/(2*30)+2*(2.824**2)/(2*30) +2*(1.032) **2/(2*30) +2*(0.272) **2/(2*30) +2*(0.056)**2/(2*30)+2*(0.008)**2/(2*30);\n", - "# change in answer due to approximations in the book\n", - "print \"Unmodulated Power Carrier ( in W) = \",Pc_unmodulated\n", - "print \"Total Power in modulated wave(in W)= \",Pt\n", - "print \"Power in the modulated wave is equal to \"\n", - "print \"power in the unmodulated wave \" \n", - "#\"Small error due to rounded off values in Bessel functions\"" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.7 page.no: 295" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the Phase Modulation Function = 12.0*sin(3000.0*pi*t)\n", - "The Modulated Wave Function = 12.0*sin(3000.0*pi*t) + 8*cos(20000*pi*t)\n" - ] - } - ], - "source": [ - "from sympy import symbols,sin,cos\n", - "\n", - "t,pi=symbols('t,pi') \n", - "Pha_dev=3.; #Phase Deviation constant in rad/V 6\n", - "# Phase Modulation Function\n", - "Pha_function=Pha_dev*4*sin(2.*pi*1.5*10**3*t);\n", - "Mod_wave=8*cos(2*pi*10**4*t)+Pha_function\n", - "print \"the Phase Modulation Function = \",Pha_function\n", - "print \"The Modulated Wave Function = \",Mod_wave" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.8 page.no: 295" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The outputs of the balanced modulator for these parameters\n", - "are same as the inputs \n", - "They remain unaltered \n", - "At the output of the Multiplier , \n", - "Fc(in kHz)= 9600 , Fm(in kHz)= 10 , B= 6.0\n", - "Frequency Deviation ( in kHz)= 60\n" - ] - } - ], - "source": [ - "initial_Freq_Dev=5; # frequency in kHz\n", - "B_initial=0.5; #modulation index\n", - "fm_initial=10;# message signal frequency in kHz\n", - "fc_initial=800; # carrier frequency in kHz\n", - "print \"The outputs of the balanced modulator for these parameters\"\n", - "print \"are same as the inputs \"\n", - "print \"They remain unaltered \"\n", - "#at the output of the multiplier 14\n", - "m=12;# multiplication factor\n", - "final_Freq_Dev=initial_Freq_Dev*m;\n", - "B_final=0.5*m;\n", - "fm_final=10; #modulating signal remains unaltered\n", - "fc_final=800*m;\n", - "print \"At the output of the Multiplier , \"\n", - "print \"Fc(in kHz)= \",fc_final,\", Fm(in kHz)= \",fm_final,\", B= \",B_final\n", - "print \"Frequency Deviation ( in kHz)= \",final_Freq_Dev" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.9.A page.no: 296" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a) MAster Oscillator Centre Frequency(in MHz) = 4.008\n", - "b) Frequency Deviation at the output of modulator(in KHz)= 2.4\n", - "c)Devaition ratio at the output of modulator 0.24\n", - "d)deviation ratio at power amplifier 6.0\n" - ] - } - ], - "source": [ - "ft=100.2; #final carrier frequency in MHz\n", - "Freq_Dev_ft=60.;# Frequency Deviation in KHz at power amplifier\n", - "fm=10.;#modulating frequency in KHz\n", - "m=25.;#multiplication factor\n", - "#a)\n", - "fc=ft/25.;\n", - "#b)\n", - "Freq_Dev=Freq_Dev_ft/25;\n", - "#c)\n", - "B=Freq_Dev/fm;\n", - "#d)\n", - "Bt=B*m;\n", - "print \"a) MAster Oscillator Centre Frequency(in MHz) = \",fc\n", - "print \"b) Frequency Deviation at the output of modulator(in KHz)= \",Freq_Dev\n", - "print \"c)Devaition ratio at the output of modulator \",B\n", - "print \"d)deviation ratio at power amplifier\",Bt" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exa 4.10.A page.no: 297" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "a) Frequency Deviation(in Hz)= 5954.92965855\n", - "b) Devaition Ratio= 5.95492965855\n", - "c) Phase Deviation( in rad)= 8\n", - "d) Bandwidth( in Hz)= 13909.8593171\n" - ] - } - ], - "source": [ - "from math import pi\n", - "\n", - "#f(t)=5cos(Wc∗t+3sin(2000∗t)+5sin(2000∗pi∗t)) 5\n", - "fm=2000*pi/(2*pi); #bandwidth is the highest frequency component\n", - "#a) \n", - "Freq_dev=(6000+10000*pi)/(2*pi); 11\n", - "#b)\n", - "B=Freq_dev/fm; \n", - "#c)\n", - "Phase_dev=8;#Highest value of[3sin(2000t)+5sin(2000∗ pi∗t)]\n", - "#d)\n", - "Bw= 2*(fm+Freq_dev);\n", - "print \"a) Frequency Deviation(in Hz)= \",Freq_dev\n", - "print \"b) Devaition Ratio= \",B\n", - "print \"c) Phase Deviation( in rad)= \",Phase_dev\n", - "print \"d) Bandwidth( in Hz)= \",Bw" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/harikagunturu/harikagunturu_version_backup/Chapter_4_Angle.ipynb b/sample_notebooks/harikagunturu/harikagunturu_version_backup/Chapter_4_Angle.ipynb new file mode 100755 index 00000000..de7d514c --- /dev/null +++ b/sample_notebooks/harikagunturu/harikagunturu_version_backup/Chapter_4_Angle.ipynb @@ -0,0 +1,666 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4 Angle Modulation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.1.A page.no: 286" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "12000 the new deviation( in Hz)\n" + ] + } + ], + "source": [ + "Freq_dev=6; #Frequency Deviation in kHz\n", + "Vm=3; #Modulating Voltage in V\n", + "Dev=Freq_dev*10**3/Vm; \n", + "# for Vm=6V\n", + "Vm=6;\n", + "Freq_dev_new=Dev*Vm;\n", + "print Freq_dev_new,\"the new deviation( in Hz)\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.1 page.no: 287" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Instantaneous Frequency(in Hz) at (t=0.4 ms)N = 100290.574948\n", + "Maximum Phase Deviation (in rad) = 3\n", + "MAximum Frequency Deiation (in Hz)= 300.0\n" + ] + } + ], + "source": [ + "from math import pi,cos\n", + "\n", + "t1=0.4;# time in ms\n", + "Ang_Freq =2*pi*10**5 +3*2*pi*100*cos(2*pi*100*(t1*10**(-3)));\n", + "Freq=Ang_Freq/(2*pi);\n", + "#change in answer due to calculation error in book\n", + "print \"Instantaneous Frequency(in Hz) at (t=0.4 ms)N = \",Freq\n", + "Max_pha_Dev=3; #max(3sin(2∗pi∗100t))\n", + "print \"Maximum Phase Deviation (in rad) = \",Max_pha_Dev\n", + "Max_fre_Dev=6*pi*100; #max(6∗pi∗100∗cos(2∗pi∗100t))\n", + "print \"MAximum Frequency Deiation (in Hz)= \",Max_fre_Dev/(2*pi)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.2.A page.no: 287" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Power Dissipated (in W) is 9.375\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "\n", + "Wc=8*10**(8);# Angular Frequency of Carrier Signal\n", + "fc=Wc/(2*pi);\n", + "Wm=1300;#Angular Frequency of Message Signal\n", + "fm=Wm/(2*pi);\n", + "B=3;#Modulation Index\n", + "R=12;\n", + "Vc_rms=15/sqrt(2);\n", + "Max_dev=B*fm;\n", + "Power=Vc_rms**(2)/R;\n", + "print \"Power Dissipated (in W) is \",Power" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.2 page.no: 287" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Peak Frequency Deviation(in Hz) is 12000\n", + "modulation index 8.0\n" + ] + } + ], + "source": [ + "a=3;#amplitude in volts\n", + "Dev_sen=4;# deviation sensitivity in KHz/volts\n", + "fm=1.5;# frequency modulating signal in KHz\n", + "f=Dev_sen*10**(3)*3;#peak frequency deviation\n", + "B=f/(fm*10**3);\n", + "print \"Peak Frequency Deviation(in Hz) is \",f\n", + "print \"modulation index \",B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.3.A page.no: 289" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The Bandwidth (in Hz) is 72000\n" + ] + } + ], + "source": [ + "fm=3; #Modulating Frequency in kHZ\n", + "Max_Dev=18; #MAximum Deviation in kHz\n", + "B=Max_Dev/fm; # modulation index 7\n", + "J=12;#from Bessel Table , for B=6\n", + "Bw=fm*J*2*10**(3);\n", + "print \"The Bandwidth (in Hz) is \",Bw" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.3 page.no: 289" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Peak Phase Deviation( in rad) 8.75\n" + ] + } + ], + "source": [ + "Dev_sen=3.5 # Deviation Sensitivity in rad/volt\n", + "a=2.5; #amplitude in volts\n", + "B=a*Dev_sen; # Peak Phase Deviation\n", + "print \"Peak Phase Deviation( in rad) \",B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.4.A page.no: 290" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Maximum Frequency Deviation (in Hz) is 18000\n", + "Modulation Index is 5.99985864877\n" + ] + } + ], + "source": [ + "from math import pi\n", + "\n", + "Wm=18850;#Angular Frequency of message signal\n", + "fm=Wm/(2*pi);\n", + "a=3;# amplitude of message signal\n", + "Dev_sen=6;#Deviation Sensitivity in kHz/V\n", + "Max_Freq_Dev=a*Dev_sen*10**(3);\n", + "B=Max_Freq_Dev/(fm);\n", + "print \"Maximum Frequency Deviation (in Hz) is \",Max_Freq_Dev\n", + "print \"Modulation Index is \",B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.4 page.no: 291" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Deviation Sensitivity(in kHz/V) 1333\n", + "Modulation Index is 4\n", + "Deviation Sensitivity for 5V (in Hz) 6665\n", + "Modulation index 6\n", + "Deviation Sensitivity for 10V (in Hz) 13330\n", + "Modulation index is 33\n" + ] + } + ], + "source": [ + "a=3; #amplitude in Volts\n", + "Dev=4;# Deviation in kHz\n", + "fm=1;# modulating frequency in kHz\n", + "Dev_sen=Dev*10**(3)/a; #Deviation Sensitivity\n", + "B=Dev/fm; # Modulation Index\n", + "print \"Deviation Sensitivity(in kHz/V) \",Dev_sen\n", + "print \"Modulation Index is \",B\n", + "#a)\n", + "a=5;\n", + "Dev_sen_1=a*Dev_sen;\n", + "B=Dev_sen_1/(fm*10**(3));\n", + "print \"Deviation Sensitivity for 5V (in Hz) \",Dev_sen_1\n", + "print \"Modulation index\",B\n", + "#b)\n", + "a=10;\n", + "fm=400;\n", + "Dev_sen_2=a*Dev_sen;\n", + "B=Dev_sen_2/fm;\n", + "print \"Deviation Sensitivity for 10V (in Hz) \",Dev_sen_2\n", + "print \"Modulation index is \",B" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.5.A page.no: 291" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "for B=2, The number of significant frequencies are 6\n", + "They are J1,J2,J3,J4,J5 and J6\n", + "Their amplitudes with carriers are \n", + "they are (in V) 1.792 4.616 2.824 1.032 0.272 0.056 0.008\n" + ] + } + ], + "source": [ + "print \"for B=2, The number of significant frequencies are 6\"\n", + "print \"They are J1,J2,J3,J4,J5 and J6\"\n", + "print \"Their amplitudes with carriers are \"\n", + "J0= 0.224*8;\n", + "J1= 0.577*8;\n", + "J2= 0.353*8;\n", + "J3= 0.129*8;\n", + "J4= 0.034*8;\n", + "J5= 0.007*8;\n", + "J6= 0.001*8;\n", + "print\"they are (in V)\",J0,J1,J2,J3,J4,J5,J6" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.5 page.no: 292" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Bandwidth required (in Hz) 24000\n", + "According to Carsons rule , Bandwidth (in Hz) 36000\n" + ] + } + ], + "source": [ + "fm=3; #Modulating Frequency in kHZ\n", + "Max_dev=15;# Maximum Deviatin in kHZ\n", + "B=Max_dev/fm; \n", + "J=8; # Bessel table , the highest J coefficient\n", + "BW=J*fm*10**(3);#Bandwidth in kHz\n", + "BW1=2*(fm+Max_dev)*10**(3);# According to carson rule , BAndwidth\n", + "print \"Bandwidth required (in Hz) \",BW\n", + "print \"According to Carsons rule , Bandwidth (in Hz) \",BW1" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.6.A page.no: 292" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Minimum Bandwidth (in Hz) is 72000\n", + "Approximate Minimum Bandwidth is 36000\n" + ] + } + ], + "source": [ + "Max_Freq_Dev=12; #Maximum Frequency Deviation in kHZ\n", + "fm=6; #Modulating frquency in kHz\n", + "B=Max_Freq_Dev/fm;# Modulation index 7\n", + "J=6;#From Bessel Table , for B=2\n", + "Bw=2*J*6*10**(3);\n", + "BW_carson=2*(fm + Max_Freq_Dev)*10**(3);\n", + "print \"Minimum Bandwidth (in Hz) is \",Bw\n", + "print \"Approximate Minimum Bandwidth is \",BW_carson" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.6.A page.no: 283" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "For B=5 from the Bessel table ,The Bessel Function is taken upto J9\n", + "Hence the average power of the modulated signal (in W) is 9.936\n", + "Hence, the average power of the modulated signal is equal to \n", + "unmodulated carrier power\n" + ] + } + ], + "source": [ + "a=10; #Amplitude in V\n", + "Pt=a*(0.18**2 +2*(0.33**2+0.05**2+0.36**2+0.39**2+0.26**2+0.13**2+0.05**2+0.02**2+0.01**2))\n", + "print \"For B=5 from the Bessel table ,The Bessel Function is taken upto J9\"\n", + "print \"Hence the average power of the modulated signal (in W) is \",Pt\n", + "print \"Hence, the average power of the modulated signal is equal to \"\n", + "print \"unmodulated carrier power\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.7.A page.no: 294" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Unmodulated Power Carrier ( in W) = 1\n", + "Total Power in modulated wave(in W)= 1.06767573333\n", + "Power in the modulated wave is equal to \n", + "power in the unmodulated wave \n" + ] + } + ], + "source": [ + "a=8;# amplitude in V\n", + "r=30; # resistance in ohms\n", + "Pc_unmodulated=a**2/(2*r);\n", + "Pt=1.792**2/(2*30)+2*(4.616)**2/(2*30)+2*(2.824**2)/(2*30) +2*(1.032) **2/(2*30) +2*(0.272) **2/(2*30) +2*(0.056)**2/(2*30)+2*(0.008)**2/(2*30);\n", + "# change in answer due to approximations in the book\n", + "print \"Unmodulated Power Carrier ( in W) = \",Pc_unmodulated\n", + "print \"Total Power in modulated wave(in W)= \",Pt\n", + "print \"Power in the modulated wave is equal to \"\n", + "print \"power in the unmodulated wave \" \n", + "#\"Small error due to rounded off values in Bessel functions\"" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.7 page.no: 295" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the Phase Modulation Function = 12.0*sin(3000.0*pi*t)\n", + "The Modulated Wave Function = 12.0*sin(3000.0*pi*t) + 8*cos(20000*pi*t)\n" + ] + } + ], + "source": [ + "from sympy import symbols,sin,cos\n", + "\n", + "t,pi=symbols('t,pi') \n", + "Pha_dev=3.; #Phase Deviation constant in rad/V 6\n", + "# Phase Modulation Function\n", + "Pha_function=Pha_dev*4*sin(2.*pi*1.5*10**3*t);\n", + "Mod_wave=8*cos(2*pi*10**4*t)+Pha_function\n", + "print \"the Phase Modulation Function = \",Pha_function\n", + "print \"The Modulated Wave Function = \",Mod_wave" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.8 page.no: 295" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The outputs of the balanced modulator for these parameters\n", + "are same as the inputs \n", + "They remain unaltered \n", + "At the output of the Multiplier , \n", + "Fc(in kHz)= 9600 , Fm(in kHz)= 10 , B= 6.0\n", + "Frequency Deviation ( in kHz)= 60\n" + ] + } + ], + "source": [ + "initial_Freq_Dev=5; # frequency in kHz\n", + "B_initial=0.5; #modulation index\n", + "fm_initial=10;# message signal frequency in kHz\n", + "fc_initial=800; # carrier frequency in kHz\n", + "print \"The outputs of the balanced modulator for these parameters\"\n", + "print \"are same as the inputs \"\n", + "print \"They remain unaltered \"\n", + "#at the output of the multiplier 14\n", + "m=12;# multiplication factor\n", + "final_Freq_Dev=initial_Freq_Dev*m;\n", + "B_final=0.5*m;\n", + "fm_final=10; #modulating signal remains unaltered\n", + "fc_final=800*m;\n", + "print \"At the output of the Multiplier , \"\n", + "print \"Fc(in kHz)= \",fc_final,\", Fm(in kHz)= \",fm_final,\", B= \",B_final\n", + "print \"Frequency Deviation ( in kHz)= \",final_Freq_Dev" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.9.A page.no: 296" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a) MAster Oscillator Centre Frequency(in MHz) = 4.008\n", + "b) Frequency Deviation at the output of modulator(in KHz)= 2.4\n", + "c)Devaition ratio at the output of modulator 0.24\n", + "d)deviation ratio at power amplifier 6.0\n" + ] + } + ], + "source": [ + "ft=100.2; #final carrier frequency in MHz\n", + "Freq_Dev_ft=60.;# Frequency Deviation in KHz at power amplifier\n", + "fm=10.;#modulating frequency in KHz\n", + "m=25.;#multiplication factor\n", + "#a)\n", + "fc=ft/25.;\n", + "#b)\n", + "Freq_Dev=Freq_Dev_ft/25;\n", + "#c)\n", + "B=Freq_Dev/fm;\n", + "#d)\n", + "Bt=B*m;\n", + "print \"a) MAster Oscillator Centre Frequency(in MHz) = \",fc\n", + "print \"b) Frequency Deviation at the output of modulator(in KHz)= \",Freq_Dev\n", + "print \"c)Devaition ratio at the output of modulator \",B\n", + "print \"d)deviation ratio at power amplifier\",Bt" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Exa 4.10.A page.no: 297" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "a) Frequency Deviation(in Hz)= 5954.92965855\n", + "b) Devaition Ratio= 5.95492965855\n", + "c) Phase Deviation( in rad)= 8\n", + "d) Bandwidth( in Hz)= 13909.8593171\n" + ] + } + ], + "source": [ + "from math import pi\n", + "\n", + "#f(t)=5cos(Wc∗t+3sin(2000∗t)+5sin(2000∗pi∗t)) 5\n", + "fm=2000*pi/(2*pi); #bandwidth is the highest frequency component\n", + "#a) \n", + "Freq_dev=(6000+10000*pi)/(2*pi); 11\n", + "#b)\n", + "B=Freq_dev/fm; \n", + "#c)\n", + "Phase_dev=8;#Highest value of[3sin(2000t)+5sin(2000∗ pi∗t)]\n", + "#d)\n", + "Bw= 2*(fm+Freq_dev);\n", + "print \"a) Frequency Deviation(in Hz)= \",Freq_dev\n", + "print \"b) Devaition Ratio= \",B\n", + "print \"c) Phase Deviation( in rad)= \",Phase_dev\n", + "print \"d) Bandwidth( in Hz)= \",Bw" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/hemanth/Untitled1.ipynb b/sample_notebooks/hemanth/Untitled1.ipynb deleted file mode 100755 index 9684d917..00000000 --- a/sample_notebooks/hemanth/Untitled1.ipynb +++ /dev/null @@ -1,27 +0,0 @@ - -# coding: utf-8 - -# # UNIT 3 : ELECTRICAL CONDUCTIVITY IN METALS - -# -# -# # Example number 1 , page number 208 - -# In[ ]: - -#importing module -from __future__ import division -import math - - -#Variable declaration -u= 7*10**-3 # mobility of an electron -E= 100 # applied field - - -#Calculations -Vd=u*E - -#Result -print"the drift velocity = %.1f m/s" %Vd -print"the correct choice is B" diff --git a/sample_notebooks/hemanth/hemanth_version_backup/Untitled1.ipynb b/sample_notebooks/hemanth/hemanth_version_backup/Untitled1.ipynb new file mode 100755 index 00000000..9684d917 --- /dev/null +++ b/sample_notebooks/hemanth/hemanth_version_backup/Untitled1.ipynb @@ -0,0 +1,27 @@ + +# coding: utf-8 + +# # UNIT 3 : ELECTRICAL CONDUCTIVITY IN METALS + +# +# +# # Example number 1 , page number 208 + +# In[ ]: + +#importing module +from __future__ import division +import math + + +#Variable declaration +u= 7*10**-3 # mobility of an electron +E= 100 # applied field + + +#Calculations +Vd=u*E + +#Result +print"the drift velocity = %.1f m/s" %Vd +print"the correct choice is B" diff --git a/sample_notebooks/karansingh/Thyristors_Principles_&.ipynb b/sample_notebooks/karansingh/Thyristors_Principles_&.ipynb new file mode 100755 index 00000000..4e252985 --- /dev/null +++ b/sample_notebooks/karansingh/Thyristors_Principles_&.ipynb @@ -0,0 +1,209 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:4abf44c9c11389b267bffebabb50666e37ae7ef97c6e1f36ae4dc72c5936a6d7" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Thyristors Principles & Characeristics" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1_1 - page : 5" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "alfa1=0.35 \n", + "alfa2=0.4 \n", + "IG=40*10**-3 #A\n", + "#Solution :\n", + "IA=alfa2*IG/(1-(alfa1+alfa2)) #A\n", + "print \"Anode current is %0.3f A\" %IA" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Anode current is 0.064 A\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1_2 - page : 7" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "dv_dt=190 #V/\u00b5s\n", + "IC=8*10**-3 #A\n", + "#Solution :\n", + "C=IC/(dv_dt/10**-6) #F\n", + "print \"Capacitance of depletion layer is %0.1E F : \" %C" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Capacitance of depletion layer is 4.2E-11 F : \n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1_3 - page : 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "RG=2000 #ohm\n", + "VCC=20 #V\n", + "VT=0.75 #V\n", + "Vthy=0.7 #V(Voltage across thyristor)\n", + "R=200 #ohm\n", + "IT=7*10**-3 #A\n", + "Ih=5*10**-3 #A\n", + "#Solution :\n", + "#part (a)\n", + "Vo=VCC #V##thyristor not conducting\n", + "print \"(a) When thyristor is in off state, Output voltage is %0.2f V\" %Vo\n", + "#part (b)\n", + "Vs=VT+IT*RG #V\n", + "print \"(b) Voltage necessary to turn on the thyristor is %0.2f V\" %Vs\n", + "#part (c)\n", + "VR1=Ih*R #V\n", + "print \"(c) Current through thyristor should be less than holding current. Voltage should be reduced to less than %0.2f V\" %VR1\n", + "#part (d)\n", + "VR2=VR1+Vthy #V\n", + "print \"(d) VCC should be reduced to less than %0.2f V\" %VR2" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) When thyristor is in off state, Output voltage is 20.00 V\n", + "(b) Voltage necessary to turn on the thyristor is 14.75 V\n", + "(c) Current through thyristor should be less than holding current. Voltage should be reduced to less than 1.00 V\n", + "(d) VCC should be reduced to less than 1.70 V\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1_5 - page : 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given data\n", + "Vdc=100 #V\n", + "L=10 #H\n", + "i=80*10**-3 #A\n", + "#Solution :\n", + "t=i*L/Vdc #s\n", + "t*=1000 # ms\n", + "print \"Width of pulse should be more than %0.1f milli-seconds.\" %t" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Width of pulse should be more than 8.0 milli-seconds.\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1_6 - page : 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#Given data\n", + "Vdc=100 #V\n", + "R=10 #ohm\n", + "L=5 #H\n", + "i=50*10**-3 #A\n", + "#Solution :\n", + "#i=Vdc/R*(1-exp(-R*t/L))\n", + "t=-math.log(1-i/Vdc*R)/R*L #s\n", + "t*=1000 #ms\n", + "print \"Minimum width of gate pulse is %0.1f milli-seconds.\" %t\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Minimum width of gate pulse is 2.5 milli-seconds.\n" + ] + } + ], + "prompt_number": 14 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/karansingh/Thyristors_Principles_&_Characeristics.ipynb b/sample_notebooks/karansingh/Thyristors_Principles_&_Characeristics.ipynb deleted file mode 100755 index 4e252985..00000000 --- a/sample_notebooks/karansingh/Thyristors_Principles_&_Characeristics.ipynb +++ /dev/null @@ -1,209 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:4abf44c9c11389b267bffebabb50666e37ae7ef97c6e1f36ae4dc72c5936a6d7" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Thyristors Principles & Characeristics" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1_1 - page : 5" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given data\n", - "alfa1=0.35 \n", - "alfa2=0.4 \n", - "IG=40*10**-3 #A\n", - "#Solution :\n", - "IA=alfa2*IG/(1-(alfa1+alfa2)) #A\n", - "print \"Anode current is %0.3f A\" %IA" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Anode current is 0.064 A\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1_2 - page : 7" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given data\n", - "dv_dt=190 #V/\u00b5s\n", - "IC=8*10**-3 #A\n", - "#Solution :\n", - "C=IC/(dv_dt/10**-6) #F\n", - "print \"Capacitance of depletion layer is %0.1E F : \" %C" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Capacitance of depletion layer is 4.2E-11 F : \n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1_3 - page : 8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given data\n", - "RG=2000 #ohm\n", - "VCC=20 #V\n", - "VT=0.75 #V\n", - "Vthy=0.7 #V(Voltage across thyristor)\n", - "R=200 #ohm\n", - "IT=7*10**-3 #A\n", - "Ih=5*10**-3 #A\n", - "#Solution :\n", - "#part (a)\n", - "Vo=VCC #V##thyristor not conducting\n", - "print \"(a) When thyristor is in off state, Output voltage is %0.2f V\" %Vo\n", - "#part (b)\n", - "Vs=VT+IT*RG #V\n", - "print \"(b) Voltage necessary to turn on the thyristor is %0.2f V\" %Vs\n", - "#part (c)\n", - "VR1=Ih*R #V\n", - "print \"(c) Current through thyristor should be less than holding current. Voltage should be reduced to less than %0.2f V\" %VR1\n", - "#part (d)\n", - "VR2=VR1+Vthy #V\n", - "print \"(d) VCC should be reduced to less than %0.2f V\" %VR2" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) When thyristor is in off state, Output voltage is 20.00 V\n", - "(b) Voltage necessary to turn on the thyristor is 14.75 V\n", - "(c) Current through thyristor should be less than holding current. Voltage should be reduced to less than 1.00 V\n", - "(d) VCC should be reduced to less than 1.70 V\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1_5 - page : 8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given data\n", - "Vdc=100 #V\n", - "L=10 #H\n", - "i=80*10**-3 #A\n", - "#Solution :\n", - "t=i*L/Vdc #s\n", - "t*=1000 # ms\n", - "print \"Width of pulse should be more than %0.1f milli-seconds.\" %t" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Width of pulse should be more than 8.0 milli-seconds.\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1_6 - page : 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#Given data\n", - "Vdc=100 #V\n", - "R=10 #ohm\n", - "L=5 #H\n", - "i=50*10**-3 #A\n", - "#Solution :\n", - "#i=Vdc/R*(1-exp(-R*t/L))\n", - "t=-math.log(1-i/Vdc*R)/R*L #s\n", - "t*=1000 #ms\n", - "print \"Minimum width of gate pulse is %0.1f milli-seconds.\" %t\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Minimum width of gate pulse is 2.5 milli-seconds.\n" - ] - } - ], - "prompt_number": 14 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/kartiksankhla/Chapter2.ipynb b/sample_notebooks/kartiksankhla/Chapter2.ipynb old mode 100755 new mode 100644 index 21f2d4c4..f12ee152 --- a/sample_notebooks/kartiksankhla/Chapter2.ipynb +++ b/sample_notebooks/kartiksankhla/Chapter2.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:e984fee9b841dd6e9b7eedf1533b0a0d297cd9f484c047f051ce48a09b156826" + "signature": "sha256:44c6b2962e60454059ed8ab0f850fa5cf7fde8b83f0146551b8d869bf0ff197f" }, "nbformat": 3, "nbformat_minor": 0, @@ -13,7 +13,9 @@ "level": 1, "metadata": {}, "source": [ - "Chapter2-Nuclear Engineering" + "Chapter2-Basic Thermodynamics, Fluid\n", + "Mechanics: Definitions\n", + "of Efficiency" ] }, { @@ -21,25 +23,32 @@ "level": 2, "metadata": {}, "source": [ - "Ex1-pg54" + "Ex1-pg39" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "## Example 2.1\n", "import math\n", - "#determine atoms in deuterium\n", - "## Given data\n", - "atom_h = 6.6*10**24; ## Number of atoms in Hydrogen\n", - "## Using the data given in Table II.2, Appendix II for isotropic abundance of deuterium\n", - "isoab_H2 = 0.015; ## Isotropic abundance of deuterium\n", - "## Calculation\n", - "totatom_d=(isoab_H2*atom_h)/100.;\n", - "## Result\n", - "print\"%s %.2e %s \"%('\\n Number of deuterium atoms = ',totatom_d,'');\n", - "\n" + "#calculate the polyefficency and overall total to total efficiency\n", + "\n", + "##given data\n", + "gamma = 1.4;\n", + "pi = 8.;##pressure ratio\n", + "T01 = 300.;##inlet temperature in K\n", + "T02 = 586.4;##outlet temperature in K\n", + "\n", + "##Calculations\n", + "##Calculation of Overall Total to Total efficiency\n", + "Tot_eff = ((pi**((gamma-1.)/gamma))-1.)/((T02/T01)-1.);\n", + "\n", + "##Calculation of polytropic efficiency\n", + "Poly_eff = ((gamma-1.)/gamma)*((math.log(pi))/math.log(T02/T01));\n", + "\n", + "##Results\n", + "print'%s %.2f %s'%('The Overall total-to-total efficiency is ',Tot_eff,'');\n", + "print'%s %.2f %s'%('The polytropic efficiency is ',Poly_eff,'');\n" ], "language": "python", "metadata": {}, @@ -48,41 +57,42 @@ "output_type": "stream", "stream": "stdout", "text": [ - "\n", - " Number of deuterium atoms = 9.90e+20 \n" + "The Overall total-to-total efficiency is 0.85 \n", + "The polytropic efficiency is 0.89 \n" ] } ], - "prompt_number": 5 + "prompt_number": 1 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Ex2-pg54" + "Ex2-pg44" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "## Example 2.2\n", "import math\n", - "#determine atomic weight of oxygen\n", - "## Given data \n", - "## Using the data given in the example 2.2\n", - "atwt_O16 = 15.99492; ## Atomic weight of O-16 isotope\n", - "isoab_O16 = 99.759; ## Abundance of O-16 isotope\n", - "atwt_O17 = 16.99913; ## Atomic weight of O-17 isotope\n", - "isoab_O17 = 0.037; ## Abundance of O-17 isotope\n", - "atwt_O18 = 17.99916; ## Atomic weight of O-18 isotope\n", - "isoab_O18 = 0.204; ## Abundance of O-18 isotope\n", - "## Calculation\n", - "atwt_O=(isoab_O16*atwt_O16 + isoab_O17*atwt_O17 + isoab_O18*atwt_O18)/100.;\n", - "## Result\n", - "print\"%s %.2f %s \"%('\\n Atomic Weight of Oxygen = ',atwt_O,'');\n", - "\n" + "#calculate the\n", + "\n", + "##given data\n", + "T01 = 1200.;##Stagnation temperature at which gas enters in K\n", + "p01 = 4.;##Stagnation pressure at which gas enters in bar\n", + "c2 = 572.;##exit velocity in m/s\n", + "p2 = 2.36;##exit pressure in bar\n", + "Cp = 1.160*1000.;##in J/kgK\n", + "gamma = 1.33\n", + "\n", + "##calculations\n", + "T2 = T01 - 0.5*(c2**2)/Cp;##Calculation of exit temperature in K\n", + "Noz_eff = ((1.-(T2/T01))/(1.-(p2/p01)**((gamma-1.)/gamma)));##Nozzle efficiency\n", + "\n", + "##Results\n", + "print'%s %.2f %s'%('Nozzle efficiency is ',Noz_eff,'');\n" ], "language": "python", "metadata": {}, @@ -91,8 +101,7 @@ "output_type": "stream", "stream": "stdout", "text": [ - "\n", - " Atomic Weight of Oxygen = 16.00 \n" + "Nozzle efficiency is 0.96 \n" ] } ], @@ -103,31 +112,31 @@ "level": 2, "metadata": {}, "source": [ - "Ex3-pg55" + "Ex3-pg51" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "## Example 2.3\n", "import math\n", - "#determine rest mass energy of electron\n", - "## Given data\n", - "me = 9.1095*10**(-28); ## Mass of electron in grams\n", - "c = 2.9979*10**10; ## Speed of light in vacuum in cm/sec\n", - "## Calculation\n", - "rest_mass = me*c**2;\n", - "## Result\n", - "print\"%s %.2e %s \"%('\\n Rest mass energy of electron = ',rest_mass,' ergs\\n');\n", - "print('Expressing the result in joules')\n", - "## 1 Joule = 10^(-7)ergs\n", - "rest_mass_j = rest_mass*10**(-7);\n", - "print\"%s %.2e %s \"%('\\n Rest mass energy of electron = ',rest_mass_j,' joules\\n');\n", - "print('Expressing the result in MeV')\n", - "## 1 MeV = 1.6022*10^(-13)joules\n", - "rest_mass_mev = rest_mass_j/(1.6022*10**(-13));\n", - "print\"%s %.2f %s \"%('\\n Rest mass energy of electron = ',rest_mass_mev,' MeV\\n');\n" + "#calculate the\n", + "\n", + "##given data\n", + "cp = 0.6;##coefficient of pressure\n", + "AR = 2.13;##Area ratio\n", + "N_R1 = 4.66;\n", + "\n", + "##calculations\n", + "cpi = 1. - (1./(AR**2));\n", + "Diff_eff = cp/cpi;##diffuser efficiency\n", + "theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n", + "\n", + "##Results\n", + "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n", + "print'%s %.2f %s'%('The included cone angle can be found = ',theta,' deg.');\n", + "\n", + "\n" ], "language": "python", "metadata": {}, @@ -136,21 +145,103 @@ "output_type": "stream", "stream": "stdout", "text": [ + "cpi = \n", + " 0.78 \n", + "The included cone angle can be found = 11.26 deg.\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex4-pg52" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#calculate the\n", + "\n", + "##given data\n", + "AR = 1.8;##Area ratio\n", + "cp = 0.6;##coefficient of pressure\n", + "N_R1 = 7.85;\n", + "\n", + "##calculations\n", + "Theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n", + "cpi = 1.-(1./(AR**2));\n", + "Diff_eff = cp/cpi;##diffuser efficeincy\n", + "\n", + "##Results\n", + "print'%s %.2f %s'%('The included cone angle can be found = ',Theta,' deg.\\n');\n", + "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n", + "print'%s %.2f %s'%('Diffuser efficiency = ',Diff_eff,'');\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The included cone angle can be found = 4.98 deg.\n", "\n", - " Rest mass energy of electron = 8.19e-07 ergs\n", - " \n", - "Expressing the result in joules\n", - "\n", - " Rest mass energy of electron = 8.19e-14 joules\n", - " \n", - "Expressing the result in MeV\n", - "\n", - " Rest mass energy of electron = 0.51 MeV\n", - " \n" + "cpi = \n", + " 0.69 \n", + "Diffuser efficiency = 0.87 \n" ] } ], "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Ex5-pg53" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "#calculate the\n", + "\n", + "##given data\n", + "AR = 2.0;##Area ratio\n", + "alpha1 = 1.059;\n", + "B1 = 0.109;\n", + "alpha2 = 1.543;\n", + "B2 = 0.364;\n", + "cp = 0.577;##coefficient of pressure\n", + "\n", + "##calculations\n", + "cp = (alpha1 - (alpha2/(AR**2))) - 0.09;\n", + "Diff_eff = cp/(1.-(1./(AR**2)));##Diffuser efficiency\n", + "\n", + "##Results\n", + "print'%s %.2f %s'%('The diffuser efficiency = ',Diff_eff,'');\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The diffuser efficiency = 0.78 \n" + ] + } + ], + "prompt_number": 5 } ], "metadata": {} diff --git a/sample_notebooks/kartiksankhla/Chapter2_WEIco2c.ipynb b/sample_notebooks/kartiksankhla/Chapter2_WEIco2c.ipynb deleted file mode 100644 index f12ee152..00000000 --- a/sample_notebooks/kartiksankhla/Chapter2_WEIco2c.ipynb +++ /dev/null @@ -1,250 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:44c6b2962e60454059ed8ab0f850fa5cf7fde8b83f0146551b8d869bf0ff197f" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter2-Basic Thermodynamics, Fluid\n", - "Mechanics: Definitions\n", - "of Efficiency" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex1-pg39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#calculate the polyefficency and overall total to total efficiency\n", - "\n", - "##given data\n", - "gamma = 1.4;\n", - "pi = 8.;##pressure ratio\n", - "T01 = 300.;##inlet temperature in K\n", - "T02 = 586.4;##outlet temperature in K\n", - "\n", - "##Calculations\n", - "##Calculation of Overall Total to Total efficiency\n", - "Tot_eff = ((pi**((gamma-1.)/gamma))-1.)/((T02/T01)-1.);\n", - "\n", - "##Calculation of polytropic efficiency\n", - "Poly_eff = ((gamma-1.)/gamma)*((math.log(pi))/math.log(T02/T01));\n", - "\n", - "##Results\n", - "print'%s %.2f %s'%('The Overall total-to-total efficiency is ',Tot_eff,'');\n", - "print'%s %.2f %s'%('The polytropic efficiency is ',Poly_eff,'');\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The Overall total-to-total efficiency is 0.85 \n", - "The polytropic efficiency is 0.89 \n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2-pg44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#calculate the\n", - "\n", - "##given data\n", - "T01 = 1200.;##Stagnation temperature at which gas enters in K\n", - "p01 = 4.;##Stagnation pressure at which gas enters in bar\n", - "c2 = 572.;##exit velocity in m/s\n", - "p2 = 2.36;##exit pressure in bar\n", - "Cp = 1.160*1000.;##in J/kgK\n", - "gamma = 1.33\n", - "\n", - "##calculations\n", - "T2 = T01 - 0.5*(c2**2)/Cp;##Calculation of exit temperature in K\n", - "Noz_eff = ((1.-(T2/T01))/(1.-(p2/p01)**((gamma-1.)/gamma)));##Nozzle efficiency\n", - "\n", - "##Results\n", - "print'%s %.2f %s'%('Nozzle efficiency is ',Noz_eff,'');\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Nozzle efficiency is 0.96 \n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex3-pg51" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#calculate the\n", - "\n", - "##given data\n", - "cp = 0.6;##coefficient of pressure\n", - "AR = 2.13;##Area ratio\n", - "N_R1 = 4.66;\n", - "\n", - "##calculations\n", - "cpi = 1. - (1./(AR**2));\n", - "Diff_eff = cp/cpi;##diffuser efficiency\n", - "theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n", - "\n", - "##Results\n", - "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n", - "print'%s %.2f %s'%('The included cone angle can be found = ',theta,' deg.');\n", - "\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "cpi = \n", - " 0.78 \n", - "The included cone angle can be found = 11.26 deg.\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex4-pg52" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#calculate the\n", - "\n", - "##given data\n", - "AR = 1.8;##Area ratio\n", - "cp = 0.6;##coefficient of pressure\n", - "N_R1 = 7.85;\n", - "\n", - "##calculations\n", - "Theta = 2.*(180./math.pi)*math.atan((AR**0.5 - 1.)/(N_R1));##included cone angle\n", - "cpi = 1.-(1./(AR**2));\n", - "Diff_eff = cp/cpi;##diffuser efficeincy\n", - "\n", - "##Results\n", - "print'%s %.2f %s'%('The included cone angle can be found = ',Theta,' deg.\\n');\n", - "print'%s %.2f %s'%('cpi = \\n',cpi,'');\n", - "print'%s %.2f %s'%('Diffuser efficiency = ',Diff_eff,'');\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The included cone angle can be found = 4.98 deg.\n", - "\n", - "cpi = \n", - " 0.69 \n", - "Diffuser efficiency = 0.87 \n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex5-pg53" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "#calculate the\n", - "\n", - "##given data\n", - "AR = 2.0;##Area ratio\n", - "alpha1 = 1.059;\n", - "B1 = 0.109;\n", - "alpha2 = 1.543;\n", - "B2 = 0.364;\n", - "cp = 0.577;##coefficient of pressure\n", - "\n", - "##calculations\n", - "cp = (alpha1 - (alpha2/(AR**2))) - 0.09;\n", - "Diff_eff = cp/(1.-(1./(AR**2)));##Diffuser efficiency\n", - "\n", - "##Results\n", - "print'%s %.2f %s'%('The diffuser efficiency = ',Diff_eff,'');\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The diffuser efficiency = 0.78 \n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/keerthi vanigundla/R.K.RAJPUTCHAPTER_12.ipynb b/sample_notebooks/keerthi vanigundla/R.K.RAJPUTCHAPTER_12.ipynb deleted file mode 100755 index b7f5147f..00000000 --- a/sample_notebooks/keerthi vanigundla/R.K.RAJPUTCHAPTER_12.ipynb +++ /dev/null @@ -1,292 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 12:Measurement of Non-Electrical Quantities" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 12.1,Page No:600" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": false - }, - "outputs": [], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "Gf = 2; #guage factor \n", - "a = 100*10**6; #stress in N/m**2\n", - "E = 200*10**9; #elasticity of steel in N/m**2\n", - "\n", - "#calculation\n", - "st = (a/float(E)); #strain\n", - "x = Gf*st; # change in guage resistance\n", - "p = (x)*100; #percentage change in resistance in %\n", - "\n", - "#result\n", - "print\"percentage change in resistance %1.1f\"%p,\"%\";\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 12.4,Page No:631" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "water flow rate 0.0586 m**3/s\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "D1 = 200*10**-3; # inlet horizontal venturimeter in m\n", - "D2 = 100*10**-3; #throat horizontal enturimeter in m\n", - "h = 220*10**-3; #pressure in m\n", - "Cd = 0.98; #coefficient of discharge \n", - "phg = 13.6; #specific gravity of mercury\n", - "p = 1000; #density of water in kg/m**3\n", - "g = 9.81; #gravitational constant\n", - "pw = 1; #density of water in kg/m**3\n", - "w = 9.81; \n", - "\n", - "\n", - "\n", - "#calculation\n", - "x = (g)*(h)*(phg-pw)*1000; #differential pressure head in N/m**2\n", - "a = 1-((D2/float(D1))**4); #velocity approach factor\n", - "M = 1/(float(math.sqrt(a))); #velocity of approach\n", - "b = math.sqrt(((2*g)/(float(w*p)))*x);\n", - "A2 = (math.pi/float(4))*((D2)**2); #area in m**2\n", - "Q = Cd*M*A2*(b); #discharge through venturimeter in m**3/s\n", - " \n", - "#result\n", - "print'water flow rate %3.4f'%Q,'m**3/s'; \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 12.5,Page No:631" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "rate of flow of oil 0.137850 m**3/s\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "D1 = 400*10**-3; #diameter at inlet in m\n", - "D2 = 200*10**-3; #diameter at throat in m\n", - "y = 50*10**-3; #reading of differential manometer in m\n", - "Shl = 13.6; #specific gravity of mercury in U-tube \n", - "Sp = 0.7; #specific gravity of oil in U-tube \n", - "h = 0.92;\n", - "\n", - "#bernoulli's equation\n", - "#p1/w +z1+V1**2=p2/w +z2+V2**2\n", - "#solving we get h+(V1**2/2*g)-(V2**2/2*g)=0\n", - "# calculations\n", - "\n", - "A1 = (math.pi/float(4))*(D1**2); #area in m**2\n", - "A2 = (math.pi/4)*(D2**2); #area in m**2\n", - "a = A2/float(A1); #ratio of areas\n", - "#V1 = a*V2;\n", - "#h+(V1**2/2*g)*(1-(1/4))=0\n", - "V2 = math.sqrt((2*g*h)/(float(1-((a)**2)))); \n", - "Q = A2*V2; #rate of oil flow in m**3/s\n", - "\n", - "#result\n", - "print'rate of flow of oil %f'%Q,'m**3/s';\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 12.6,Page No:633" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "difference in pressure head 4952.073 N/m**2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "Q = 0.015; #rate of flow in m**3/s\n", - "D0 = 100*10**-3; #diameter orifice in m\n", - "D1 = 200*10**-3; #diameter of pipe in m\n", - "Cc = 0.6; #coefficient of contraction\n", - "Cd = 0.6; #coefficient of discharge\n", - "E = 1; #thermal expansion factor\n", - "g = 9.81; #gravitational constant \n", - "w = 9810;\n", - "\n", - "#calculations\n", - "A0 = ((math.pi)/float(4))*(D0**2); #area in m**2\n", - "A1 = ((math.pi)/float(4))*(D1**2); #area in m**2\n", - "a = (Cc*A0)/(float(A1)); \n", - "M = math.sqrt(1-((a)**2));\n", - "K = Cd/float(M);\n", - "x = ((Q/float(K*E*A0))**2);\n", - "dp = (x*w/float(2*g)); #difference in pressure head in N/m**2\n", - "\n", - "#result\n", - "print'difference in pressure head %3.3f'%dp,'N/m**2';\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example:12.7,Page No:633" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "discharge through the orifice 0.742 m**3/s\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "C0 = 0.6; #coefficient of orifice\n", - "Cv = 0.97; #coefficient of discharge\n", - "Qv = 1.2; #flow rate in m**3/s\n", - "\n", - "#calculations\n", - "Q0 = (C0/Cv)*Qv; #discharge through the orifice in m**3/s\n", - "\n", - "#result\n", - "print'discharge through the orifice %3.3f'%Q0,'m**3/s'\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example:12.8,Page No:634" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "velocity of submarine 25.0 km/h\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "Shl = 13.6; #specific gravity of mercury\n", - "Sl = 1.025; #specific gravity of sea water\n", - "y = 200*10**-3; #reading in m\n", - "g = 9.81; #constant\n", - "\n", - "#calculation\n", - "x = Shl/float(Sl);\n", - "h = (y*((x)-1)); #head\n", - "V = math.sqrt(2*g*h); #velocity of submarine in km/h\n", - "\n", - "#result\n", - "print'velocity of submarine %3.1f'%(V*(18/float(5))),'km/h';" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/R.K.RAJPUTCHAPTER_12.ipynb b/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/R.K.RAJPUTCHAPTER_12.ipynb new file mode 100755 index 00000000..b7f5147f --- /dev/null +++ b/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/R.K.RAJPUTCHAPTER_12.ipynb @@ -0,0 +1,292 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 12:Measurement of Non-Electrical Quantities" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.1,Page No:600" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "Gf = 2; #guage factor \n", + "a = 100*10**6; #stress in N/m**2\n", + "E = 200*10**9; #elasticity of steel in N/m**2\n", + "\n", + "#calculation\n", + "st = (a/float(E)); #strain\n", + "x = Gf*st; # change in guage resistance\n", + "p = (x)*100; #percentage change in resistance in %\n", + "\n", + "#result\n", + "print\"percentage change in resistance %1.1f\"%p,\"%\";\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.4,Page No:631" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "water flow rate 0.0586 m**3/s\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "D1 = 200*10**-3; # inlet horizontal venturimeter in m\n", + "D2 = 100*10**-3; #throat horizontal enturimeter in m\n", + "h = 220*10**-3; #pressure in m\n", + "Cd = 0.98; #coefficient of discharge \n", + "phg = 13.6; #specific gravity of mercury\n", + "p = 1000; #density of water in kg/m**3\n", + "g = 9.81; #gravitational constant\n", + "pw = 1; #density of water in kg/m**3\n", + "w = 9.81; \n", + "\n", + "\n", + "\n", + "#calculation\n", + "x = (g)*(h)*(phg-pw)*1000; #differential pressure head in N/m**2\n", + "a = 1-((D2/float(D1))**4); #velocity approach factor\n", + "M = 1/(float(math.sqrt(a))); #velocity of approach\n", + "b = math.sqrt(((2*g)/(float(w*p)))*x);\n", + "A2 = (math.pi/float(4))*((D2)**2); #area in m**2\n", + "Q = Cd*M*A2*(b); #discharge through venturimeter in m**3/s\n", + " \n", + "#result\n", + "print'water flow rate %3.4f'%Q,'m**3/s'; \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.5,Page No:631" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "rate of flow of oil 0.137850 m**3/s\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "D1 = 400*10**-3; #diameter at inlet in m\n", + "D2 = 200*10**-3; #diameter at throat in m\n", + "y = 50*10**-3; #reading of differential manometer in m\n", + "Shl = 13.6; #specific gravity of mercury in U-tube \n", + "Sp = 0.7; #specific gravity of oil in U-tube \n", + "h = 0.92;\n", + "\n", + "#bernoulli's equation\n", + "#p1/w +z1+V1**2=p2/w +z2+V2**2\n", + "#solving we get h+(V1**2/2*g)-(V2**2/2*g)=0\n", + "# calculations\n", + "\n", + "A1 = (math.pi/float(4))*(D1**2); #area in m**2\n", + "A2 = (math.pi/4)*(D2**2); #area in m**2\n", + "a = A2/float(A1); #ratio of areas\n", + "#V1 = a*V2;\n", + "#h+(V1**2/2*g)*(1-(1/4))=0\n", + "V2 = math.sqrt((2*g*h)/(float(1-((a)**2)))); \n", + "Q = A2*V2; #rate of oil flow in m**3/s\n", + "\n", + "#result\n", + "print'rate of flow of oil %f'%Q,'m**3/s';\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 12.6,Page No:633" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "difference in pressure head 4952.073 N/m**2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "Q = 0.015; #rate of flow in m**3/s\n", + "D0 = 100*10**-3; #diameter orifice in m\n", + "D1 = 200*10**-3; #diameter of pipe in m\n", + "Cc = 0.6; #coefficient of contraction\n", + "Cd = 0.6; #coefficient of discharge\n", + "E = 1; #thermal expansion factor\n", + "g = 9.81; #gravitational constant \n", + "w = 9810;\n", + "\n", + "#calculations\n", + "A0 = ((math.pi)/float(4))*(D0**2); #area in m**2\n", + "A1 = ((math.pi)/float(4))*(D1**2); #area in m**2\n", + "a = (Cc*A0)/(float(A1)); \n", + "M = math.sqrt(1-((a)**2));\n", + "K = Cd/float(M);\n", + "x = ((Q/float(K*E*A0))**2);\n", + "dp = (x*w/float(2*g)); #difference in pressure head in N/m**2\n", + "\n", + "#result\n", + "print'difference in pressure head %3.3f'%dp,'N/m**2';\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example:12.7,Page No:633" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "discharge through the orifice 0.742 m**3/s\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "C0 = 0.6; #coefficient of orifice\n", + "Cv = 0.97; #coefficient of discharge\n", + "Qv = 1.2; #flow rate in m**3/s\n", + "\n", + "#calculations\n", + "Q0 = (C0/Cv)*Qv; #discharge through the orifice in m**3/s\n", + "\n", + "#result\n", + "print'discharge through the orifice %3.3f'%Q0,'m**3/s'\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example:12.8,Page No:634" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "velocity of submarine 25.0 km/h\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "Shl = 13.6; #specific gravity of mercury\n", + "Sl = 1.025; #specific gravity of sea water\n", + "y = 200*10**-3; #reading in m\n", + "g = 9.81; #constant\n", + "\n", + "#calculation\n", + "x = Shl/float(Sl);\n", + "h = (y*((x)-1)); #head\n", + "V = math.sqrt(2*g*h); #velocity of submarine in km/h\n", + "\n", + "#result\n", + "print'velocity of submarine %3.1f'%(V*(18/float(5))),'km/h';" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/r.k.shukla.ipynb b/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/r.k.shukla.ipynb new file mode 100755 index 00000000..19a84998 --- /dev/null +++ b/sample_notebooks/keerthi vanigundla/keerthi vanigundla_version_backup/r.k.shukla.ipynb @@ -0,0 +1,379 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4:Behaviour of Dielectric Materials in ac and dc Fields" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.1,Page No:4.8" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dielectric constant of argon = 1.0005466\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "alpha = 1.8*10**-40; #polarisability of argon in Fm**2\n", + "e0 = 8.85*10**-12; #dielectric constant F/m\n", + "N1 = 6.02*10**23; #avagadro number in mol**-1\n", + "x = 22.4*10**3; #volume in m^3\n", + " \n", + "#formula\n", + "#er-1=N*p/e0*E=(N/e0)*alpha\n", + "#calculation\n", + "N = N1/float(x); #number of argon atoms in per unit volume in cm**3\n", + "N2 = N*10**6; #number of argon atoms in per unit volume in m**3\n", + "er = 1+((N2/float(e0)))*(alpha); #dielectric constant F/m\n", + "\n", + "\n", + "#result\n", + "print'dielectric constant of argon = %3.7f'%er;" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.2,Page No:4.9" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "displacement = 1.25e-17 m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "alpha = 1.8*10**-40; #polarisability of argon in F*m^2\n", + "E = 2*10**5; # in V/m\n", + "z = 18;\n", + "e = 1.6*10**-19;\n", + " \n", + " \n", + "#formula\n", + "#p=18*e*x\n", + "#calculation\n", + "p = alpha*E;\n", + "x = p/float(18*e); #shift of electron in m\n", + "\n", + " \n", + "#result\n", + "print'displacement = %3.2e'%x,'m';" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.3,Page No:4.9" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "local field of benzene=4.40e+03 V/m\n", + "local field of water=-1.57e+06 V/m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "E0 = 300*10**2; #local field in V/m\n", + "P1 = 3.398*10**-7; #dipole moment Coulomb/m\n", + "P2 = 2.124*10**-5; #dipole moment Coulomb/m\n", + "e0 = 8.85*10**-12; #permittivity in F/m\n", + " \n", + " \n", + "#formula\n", + "#E10Ci=E0-(2*Pi/3*e0)\n", + "#calculation\n", + "E10C1 = E0-((2*P1)/float(3*e0)); #local field of benzene in V/m\n", + "E10C2 = E0-((2*P2)/float(3*e0)); #local field of water in V/m\n", + " \n", + "#result\n", + "print'local field of benzene=%3.2e'%E10C1,'V/m';\n", + "print'local field of water=%3.2e'%E10C2,'V/m';" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.4,Page No:4.9" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "# import math\n", + "\n", + "#variable declaration\n", + "p1 = 5.12*10**-34; #p of benzene kg/m**3\n", + "p2 = 6.34*10**-34; #p of water kg/m**3\n", + "e10C1 = 4.4*10**3; #local field of benzene in V/m\n", + "e10C2 = 1570*10**3; #local field of water in V/m\n", + " \n", + " \n", + "#formula\n", + "#p=alphai*e10Ci\n", + "#calculation\n", + "alpha1 = p1/float(e10C1); #polarisability of benzene in F*m**2\n", + "alpha2 = p2/float(e10C2); #polarisability of water in F*m**2\n", + " \n", + "\n", + "#result\n", + "print'polarisability of benzene = %3.2e'%alpha1,'F*m**2';\n", + "print'polarisability of water = %3.2e'%alpha2,'F*m**2';\n", + "print'Note: mistake in textbok,alpha1 value is printed as 1.16*10**-38 instead of 1.16*10**-37';" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.5,Page No:4.10" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "polarisation of benzene = 6.80e-07 c/m**2\n", + "polarisation of water = 4.25e-05. c/m**2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "e0 = 8.85*10**-12; #abslute permitivity in (m**-3)*(kg**-1)*(s**4)*(A**2)\n", + "E = 600*10**2; #strength in V/cm\n", + "er1 = 2.28; #dielectric constant of benzene in coulomb/m\n", + "er2 = 81; #dielectric constant of water in coulomb/m\n", + "\n", + "\n", + "#fomula\n", + "#p=e0*E*(er-1)\n", + "#calculation\n", + "pB = e0*E*(er1-1); #polarisation of benzene in c/m**2\n", + "pW = e0*E*(er2-1); #polarisation of water in c/m**2\n", + " \n", + "\n", + "#result\n", + "print'polarisation of benzene = %3.2e'%pB,'c/m**2';\n", + "print'polarisation of water = %3.2e.'%pW,'c/m**2';" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.6,Page No:4.10" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "percentage contribution from ionic polaristion = 59.82 %\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "er0 = 5.6; #static dielectric cnstant of NaCl \n", + "n = 1.5; #optical index of refraction\n", + " \n", + "\n", + "#calculation\n", + "er = er0-n**2;\n", + "d = ((er/float(er0))*100); #percentage contribution from ionic polaristion in %\n", + " \n", + "#result \n", + "print'percentage contribution from ionic polaristion = %3.2f'%d,'%';\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 4.7,Page No:4.10" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "separation=1.69e-17 m\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "alpha = 0.18*10**-40; #polarisability of He in F *m**2\n", + "E = 3*10**5; #constant in V/m\n", + "N = 2.6*10**25; #number of atoms in per m**3\n", + "e = 1.6*10**-19;\n", + " \n", + " \n", + "#formula\n", + "#P=N*p\n", + "#charge of He=2*electron charge\n", + "#p=2(e*d)\n", + "#calculation\n", + "P = N*alpha*E; #in coul/m**2\n", + "p = P/float(N); #polarisation of He in coul.m\n", + "d = p/float(2*e); #separation between charges in m\n", + " \n", + " \n", + "#result \n", + "print'separation=%3.2e'%d,'m';\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Example 4.8,Page No:4.10" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "oriental polarisation=9.66e-08 coul/m**2\n" + ] + } + ], + "source": [ + "import math\n", + "\n", + "#variable declaration\n", + "N = 10**27; #number of HCl molecules in molecules/m**3\n", + "E = 10**5; #electric field in V/m\n", + "P = 1.04*3.33*10**-30; #permanent dipole moment in coul.m\n", + "T = 300; #temperature in kelvin\n", + "K = 1.38*10**-23;\n", + " \n", + " \n", + "#calculation\n", + "P0 = (N*(P**2)*E)/float(3*K*T); #oriental polarisation in coul/m^2\n", + "\n", + " \n", + "#result\n", + "print'oriental polarisation=%3.2e'%P0,'coul/m**2';" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.6" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/keerthi vanigundla/r.k.shukla.ipynb b/sample_notebooks/keerthi vanigundla/r.k.shukla.ipynb deleted file mode 100755 index 19a84998..00000000 --- a/sample_notebooks/keerthi vanigundla/r.k.shukla.ipynb +++ /dev/null @@ -1,379 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4:Behaviour of Dielectric Materials in ac and dc Fields" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.1,Page No:4.8" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dielectric constant of argon = 1.0005466\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "alpha = 1.8*10**-40; #polarisability of argon in Fm**2\n", - "e0 = 8.85*10**-12; #dielectric constant F/m\n", - "N1 = 6.02*10**23; #avagadro number in mol**-1\n", - "x = 22.4*10**3; #volume in m^3\n", - " \n", - "#formula\n", - "#er-1=N*p/e0*E=(N/e0)*alpha\n", - "#calculation\n", - "N = N1/float(x); #number of argon atoms in per unit volume in cm**3\n", - "N2 = N*10**6; #number of argon atoms in per unit volume in m**3\n", - "er = 1+((N2/float(e0)))*(alpha); #dielectric constant F/m\n", - "\n", - "\n", - "#result\n", - "print'dielectric constant of argon = %3.7f'%er;" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.2,Page No:4.9" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "displacement = 1.25e-17 m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "alpha = 1.8*10**-40; #polarisability of argon in F*m^2\n", - "E = 2*10**5; # in V/m\n", - "z = 18;\n", - "e = 1.6*10**-19;\n", - " \n", - " \n", - "#formula\n", - "#p=18*e*x\n", - "#calculation\n", - "p = alpha*E;\n", - "x = p/float(18*e); #shift of electron in m\n", - "\n", - " \n", - "#result\n", - "print'displacement = %3.2e'%x,'m';" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.3,Page No:4.9" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "local field of benzene=4.40e+03 V/m\n", - "local field of water=-1.57e+06 V/m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "E0 = 300*10**2; #local field in V/m\n", - "P1 = 3.398*10**-7; #dipole moment Coulomb/m\n", - "P2 = 2.124*10**-5; #dipole moment Coulomb/m\n", - "e0 = 8.85*10**-12; #permittivity in F/m\n", - " \n", - " \n", - "#formula\n", - "#E10Ci=E0-(2*Pi/3*e0)\n", - "#calculation\n", - "E10C1 = E0-((2*P1)/float(3*e0)); #local field of benzene in V/m\n", - "E10C2 = E0-((2*P2)/float(3*e0)); #local field of water in V/m\n", - " \n", - "#result\n", - "print'local field of benzene=%3.2e'%E10C1,'V/m';\n", - "print'local field of water=%3.2e'%E10C2,'V/m';" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.4,Page No:4.9" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "# import math\n", - "\n", - "#variable declaration\n", - "p1 = 5.12*10**-34; #p of benzene kg/m**3\n", - "p2 = 6.34*10**-34; #p of water kg/m**3\n", - "e10C1 = 4.4*10**3; #local field of benzene in V/m\n", - "e10C2 = 1570*10**3; #local field of water in V/m\n", - " \n", - " \n", - "#formula\n", - "#p=alphai*e10Ci\n", - "#calculation\n", - "alpha1 = p1/float(e10C1); #polarisability of benzene in F*m**2\n", - "alpha2 = p2/float(e10C2); #polarisability of water in F*m**2\n", - " \n", - "\n", - "#result\n", - "print'polarisability of benzene = %3.2e'%alpha1,'F*m**2';\n", - "print'polarisability of water = %3.2e'%alpha2,'F*m**2';\n", - "print'Note: mistake in textbok,alpha1 value is printed as 1.16*10**-38 instead of 1.16*10**-37';" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.5,Page No:4.10" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "polarisation of benzene = 6.80e-07 c/m**2\n", - "polarisation of water = 4.25e-05. c/m**2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "e0 = 8.85*10**-12; #abslute permitivity in (m**-3)*(kg**-1)*(s**4)*(A**2)\n", - "E = 600*10**2; #strength in V/cm\n", - "er1 = 2.28; #dielectric constant of benzene in coulomb/m\n", - "er2 = 81; #dielectric constant of water in coulomb/m\n", - "\n", - "\n", - "#fomula\n", - "#p=e0*E*(er-1)\n", - "#calculation\n", - "pB = e0*E*(er1-1); #polarisation of benzene in c/m**2\n", - "pW = e0*E*(er2-1); #polarisation of water in c/m**2\n", - " \n", - "\n", - "#result\n", - "print'polarisation of benzene = %3.2e'%pB,'c/m**2';\n", - "print'polarisation of water = %3.2e.'%pW,'c/m**2';" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.6,Page No:4.10" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "percentage contribution from ionic polaristion = 59.82 %\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "er0 = 5.6; #static dielectric cnstant of NaCl \n", - "n = 1.5; #optical index of refraction\n", - " \n", - "\n", - "#calculation\n", - "er = er0-n**2;\n", - "d = ((er/float(er0))*100); #percentage contribution from ionic polaristion in %\n", - " \n", - "#result \n", - "print'percentage contribution from ionic polaristion = %3.2f'%d,'%';\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 4.7,Page No:4.10" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "separation=1.69e-17 m\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "alpha = 0.18*10**-40; #polarisability of He in F *m**2\n", - "E = 3*10**5; #constant in V/m\n", - "N = 2.6*10**25; #number of atoms in per m**3\n", - "e = 1.6*10**-19;\n", - " \n", - " \n", - "#formula\n", - "#P=N*p\n", - "#charge of He=2*electron charge\n", - "#p=2(e*d)\n", - "#calculation\n", - "P = N*alpha*E; #in coul/m**2\n", - "p = P/float(N); #polarisation of He in coul.m\n", - "d = p/float(2*e); #separation between charges in m\n", - " \n", - " \n", - "#result \n", - "print'separation=%3.2e'%d,'m';\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "collapsed": true - }, - "source": [ - "# Example 4.8,Page No:4.10" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "oriental polarisation=9.66e-08 coul/m**2\n" - ] - } - ], - "source": [ - "import math\n", - "\n", - "#variable declaration\n", - "N = 10**27; #number of HCl molecules in molecules/m**3\n", - "E = 10**5; #electric field in V/m\n", - "P = 1.04*3.33*10**-30; #permanent dipole moment in coul.m\n", - "T = 300; #temperature in kelvin\n", - "K = 1.38*10**-23;\n", - " \n", - " \n", - "#calculation\n", - "P0 = (N*(P**2)*E)/float(3*K*T); #oriental polarisation in coul/m^2\n", - "\n", - " \n", - "#result\n", - "print'oriental polarisation=%3.2e'%P0,'coul/m**2';" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.6" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat.ipynb b/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat.ipynb new file mode 100755 index 00000000..b114e915 --- /dev/null +++ b/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat.ipynb @@ -0,0 +1,278 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#Chapter:2 CONDUCTION" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.1" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " heat is Btu/hr 69120.0\n", + "\t approximate values are mentioned in the book \n", + "\n" + ] + } + ], + "source": [ + "#given\n", + "Tavg=900; # average temperature of the wall,F\n", + "k=0.15; # Thermal conductivity at 932 F,Btu/(hr)(ft^2)(F/ft)\n", + "T1=1500; # hot side temperature,F\n", + "T2=300; # cold side temperature,F\n", + "A=192; # surface area,ft^2\n", + "L=0.5; # thickness,ft\n", + "#solution\n", + "Q=(k)*(A)*(T1-T2)/L; # formula for heat,Btu/hr\n", + "print \" heat is Btu/hr \",Q\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#end\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example2.2" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t resistance offered by firebrick : (hr)*(F)/Btu 0.97\n", + "\t resistance offered by insulating brick : (hr)*(F)/Btu 2.2\n", + "\t resistance offered by buildingbrick : (hr)*(F)/Btu 1.25\n", + "\t total resistance offered by three walls : (hr)*(F)/Btu 4.42\n", + "\t heat loss/ft^2 : Btu/hr 331.0\n", + "\t delta is : F 322.0\n", + "\t temperature at interface of firebrick and insulating brick F 1278.0\n", + "\t deltb is : F 729.0\n", + "\t temperature at interface of insulating brick and building brick F 549.0\n", + "\t approximate values are mentioned in the book \n", + "\n" + ] + } + ], + "source": [ + "#given\n", + "La=0.66; # Thickness of firebrick wall,ft\n", + "Lb=0.33; # Thickness of insulating brick wall,ft\n", + "Lc=0.5; # Thickness of building brick wall,ft\n", + "Ka=0.68; # themal conductivity of firebrick,Btu/(hr)*(ft^2)*(F/ft)\n", + "Kb=0.15; # themal conductivity of insulating brick,Btu/(hr)*(ft^2)*(F/ft)\n", + "Kc=0.40; # themal conductivity of building brick,Btu/(hr)*(ft^2)*(F/ft)\n", + "A=1.; # surface area,ft^2\n", + "Ta=1600.; # temperature of inner wall,F\n", + "Tb=125.; # temperature of outer wall.F\n", + "#solution\n", + "Ra=La/(Ka)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by firebrick : (hr)*(F)/Btu \",round(Ra,2)\n", + "Rb=Lb/(Kb)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by insulating brick : (hr)*(F)/Btu \",round(Rb,2)\n", + "Rc=Lc/(Kc)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by buildingbrick : (hr)*(F)/Btu \",round(Rc,2)\n", + "R=Ra+Rb+Rc; # total resistance offered by three walls,(hr)*(F)/Btu\n", + "print\"\\t total resistance offered by three walls : (hr)*(F)/Btu \",round(R,2)\n", + "Q=(1600-125)/4.45; # using formula for heat loss/ft^2,Btu/hr\n", + "print\"\\t heat loss/ft^2 : Btu/hr \",round(Q,0)\n", + "# T1,T2 are temperatures at interface of firebrick and insulating brick, and insulating brick and building brick respectively,F\n", + "delta=(Q)*(Ra); # formula for temperature difference,F\n", + "print\"\\t delta is : F \",round(delta,0)\n", + "T1=Ta-((Q)*(Ra)); # temperature at interface of firebrick and insulating brick,F\n", + "print\"\\t temperature at interface of firebrick and insulating brick F \",round(T1,0)\n", + "deltb=Q*(Rb);\n", + "print\"\\t deltb is : F \",round(deltb,0)\n", + "T2=T1-((Q)*(Rb)); #temperature at interface of insulating brick and building brick,F\n", + "print\"\\t temperature at interface of insulating brick and building brick F \",round(T2,0)\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#end\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.3" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t approximate values are mentioned in the book \n", + "\n", + "\t resistance offered by air film (hr)(F)/Btu 0.79\n", + "\t total resistance (hr)(F)/Btu 5.24\n", + "\t heat loss Btu/hr 282.0\n" + ] + } + ], + "source": [ + "\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#given\n", + "Lair=0.25/12; # thickness of air film,ft\n", + "Kair=0.0265; # thermal conductivity of air at 572F,Btu/(hr)*(ft^2)(F/ft)\n", + "A=1; # surface area,ft^2\n", + "#solution\n", + "Rair=Lair/(Kair*(A)); # resistance offered by air film, (hr)(F)/Btu\n", + "print\"\\t resistance offered by air film (hr)(F)/Btu \",round(Rair,2)\n", + "R=4.45; # resistance from previous example 2.2,(hr)(F)/Btu\n", + "Rt=(R)+Rair; # total resistance,(hr)(F)/Btu\n", + "print\"\\t total resistance (hr)(F)/Btu \",round(Rt,2)\n", + "Ta=1600; # temperature of inner wall,F\n", + "Tb=125; # temperature of outer wall,F\n", + "Q=(1600-125)/Rt; # heat loss, Btu/hr\n", + "print\"\\t heat loss Btu/hr \",round(Q,0)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#given\n", + "k=0.63; # thermal conductivity of pipe, Btu/(hr)*(ft^2)*(F/ft)\n", + "Do=6. # in\n", + "Di=5. # in\n", + "Ti=200.;# inner side temperature,F\n", + "To=175.; # outer side temperature,F\n", + "#solution\n", + "import math\n", + "from math import log\n", + "q=(2*(3.14)*(k)*(Ti-To))/(log (Do/Di)); # formula for heat flow,Btu/(hr)*(ft)\n", + "print\"\\t heat flow is : Btu/(hr)*(ft) \",round(q,0)\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "# caculation mistake in book\n", + "# end\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.5" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t approximate values are mentioned in the book \n", + "\n", + "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 104.4\n", + "\t Check between ts and t1, since delt/R = deltc/Rc \n", + "\t t1 is : F 122.300238658\n", + "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 102.9\n", + "\t Check between ts and t1, since delt/R = deltc/Rc \n", + "\t t1 is : F \n", + "125.4\n" + ] + } + ], + "source": [ + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#given\n", + "t1=150; # assume temperature of outer surface of rockwool,F\n", + "ta=70; # temperature of surrounding air,F\n", + "ha=2.23; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", + "#solution\n", + "import math\n", + "from math import log\n", + "q=(3.14)*(300-70)/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.23)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft), calculation mistake\n", + "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft) \",round(q,1)\n", + "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", + "t1=300-(((104.8)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", + "print\"\\t t1 is : F \",t1\n", + "t1=125; # assume temperature of outer surface of rockwool,F\n", + "ha=2.10; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", + "q=((3.14)*(300-70))/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.10)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft)\n", + "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft)\",round(q,1)\n", + "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", + "t1=300-(((103)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", + "print\"\\t t1 is : F \\n\",round(t1,1)\n", + "# end \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat_transfer)_1.ipynb b/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat_transfer)_1.ipynb new file mode 100755 index 00000000..1de57adb --- /dev/null +++ b/sample_notebooks/kotaDinesh Babu/kotaDinesh Babu_version_backup/samplebook(process_heat_transfer)_1.ipynb @@ -0,0 +1,281 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2:CONDUCTION" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.1" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " heat is Btu/hr 69120.0\n", + "\t approximate values are mentioned in the book \n", + "\n" + ] + } + ], + "source": [ + "#page 13\n", + "#given\n", + "Tavg=900; # average temperature of the wall,F\n", + "k=0.15; # Thermal conductivity at 932 F,Btu/(hr)(ft^2)(F/ft)\n", + "T1=1500; # hot side temperature,F\n", + "T2=300; # cold side temperature,F\n", + "A=192; # surface area,ft^2\n", + "L=0.5; # thickness,ft\n", + "#solution\n", + "Q=(k)*(A)*(T1-T2)/L; # formula for heat,Btu/hr\n", + "print \" heat is Btu/hr \",Q\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#end\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example2.2" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t resistance offered by firebrick : (hr)*(F)/Btu 0.97\n", + "\t resistance offered by insulating brick : (hr)*(F)/Btu 2.2\n", + "\t resistance offered by buildingbrick : (hr)*(F)/Btu 1.25\n", + "\t total resistance offered by three walls : (hr)*(F)/Btu 4.42\n", + "\t heat loss/ft^2 : Btu/hr 331.0\n", + "\t delta is : F 322.0\n", + "\t temperature at interface of firebrick and insulating brick F 1278.0\n", + "\t deltb is : F 729.0\n", + "\t temperature at interface of insulating brick and building brick F 549.0\n", + "\t approximate values are mentioned in the book \n", + "\n" + ] + } + ], + "source": [ + "#page 14\n", + "#given\n", + "La=0.66; # Thickness of firebrick wall,ft\n", + "Lb=0.33; # Thickness of insulating brick wall,ft\n", + "Lc=0.5; # Thickness of building brick wall,ft\n", + "Ka=0.68; # themal conductivity of firebrick,Btu/(hr)*(ft^2)*(F/ft)\n", + "Kb=0.15; # themal conductivity of insulating brick,Btu/(hr)*(ft^2)*(F/ft)\n", + "Kc=0.40; # themal conductivity of building brick,Btu/(hr)*(ft^2)*(F/ft)\n", + "A=1.; # surface area,ft^2\n", + "Ta=1600.; # temperature of inner wall,F\n", + "Tb=125.; # temperature of outer wall.F\n", + "#solution\n", + "Ra=La/(Ka)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by firebrick : (hr)*(F)/Btu \",round(Ra,2)\n", + "Rb=Lb/(Kb)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by insulating brick : (hr)*(F)/Btu \",round(Rb,2)\n", + "Rc=Lc/(Kc)*(A); # formula for resistance,(hr)*(F)/Btu\n", + "print\"\\t resistance offered by buildingbrick : (hr)*(F)/Btu \",round(Rc,2)\n", + "R=Ra+Rb+Rc; # total resistance offered by three walls,(hr)*(F)/Btu\n", + "print\"\\t total resistance offered by three walls : (hr)*(F)/Btu \",round(R,2)\n", + "Q=(1600-125)/4.45; # using formula for heat loss/ft^2,Btu/hr\n", + "print\"\\t heat loss/ft^2 : Btu/hr \",round(Q,0)\n", + "# T1,T2 are temperatures at interface of firebrick and insulating brick, and insulating brick and building brick respectively,F\n", + "delta=(Q)*(Ra); # formula for temperature difference,F\n", + "print\"\\t delta is : F \",round(delta,0)\n", + "T1=Ta-((Q)*(Ra)); # temperature at interface of firebrick and insulating brick,F\n", + "print\"\\t temperature at interface of firebrick and insulating brick F \",round(T1,0)\n", + "deltb=Q*(Rb);\n", + "print\"\\t deltb is : F \",round(deltb,0)\n", + "T2=T1-((Q)*(Rb)); #temperature at interface of insulating brick and building brick,F\n", + "print\"\\t temperature at interface of insulating brick and building brick F \",round(T2,0)\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#end\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.3" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t approximate values are mentioned in the book \n", + "\n", + "\t resistance offered by air film (hr)(F)/Btu 0.79\n", + "\t total resistance (hr)(F)/Btu 5.24\n", + "\t heat loss Btu/hr 282.0\n" + ] + } + ], + "source": [ + "#page 15\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#given\n", + "Lair=0.25/12; # thickness of air film,ft\n", + "Kair=0.0265; # thermal conductivity of air at 572F,Btu/(hr)*(ft^2)(F/ft)\n", + "A=1; # surface area,ft^2\n", + "#solution\n", + "Rair=Lair/(Kair*(A)); # resistance offered by air film, (hr)(F)/Btu\n", + "print\"\\t resistance offered by air film (hr)(F)/Btu \",round(Rair,2)\n", + "R=4.45; # resistance from previous example 2.2,(hr)(F)/Btu\n", + "Rt=(R)+Rair; # total resistance,(hr)(F)/Btu\n", + "print\"\\t total resistance (hr)(F)/Btu \",round(Rt,2)\n", + "Ta=1600; # temperature of inner wall,F\n", + "Tb=125; # temperature of outer wall,F\n", + "Q=(1600-125)/Rt; # heat loss, Btu/hr\n", + "print\"\\t heat loss Btu/hr \",round(Q,0)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.4" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#page 16\n", + "#given\n", + "k=0.63; # thermal conductivity of pipe, Btu/(hr)*(ft^2)*(F/ft)\n", + "Do=6. # in\n", + "Di=5. # in\n", + "Ti=200.;# inner side temperature,F\n", + "To=175.; # outer side temperature,F\n", + "#solution\n", + "import math\n", + "from math import log\n", + "q=(2*(3.14)*(k)*(Ti-To))/(log (Do/Di)); # formula for heat flow,Btu/(hr)*(ft)\n", + "print\"\\t heat flow is : Btu/(hr)*(ft) \",round(q,0)\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "# caculation mistake in book\n", + "# end\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##Example2.5" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\t approximate values are mentioned in the book \n", + "\n", + "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 104.4\n", + "\t Check between ts and t1, since delt/R = deltc/Rc \n", + "\t t1 is : F 122.300238658\n", + "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 102.9\n", + "\t Check between ts and t1, since delt/R = deltc/Rc \n", + "\t t1 is : F 125.4\n" + ] + } + ], + "source": [ + "#page 19\n", + "print\"\\t approximate values are mentioned in the book \\n\"\n", + "#given\n", + "t1=150; # assume temperature of outer surface of rockwool,F\n", + "ta=70; # temperature of surrounding air,F\n", + "ha=2.23; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", + "#solution\n", + "import math\n", + "from math import log\n", + "q=(3.14)*(300-70)/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.23)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft), calculation mistake\n", + "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft) \",round(q,1)\n", + "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", + "t1=300-(((104.8)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", + "print\"\\t t1 is : F \",t1\n", + "t1=125; # assume temperature of outer surface of rockwool,F\n", + "ha=2.10; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", + "q=((3.14)*(300-70))/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.10)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft)\n", + "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft)\",round(q,1)\n", + "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", + "t1=300-(((103)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", + "print\"\\t t1 is : F \",round(t1,1)\n", + "# end \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer).ipynb b/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer).ipynb deleted file mode 100755 index b114e915..00000000 --- a/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer).ipynb +++ /dev/null @@ -1,278 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "#Chapter:2 CONDUCTION" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.1" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " heat is Btu/hr 69120.0\n", - "\t approximate values are mentioned in the book \n", - "\n" - ] - } - ], - "source": [ - "#given\n", - "Tavg=900; # average temperature of the wall,F\n", - "k=0.15; # Thermal conductivity at 932 F,Btu/(hr)(ft^2)(F/ft)\n", - "T1=1500; # hot side temperature,F\n", - "T2=300; # cold side temperature,F\n", - "A=192; # surface area,ft^2\n", - "L=0.5; # thickness,ft\n", - "#solution\n", - "Q=(k)*(A)*(T1-T2)/L; # formula for heat,Btu/hr\n", - "print \" heat is Btu/hr \",Q\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#end\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example2.2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t resistance offered by firebrick : (hr)*(F)/Btu 0.97\n", - "\t resistance offered by insulating brick : (hr)*(F)/Btu 2.2\n", - "\t resistance offered by buildingbrick : (hr)*(F)/Btu 1.25\n", - "\t total resistance offered by three walls : (hr)*(F)/Btu 4.42\n", - "\t heat loss/ft^2 : Btu/hr 331.0\n", - "\t delta is : F 322.0\n", - "\t temperature at interface of firebrick and insulating brick F 1278.0\n", - "\t deltb is : F 729.0\n", - "\t temperature at interface of insulating brick and building brick F 549.0\n", - "\t approximate values are mentioned in the book \n", - "\n" - ] - } - ], - "source": [ - "#given\n", - "La=0.66; # Thickness of firebrick wall,ft\n", - "Lb=0.33; # Thickness of insulating brick wall,ft\n", - "Lc=0.5; # Thickness of building brick wall,ft\n", - "Ka=0.68; # themal conductivity of firebrick,Btu/(hr)*(ft^2)*(F/ft)\n", - "Kb=0.15; # themal conductivity of insulating brick,Btu/(hr)*(ft^2)*(F/ft)\n", - "Kc=0.40; # themal conductivity of building brick,Btu/(hr)*(ft^2)*(F/ft)\n", - "A=1.; # surface area,ft^2\n", - "Ta=1600.; # temperature of inner wall,F\n", - "Tb=125.; # temperature of outer wall.F\n", - "#solution\n", - "Ra=La/(Ka)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by firebrick : (hr)*(F)/Btu \",round(Ra,2)\n", - "Rb=Lb/(Kb)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by insulating brick : (hr)*(F)/Btu \",round(Rb,2)\n", - "Rc=Lc/(Kc)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by buildingbrick : (hr)*(F)/Btu \",round(Rc,2)\n", - "R=Ra+Rb+Rc; # total resistance offered by three walls,(hr)*(F)/Btu\n", - "print\"\\t total resistance offered by three walls : (hr)*(F)/Btu \",round(R,2)\n", - "Q=(1600-125)/4.45; # using formula for heat loss/ft^2,Btu/hr\n", - "print\"\\t heat loss/ft^2 : Btu/hr \",round(Q,0)\n", - "# T1,T2 are temperatures at interface of firebrick and insulating brick, and insulating brick and building brick respectively,F\n", - "delta=(Q)*(Ra); # formula for temperature difference,F\n", - "print\"\\t delta is : F \",round(delta,0)\n", - "T1=Ta-((Q)*(Ra)); # temperature at interface of firebrick and insulating brick,F\n", - "print\"\\t temperature at interface of firebrick and insulating brick F \",round(T1,0)\n", - "deltb=Q*(Rb);\n", - "print\"\\t deltb is : F \",round(deltb,0)\n", - "T2=T1-((Q)*(Rb)); #temperature at interface of insulating brick and building brick,F\n", - "print\"\\t temperature at interface of insulating brick and building brick F \",round(T2,0)\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#end\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t approximate values are mentioned in the book \n", - "\n", - "\t resistance offered by air film (hr)(F)/Btu 0.79\n", - "\t total resistance (hr)(F)/Btu 5.24\n", - "\t heat loss Btu/hr 282.0\n" - ] - } - ], - "source": [ - "\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#given\n", - "Lair=0.25/12; # thickness of air film,ft\n", - "Kair=0.0265; # thermal conductivity of air at 572F,Btu/(hr)*(ft^2)(F/ft)\n", - "A=1; # surface area,ft^2\n", - "#solution\n", - "Rair=Lair/(Kair*(A)); # resistance offered by air film, (hr)(F)/Btu\n", - "print\"\\t resistance offered by air film (hr)(F)/Btu \",round(Rair,2)\n", - "R=4.45; # resistance from previous example 2.2,(hr)(F)/Btu\n", - "Rt=(R)+Rair; # total resistance,(hr)(F)/Btu\n", - "print\"\\t total resistance (hr)(F)/Btu \",round(Rt,2)\n", - "Ta=1600; # temperature of inner wall,F\n", - "Tb=125; # temperature of outer wall,F\n", - "Q=(1600-125)/Rt; # heat loss, Btu/hr\n", - "print\"\\t heat loss Btu/hr \",round(Q,0)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.4" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "#given\n", - "k=0.63; # thermal conductivity of pipe, Btu/(hr)*(ft^2)*(F/ft)\n", - "Do=6. # in\n", - "Di=5. # in\n", - "Ti=200.;# inner side temperature,F\n", - "To=175.; # outer side temperature,F\n", - "#solution\n", - "import math\n", - "from math import log\n", - "q=(2*(3.14)*(k)*(Ti-To))/(log (Do/Di)); # formula for heat flow,Btu/(hr)*(ft)\n", - "print\"\\t heat flow is : Btu/(hr)*(ft) \",round(q,0)\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "# caculation mistake in book\n", - "# end\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.5" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t approximate values are mentioned in the book \n", - "\n", - "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 104.4\n", - "\t Check between ts and t1, since delt/R = deltc/Rc \n", - "\t t1 is : F 122.300238658\n", - "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 102.9\n", - "\t Check between ts and t1, since delt/R = deltc/Rc \n", - "\t t1 is : F \n", - "125.4\n" - ] - } - ], - "source": [ - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#given\n", - "t1=150; # assume temperature of outer surface of rockwool,F\n", - "ta=70; # temperature of surrounding air,F\n", - "ha=2.23; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", - "#solution\n", - "import math\n", - "from math import log\n", - "q=(3.14)*(300-70)/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.23)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft), calculation mistake\n", - "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft) \",round(q,1)\n", - "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", - "t1=300-(((104.8)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", - "print\"\\t t1 is : F \",t1\n", - "t1=125; # assume temperature of outer surface of rockwool,F\n", - "ha=2.10; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", - "q=((3.14)*(300-70))/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.10)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft)\n", - "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft)\",round(q,1)\n", - "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", - "t1=300-(((103)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", - "print\"\\t t1 is : F \\n\",round(t1,1)\n", - "# end \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer)_1.ipynb b/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer)_1.ipynb deleted file mode 100755 index 1de57adb..00000000 --- a/sample_notebooks/kotaDinesh Babu/samplebook(process_heat_transfer)_1.ipynb +++ /dev/null @@ -1,281 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2:CONDUCTION" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.1" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " heat is Btu/hr 69120.0\n", - "\t approximate values are mentioned in the book \n", - "\n" - ] - } - ], - "source": [ - "#page 13\n", - "#given\n", - "Tavg=900; # average temperature of the wall,F\n", - "k=0.15; # Thermal conductivity at 932 F,Btu/(hr)(ft^2)(F/ft)\n", - "T1=1500; # hot side temperature,F\n", - "T2=300; # cold side temperature,F\n", - "A=192; # surface area,ft^2\n", - "L=0.5; # thickness,ft\n", - "#solution\n", - "Q=(k)*(A)*(T1-T2)/L; # formula for heat,Btu/hr\n", - "print \" heat is Btu/hr \",Q\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#end\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example2.2" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t resistance offered by firebrick : (hr)*(F)/Btu 0.97\n", - "\t resistance offered by insulating brick : (hr)*(F)/Btu 2.2\n", - "\t resistance offered by buildingbrick : (hr)*(F)/Btu 1.25\n", - "\t total resistance offered by three walls : (hr)*(F)/Btu 4.42\n", - "\t heat loss/ft^2 : Btu/hr 331.0\n", - "\t delta is : F 322.0\n", - "\t temperature at interface of firebrick and insulating brick F 1278.0\n", - "\t deltb is : F 729.0\n", - "\t temperature at interface of insulating brick and building brick F 549.0\n", - "\t approximate values are mentioned in the book \n", - "\n" - ] - } - ], - "source": [ - "#page 14\n", - "#given\n", - "La=0.66; # Thickness of firebrick wall,ft\n", - "Lb=0.33; # Thickness of insulating brick wall,ft\n", - "Lc=0.5; # Thickness of building brick wall,ft\n", - "Ka=0.68; # themal conductivity of firebrick,Btu/(hr)*(ft^2)*(F/ft)\n", - "Kb=0.15; # themal conductivity of insulating brick,Btu/(hr)*(ft^2)*(F/ft)\n", - "Kc=0.40; # themal conductivity of building brick,Btu/(hr)*(ft^2)*(F/ft)\n", - "A=1.; # surface area,ft^2\n", - "Ta=1600.; # temperature of inner wall,F\n", - "Tb=125.; # temperature of outer wall.F\n", - "#solution\n", - "Ra=La/(Ka)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by firebrick : (hr)*(F)/Btu \",round(Ra,2)\n", - "Rb=Lb/(Kb)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by insulating brick : (hr)*(F)/Btu \",round(Rb,2)\n", - "Rc=Lc/(Kc)*(A); # formula for resistance,(hr)*(F)/Btu\n", - "print\"\\t resistance offered by buildingbrick : (hr)*(F)/Btu \",round(Rc,2)\n", - "R=Ra+Rb+Rc; # total resistance offered by three walls,(hr)*(F)/Btu\n", - "print\"\\t total resistance offered by three walls : (hr)*(F)/Btu \",round(R,2)\n", - "Q=(1600-125)/4.45; # using formula for heat loss/ft^2,Btu/hr\n", - "print\"\\t heat loss/ft^2 : Btu/hr \",round(Q,0)\n", - "# T1,T2 are temperatures at interface of firebrick and insulating brick, and insulating brick and building brick respectively,F\n", - "delta=(Q)*(Ra); # formula for temperature difference,F\n", - "print\"\\t delta is : F \",round(delta,0)\n", - "T1=Ta-((Q)*(Ra)); # temperature at interface of firebrick and insulating brick,F\n", - "print\"\\t temperature at interface of firebrick and insulating brick F \",round(T1,0)\n", - "deltb=Q*(Rb);\n", - "print\"\\t deltb is : F \",round(deltb,0)\n", - "T2=T1-((Q)*(Rb)); #temperature at interface of insulating brick and building brick,F\n", - "print\"\\t temperature at interface of insulating brick and building brick F \",round(T2,0)\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#end\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.3" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t approximate values are mentioned in the book \n", - "\n", - "\t resistance offered by air film (hr)(F)/Btu 0.79\n", - "\t total resistance (hr)(F)/Btu 5.24\n", - "\t heat loss Btu/hr 282.0\n" - ] - } - ], - "source": [ - "#page 15\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#given\n", - "Lair=0.25/12; # thickness of air film,ft\n", - "Kair=0.0265; # thermal conductivity of air at 572F,Btu/(hr)*(ft^2)(F/ft)\n", - "A=1; # surface area,ft^2\n", - "#solution\n", - "Rair=Lair/(Kair*(A)); # resistance offered by air film, (hr)(F)/Btu\n", - "print\"\\t resistance offered by air film (hr)(F)/Btu \",round(Rair,2)\n", - "R=4.45; # resistance from previous example 2.2,(hr)(F)/Btu\n", - "Rt=(R)+Rair; # total resistance,(hr)(F)/Btu\n", - "print\"\\t total resistance (hr)(F)/Btu \",round(Rt,2)\n", - "Ta=1600; # temperature of inner wall,F\n", - "Tb=125; # temperature of outer wall,F\n", - "Q=(1600-125)/Rt; # heat loss, Btu/hr\n", - "print\"\\t heat loss Btu/hr \",round(Q,0)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.4" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "#page 16\n", - "#given\n", - "k=0.63; # thermal conductivity of pipe, Btu/(hr)*(ft^2)*(F/ft)\n", - "Do=6. # in\n", - "Di=5. # in\n", - "Ti=200.;# inner side temperature,F\n", - "To=175.; # outer side temperature,F\n", - "#solution\n", - "import math\n", - "from math import log\n", - "q=(2*(3.14)*(k)*(Ti-To))/(log (Do/Di)); # formula for heat flow,Btu/(hr)*(ft)\n", - "print\"\\t heat flow is : Btu/(hr)*(ft) \",round(q,0)\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "# caculation mistake in book\n", - "# end\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##Example2.5" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\t approximate values are mentioned in the book \n", - "\n", - "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 104.4\n", - "\t Check between ts and t1, since delt/R = deltc/Rc \n", - "\t t1 is : F 122.300238658\n", - "\t heat loss for linear foot is : Btu/(hr)*(lin ft) 102.9\n", - "\t Check between ts and t1, since delt/R = deltc/Rc \n", - "\t t1 is : F 125.4\n" - ] - } - ], - "source": [ - "#page 19\n", - "print\"\\t approximate values are mentioned in the book \\n\"\n", - "#given\n", - "t1=150; # assume temperature of outer surface of rockwool,F\n", - "ta=70; # temperature of surrounding air,F\n", - "ha=2.23; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", - "#solution\n", - "import math\n", - "from math import log\n", - "q=(3.14)*(300-70)/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.23)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft), calculation mistake\n", - "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft) \",round(q,1)\n", - "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", - "t1=300-(((104.8)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", - "print\"\\t t1 is : F \",t1\n", - "t1=125; # assume temperature of outer surface of rockwool,F\n", - "ha=2.10; # surface coefficient,Btu/(hr)*(ft^2)*(F)\n", - "q=((3.14)*(300-70))/(((1/(2*0.033))*log(3.375/2.375))+(1/((2.10)*(3.375/12)))); # using formula for heat loss,Btu/(hr)*(lin ft)\n", - "print\"\\t heat loss for linear foot is : Btu/(hr)*(lin ft)\",round(q,1)\n", - "print\"\\t Check between ts and t1, since delt/R = deltc/Rc \"\n", - "t1=300-(((103)*((1)*(log(3.375/2.375))))/((2)*(3.14)*(.033))); # using eq 2.31,F\n", - "print\"\\t t1 is : F \",round(t1,1)\n", - "# end \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety.ipynb b/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety.ipynb new file mode 100755 index 00000000..ff9f91c7 --- /dev/null +++ b/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety.ipynb @@ -0,0 +1,395 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.1 page number 24\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The bearing stress at C is 0.875 MPA\n", + "The maximum normal stress in BD bolt is: 62.0 MPA\n", + "The tensile strss at shank of the bolt is: 40.0 MPA\n" + ] + } + ], + "source": [ + "#Given\n", + "import math\n", + "d_bolt = 20.0 #mm,diameter,This is not the minimum area\n", + "d_bolt_min = 16.0 #mm This is at the roots of the thread \n", + "#This yealds maximum stress \n", + "A_crossection = (math.pi)*(d_bolt**2)/4 #mm*2\n", + "A_crossection_min = (math.pi)*(d_bolt_min**2)/4 #mm*2 ,This is minimum area which yeilds maximum stress\n", + "load = 10.0 #KN\n", + "BC = 1.0 #m\n", + "CF = 2.5 #m\n", + "contact_area = 200*200 # mm*2 , The contact area at c\n", + "\n", + "#caliculations \n", + "#Balancing forces in the x direction:\n", + "# Balncing the moments about C and B:\n", + "Fx = 0 \n", + "R_cy = load*(BC+CF) #KN , Reaction at C in y-direction\n", + "R_by = load*(CF) #KN , Reaction at B in y-direction\n", + "#Because of 2 bolts\n", + "stress_max = (R_by/(2*A_crossection_min))*(10**3) # MPA,maximum stess records at minimum area\n", + "stress_shank = (R_by/(2*A_crossection))*(10**3) # MPA\n", + "Bearing_stress_c = (R_cy/contact_area)*(10**3) #MPA, Bearing stress at C\n", + "\n", + "print\"The bearing stress at C is \",(Bearing_stress_c) ,\"MPA\"\n", + "print\"The maximum normal stress in BD bolt is: \",round(stress_max),\"MPA\"\n", + "print\"The tensile strss at shank of the bolt is: \",round(stress_shank),\"MPA\"\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.2 page number 26" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The total weightof pier: 25.0 KN\n", + "The stress at 1 m above is 28.75 MPA\n" + ] + } + ], + "source": [ + "#Given \n", + "load_distributed = 20 #KN/m*2, This is the load distributed over the pier\n", + "H = 2 # m, Total height \n", + "h = 1 #m , point of investigation \n", + "base = 1.5 #m The length of crossection in side veiw \n", + "top = 0.5 #m ,The length where load is distributed on top\n", + "base_inv = 1 #m , the length at the point of investigation \n", + "area = 0.5*1 #m ,The length at a-a crossection \n", + "density_conc = 25 #KN/m*2\n", + "#caliculation of total weight \n", + "\n", + "v_total = ((top+base)/2)*top*H #m*2 ,The total volume \n", + "w_total = v_total* density_conc #KN , The total weight\n", + "R_top = (top**2)*load_distributed #KN , THe reaction force due to load distribution \n", + "reaction_net = w_total + R_top\n", + "\n", + "#caliculation of State of stress at 1m \n", + "v_inv = ((top+base_inv)/2)*top*h #m*2 ,The total volume from 1m to top\n", + "w_inv = v_inv*density_conc #KN , The total weight from 1m to top\n", + "reaction_net = w_inv + R_top #KN\n", + "Stress = reaction_net/area #KN/m*2\n", + "print\"The total weight of pier is\",w_total,\"KN\"\n", + "print\"The stress at 1 m above is\",Stress,\"MPA\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.3 page number 27" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tensile stress in main bar AB: 17.89 Ksi\n", + "Tensile stress in clevis of main bar AB: 11.18 Ksi\n", + "Comprensive stress in main bar BC: 12.93 Ksi\n", + "Bearing stress in pin at C: 18.86 Ksi\n", + "torsion stress in pin at C: -25.62 Ksi\n" + ] + } + ], + "source": [ + "#Given\n", + "from math import pow\n", + "d_pins = 0.375 #inch\n", + "load = 3 #Kips\n", + "AB_x = 6 #inch,X-component\n", + "AB_y = 3 #inch,Y-component \n", + "BC_y = 6 #inch,Y-component\n", + "BC_x = 6 #inch,X-component\n", + "area_AB = 0.25*0.5 #inch*2 \n", + "area_net = 0.20*2*(0.875-0.375) #inch*2 \n", + "area_BC = 0.875*0.25 #inch*2 \n", + "area_pin = d_pins*2*0.20 #inch*2 \n", + "area_pin_crossection = 3.14*((d_pins/2)**2)\n", + "#caliculations\n", + "\n", + "slope = AB_y/ AB_x #For AB\n", + "slope = BC_y/ BC_x #For BC\n", + "\n", + "#momentum at point C:\n", + "F_A_x = (load*AB_x )/(BC_y + AB_y ) #Kips, F_A_x X-component of F_A\n", + "\n", + "#momentum at point A:\n", + "F_C_x = -(load*BC_x)/(BC_y + AB_y ) #Kips, F_C_x X-component of F_c\n", + "\n", + "#X,Y components of F_A\n", + "F_A= (pow(5,0.5)/2)*F_A_x #Kips\n", + "F_A_y = 0.5*F_A_x #Kips\n", + "\n", + "#X,Y components of F_C \n", + "F_C= pow(2,0.5)*F_C_x #Kips\n", + "F_C_y = F_C_x #Kips\n", + "\n", + "T_stress_AB = F_A/area_AB #Ksi , Tensile stress in main bar AB\n", + "stress_clevis = F_A/area_net #Ksi ,Tensile stress in clevis of main bar AB\n", + "c_strees_BC = F_C/area_BC #Ksi , Comprensive stress in main bar BC\n", + "B_stress_pin = F_C/area_pin #Ksi , Bearing stress in pin at C\n", + "To_stress_pin = F_C/area_pin_crossection #Ksi , torsion stress in pin at C\n", + "\n", + "print\"Tensile stress in main bar AB:\",round(T_stress_AB,2),\"Ksi\"\n", + "print\"Tensile stress in clevis of main bar AB:\",round(stress_clevis,2),\"Ksi\"\n", + "print\"Comprensive stress in main bar BC:\",round(-c_strees_BC,2),\"Ksi\"\n", + "print\"Bearing stress in pin at C:\",round(-B_stress_pin,2),\"Ksi\"\n", + "print\"torsion stress in pin at C:\",round(To_stress_pin,2),\"Ksi\"\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.4 page number 38" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The factor 2.5 is less than assumed factor 2.7 so this can be considered\n" + ] + } + ], + "source": [ + "#Given\n", + "strength_steel = 120 #Ksi\n", + "factor = 2.5\n", + "F_C = 2.23 #Ksi\n", + "\n", + "#caliculations\n", + "\n", + "stress_allow = strength_steel/factor #Ksi\n", + "A_net = F_C/strength_steel #in*2 , \n", + "#lets adopt 0.20x0.25 in*2 and check wether we are correct or not? \n", + "\n", + "A_net_assumption = 0.25*0.20 #in*2 , this is assumed area which is near to A_net\n", + "stress = 2.23/A_net_assumption #Ksi\n", + "factor_assumed = strength_steel/stress \n", + "\n", + "if factor_assumed > factor :\n", + " print \"The factor\",factor,\"is less than assumed factor\",round(factor_assumed,1),\"so this can be considered\"\n", + "else:\n", + " print \"The assumed factor\",factor, \"is more than assumed factor\",factor_assumed,\"factor_assumed\"\n", + " \n", + " \n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.6 page number 35" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The required size of rod is: 49.35 m*2\n" + ] + } + ], + "source": [ + "#Given\n", + "mass = 5 #Kg\n", + "frequency = 10 #Hz\n", + "stress_allow = 200 #MPa\n", + "R = 0.5 #m\n", + "\n", + "#caliculations \n", + "from math import pi\n", + "w = 2*pi*frequency #rad/sec\n", + "a = (w**2)*R #m*2/sec\n", + "F = mass*a #N\n", + "A_req = F/stress_allow #m*2 , The required area for aloowing stress\n", + "print\"The required size of rod is:\",round(A_req,2),\"m*2\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.7 page number 45" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the allowable area for live load 1.0 is 0.273 in*2\n", + "the allowable area for live load 15 is 0.909 in*2\n", + "the crossection area for live load 1.0 is 0.235 in*2\n", + "the crossection area for live load 15 is 0.926 in*2\n" + ] + } + ], + "source": [ + "#Given\n", + "D_n = 5.0 #kips, dead load\n", + "L_n_1 = 1.0 #kips ,live load 1\n", + "L_n_2 = 15 #kips ,live load 2\n", + "stress_allow = 22 #ksi\n", + "phi = 0.9 #probalistic coefficients\n", + "y_stress = 36 #ksi,Yeild strength\n", + "#According to AISR \n", + "\n", + "#a\n", + "p_1 = D_n + L_n_1 #kips since the total load is sum of dead load and live load\n", + "p_2 = D_n + L_n_2 #kips, For second live load\n", + "\n", + "Area_1 = p_1/stress_allow #in*2 ,the allowable area for the allowed stress\n", + "Area_2 = p_2/stress_allow #in*2\n", + "print \"the allowable area for live load\",L_n_1,\"is\",round(Area_1,3),\"in*2\"\n", + "print \"the allowable area for live load\",L_n_2,\"is\",round(Area_2,3),\"in*2\"\n", + "\n", + "#b\n", + "#area_crossection= (1.2*D_n +1.6L_n)/(phi*y_stress)\n", + "\n", + "area_crossection_1= (1.2*D_n +1.6*L_n_1)/(phi*y_stress) #in*2,crossection area for first live load\n", + "area_crossection_2= (1.2*D_n +1.6*L_n_2)/(phi*y_stress) #in*2,crossection area for second live load\n", + "print \"the crossection area for live load\",L_n_1,\"is\",round(area_crossection_1,3),\"in*2\"\n", + "print \"the crossection area for live load\",L_n_2,\"is\",round(area_crossection_2,3),\"in*2\"\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Example 1.8 page number 51" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length of the Weld 1: 2.54 in\n", + "Length of the Weld 2: 4.65 in\n" + ] + } + ], + "source": [ + "#Given\n", + "A_angle = 2 #in*2 \n", + "stress_allow = 20 #ksi, The maximum alowable stress\n", + "F = stress_allow*A_angle #K, The maximum force\n", + "AD = 3 #in, from the figure\n", + "DC = 1.06 #in, from the figure\n", + "strength_AWS = 5.56 # kips/in,Allowable strength according to AWS\n", + "\n", + "#caliculations \n", + "#momentum at point \"d\" is equal to 0\n", + "R_1 = (F*DC)/AD #k,Resultant force developed by the weld\n", + "R_2 = (F*(AD-DC))/AD #k,Resultant force developed by the weld\n", + "\n", + "l_1 = R_1/strength_AWS #in,Length of the Weld 1\n", + "l_2 = R_2/strength_AWS #in,Length of the Weld 2\n", + " \n", + "print \"Length of the Weld 1:\",round(l_1,2),\"in\"\n", + "print \"Length of the Weld 2:\",round(l_2,2),\"in\" \n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety_concepts.ipynb b/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety_concepts.ipynb deleted file mode 100755 index ff9f91c7..00000000 --- a/sample_notebooks/kowshikChilamkurthy/Chapter_1_Stress,Axial_load_and_Safety_concepts.ipynb +++ /dev/null @@ -1,395 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.1 page number 24\n" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The bearing stress at C is 0.875 MPA\n", - "The maximum normal stress in BD bolt is: 62.0 MPA\n", - "The tensile strss at shank of the bolt is: 40.0 MPA\n" - ] - } - ], - "source": [ - "#Given\n", - "import math\n", - "d_bolt = 20.0 #mm,diameter,This is not the minimum area\n", - "d_bolt_min = 16.0 #mm This is at the roots of the thread \n", - "#This yealds maximum stress \n", - "A_crossection = (math.pi)*(d_bolt**2)/4 #mm*2\n", - "A_crossection_min = (math.pi)*(d_bolt_min**2)/4 #mm*2 ,This is minimum area which yeilds maximum stress\n", - "load = 10.0 #KN\n", - "BC = 1.0 #m\n", - "CF = 2.5 #m\n", - "contact_area = 200*200 # mm*2 , The contact area at c\n", - "\n", - "#caliculations \n", - "#Balancing forces in the x direction:\n", - "# Balncing the moments about C and B:\n", - "Fx = 0 \n", - "R_cy = load*(BC+CF) #KN , Reaction at C in y-direction\n", - "R_by = load*(CF) #KN , Reaction at B in y-direction\n", - "#Because of 2 bolts\n", - "stress_max = (R_by/(2*A_crossection_min))*(10**3) # MPA,maximum stess records at minimum area\n", - "stress_shank = (R_by/(2*A_crossection))*(10**3) # MPA\n", - "Bearing_stress_c = (R_cy/contact_area)*(10**3) #MPA, Bearing stress at C\n", - "\n", - "print\"The bearing stress at C is \",(Bearing_stress_c) ,\"MPA\"\n", - "print\"The maximum normal stress in BD bolt is: \",round(stress_max),\"MPA\"\n", - "print\"The tensile strss at shank of the bolt is: \",round(stress_shank),\"MPA\"\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.2 page number 26" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The total weightof pier: 25.0 KN\n", - "The stress at 1 m above is 28.75 MPA\n" - ] - } - ], - "source": [ - "#Given \n", - "load_distributed = 20 #KN/m*2, This is the load distributed over the pier\n", - "H = 2 # m, Total height \n", - "h = 1 #m , point of investigation \n", - "base = 1.5 #m The length of crossection in side veiw \n", - "top = 0.5 #m ,The length where load is distributed on top\n", - "base_inv = 1 #m , the length at the point of investigation \n", - "area = 0.5*1 #m ,The length at a-a crossection \n", - "density_conc = 25 #KN/m*2\n", - "#caliculation of total weight \n", - "\n", - "v_total = ((top+base)/2)*top*H #m*2 ,The total volume \n", - "w_total = v_total* density_conc #KN , The total weight\n", - "R_top = (top**2)*load_distributed #KN , THe reaction force due to load distribution \n", - "reaction_net = w_total + R_top\n", - "\n", - "#caliculation of State of stress at 1m \n", - "v_inv = ((top+base_inv)/2)*top*h #m*2 ,The total volume from 1m to top\n", - "w_inv = v_inv*density_conc #KN , The total weight from 1m to top\n", - "reaction_net = w_inv + R_top #KN\n", - "Stress = reaction_net/area #KN/m*2\n", - "print\"The total weight of pier is\",w_total,\"KN\"\n", - "print\"The stress at 1 m above is\",Stress,\"MPA\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.3 page number 27" - ] - }, - { - "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Tensile stress in main bar AB: 17.89 Ksi\n", - "Tensile stress in clevis of main bar AB: 11.18 Ksi\n", - "Comprensive stress in main bar BC: 12.93 Ksi\n", - "Bearing stress in pin at C: 18.86 Ksi\n", - "torsion stress in pin at C: -25.62 Ksi\n" - ] - } - ], - "source": [ - "#Given\n", - "from math import pow\n", - "d_pins = 0.375 #inch\n", - "load = 3 #Kips\n", - "AB_x = 6 #inch,X-component\n", - "AB_y = 3 #inch,Y-component \n", - "BC_y = 6 #inch,Y-component\n", - "BC_x = 6 #inch,X-component\n", - "area_AB = 0.25*0.5 #inch*2 \n", - "area_net = 0.20*2*(0.875-0.375) #inch*2 \n", - "area_BC = 0.875*0.25 #inch*2 \n", - "area_pin = d_pins*2*0.20 #inch*2 \n", - "area_pin_crossection = 3.14*((d_pins/2)**2)\n", - "#caliculations\n", - "\n", - "slope = AB_y/ AB_x #For AB\n", - "slope = BC_y/ BC_x #For BC\n", - "\n", - "#momentum at point C:\n", - "F_A_x = (load*AB_x )/(BC_y + AB_y ) #Kips, F_A_x X-component of F_A\n", - "\n", - "#momentum at point A:\n", - "F_C_x = -(load*BC_x)/(BC_y + AB_y ) #Kips, F_C_x X-component of F_c\n", - "\n", - "#X,Y components of F_A\n", - "F_A= (pow(5,0.5)/2)*F_A_x #Kips\n", - "F_A_y = 0.5*F_A_x #Kips\n", - "\n", - "#X,Y components of F_C \n", - "F_C= pow(2,0.5)*F_C_x #Kips\n", - "F_C_y = F_C_x #Kips\n", - "\n", - "T_stress_AB = F_A/area_AB #Ksi , Tensile stress in main bar AB\n", - "stress_clevis = F_A/area_net #Ksi ,Tensile stress in clevis of main bar AB\n", - "c_strees_BC = F_C/area_BC #Ksi , Comprensive stress in main bar BC\n", - "B_stress_pin = F_C/area_pin #Ksi , Bearing stress in pin at C\n", - "To_stress_pin = F_C/area_pin_crossection #Ksi , torsion stress in pin at C\n", - "\n", - "print\"Tensile stress in main bar AB:\",round(T_stress_AB,2),\"Ksi\"\n", - "print\"Tensile stress in clevis of main bar AB:\",round(stress_clevis,2),\"Ksi\"\n", - "print\"Comprensive stress in main bar BC:\",round(-c_strees_BC,2),\"Ksi\"\n", - "print\"Bearing stress in pin at C:\",round(-B_stress_pin,2),\"Ksi\"\n", - "print\"torsion stress in pin at C:\",round(To_stress_pin,2),\"Ksi\"\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.4 page number 38" - ] - }, - { - "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The factor 2.5 is less than assumed factor 2.7 so this can be considered\n" - ] - } - ], - "source": [ - "#Given\n", - "strength_steel = 120 #Ksi\n", - "factor = 2.5\n", - "F_C = 2.23 #Ksi\n", - "\n", - "#caliculations\n", - "\n", - "stress_allow = strength_steel/factor #Ksi\n", - "A_net = F_C/strength_steel #in*2 , \n", - "#lets adopt 0.20x0.25 in*2 and check wether we are correct or not? \n", - "\n", - "A_net_assumption = 0.25*0.20 #in*2 , this is assumed area which is near to A_net\n", - "stress = 2.23/A_net_assumption #Ksi\n", - "factor_assumed = strength_steel/stress \n", - "\n", - "if factor_assumed > factor :\n", - " print \"The factor\",factor,\"is less than assumed factor\",round(factor_assumed,1),\"so this can be considered\"\n", - "else:\n", - " print \"The assumed factor\",factor, \"is more than assumed factor\",factor_assumed,\"factor_assumed\"\n", - " \n", - " \n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.6 page number 35" - ] - }, - { - "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The required size of rod is: 49.35 m*2\n" - ] - } - ], - "source": [ - "#Given\n", - "mass = 5 #Kg\n", - "frequency = 10 #Hz\n", - "stress_allow = 200 #MPa\n", - "R = 0.5 #m\n", - "\n", - "#caliculations \n", - "from math import pi\n", - "w = 2*pi*frequency #rad/sec\n", - "a = (w**2)*R #m*2/sec\n", - "F = mass*a #N\n", - "A_req = F/stress_allow #m*2 , The required area for aloowing stress\n", - "print\"The required size of rod is:\",round(A_req,2),\"m*2\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.7 page number 45" - ] - }, - { - "cell_type": "code", - "execution_count": 46, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the allowable area for live load 1.0 is 0.273 in*2\n", - "the allowable area for live load 15 is 0.909 in*2\n", - "the crossection area for live load 1.0 is 0.235 in*2\n", - "the crossection area for live load 15 is 0.926 in*2\n" - ] - } - ], - "source": [ - "#Given\n", - "D_n = 5.0 #kips, dead load\n", - "L_n_1 = 1.0 #kips ,live load 1\n", - "L_n_2 = 15 #kips ,live load 2\n", - "stress_allow = 22 #ksi\n", - "phi = 0.9 #probalistic coefficients\n", - "y_stress = 36 #ksi,Yeild strength\n", - "#According to AISR \n", - "\n", - "#a\n", - "p_1 = D_n + L_n_1 #kips since the total load is sum of dead load and live load\n", - "p_2 = D_n + L_n_2 #kips, For second live load\n", - "\n", - "Area_1 = p_1/stress_allow #in*2 ,the allowable area for the allowed stress\n", - "Area_2 = p_2/stress_allow #in*2\n", - "print \"the allowable area for live load\",L_n_1,\"is\",round(Area_1,3),\"in*2\"\n", - "print \"the allowable area for live load\",L_n_2,\"is\",round(Area_2,3),\"in*2\"\n", - "\n", - "#b\n", - "#area_crossection= (1.2*D_n +1.6L_n)/(phi*y_stress)\n", - "\n", - "area_crossection_1= (1.2*D_n +1.6*L_n_1)/(phi*y_stress) #in*2,crossection area for first live load\n", - "area_crossection_2= (1.2*D_n +1.6*L_n_2)/(phi*y_stress) #in*2,crossection area for second live load\n", - "print \"the crossection area for live load\",L_n_1,\"is\",round(area_crossection_1,3),\"in*2\"\n", - "print \"the crossection area for live load\",L_n_2,\"is\",round(area_crossection_2,3),\"in*2\"\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Example 1.8 page number 51" - ] - }, - { - "cell_type": "code", - "execution_count": 52, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Length of the Weld 1: 2.54 in\n", - "Length of the Weld 2: 4.65 in\n" - ] - } - ], - "source": [ - "#Given\n", - "A_angle = 2 #in*2 \n", - "stress_allow = 20 #ksi, The maximum alowable stress\n", - "F = stress_allow*A_angle #K, The maximum force\n", - "AD = 3 #in, from the figure\n", - "DC = 1.06 #in, from the figure\n", - "strength_AWS = 5.56 # kips/in,Allowable strength according to AWS\n", - "\n", - "#caliculations \n", - "#momentum at point \"d\" is equal to 0\n", - "R_1 = (F*DC)/AD #k,Resultant force developed by the weld\n", - "R_2 = (F*(AD-DC))/AD #k,Resultant force developed by the weld\n", - "\n", - "l_1 = R_1/strength_AWS #in,Length of the Weld 1\n", - "l_2 = R_2/strength_AWS #in,Length of the Weld 2\n", - " \n", - "print \"Length of the Weld 1:\",round(l_1,2),\"in\"\n", - "print \"Length of the Weld 2:\",round(l_2,2),\"in\" \n", - " \n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/kumargugloth/Chapter1.ipynb b/sample_notebooks/kumargugloth/Chapter1.ipynb old mode 100755 new mode 100644 index df9ba4d0..fdfb0cb9 --- a/sample_notebooks/kumargugloth/Chapter1.ipynb +++ b/sample_notebooks/kumargugloth/Chapter1.ipynb @@ -1,7 +1,7 @@ { "metadata": { "name": "", - "signature": "sha256:84e452258bd05b64c16351467c4970051f4494cb47d7a832df03bdce07abddb8" + "signature": "sha256:281275d36b0e16d144d1212530d5ebac420ea6bfd258dbfe43c04ce417d0dbbc" }, "nbformat": 3, "nbformat_minor": 0, @@ -13,7 +13,7 @@ "level": 1, "metadata": {}, "source": [ - "Chapter1-Introduction" + "Chapter1-Atomic Weight " ] }, { @@ -21,34 +21,23 @@ "level": 2, "metadata": {}, "source": [ - "Ex1-pg9" + "Ex1-pg12" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "\n", "import math\n", - " #determine\n", - "##This numerical is Ex 1_1E,page 9.\n", - "Pso=20.5\n", - "Psc=20.5*550##converting hp to fps system\n", - "Qo=385.\n", - "Qc=385./449.##converting gpm to ft^3/s\n", - "E=0.83\n", - "dp=E*Psc/(Qc*144.)\n", - "print\"%s %.2f %s \"%('The pressure rise is ',dp,' psi')\n", - "print(\"After rounding off,pressure rise is 75.8 psi\")\n", - "dpr=75.8\n", - "dHw=75.8*144/62.4##62.4 is accelaration due to gravity in fps system\n", - "print\"%s %.2f %s \"%(' The head of water is ',dHw,' ft of water')\n", - "print(\"After rounding off the value of head of water the answer is 175 ft of water.\")\n", - "dhwr=175##rounded off value of head of water\n", - "sg=0.72##specific gravity of oil\n", - "dHo=dhwr/sg\n", - "print\"%s %.2f %s \"%(' The head of oil is ',dHo,' ft of oil')\n", - "print(\"After rounding off the value of head of oil the answer is 243 ft of oil.\")\n" + "##Intitalisation of variables\n", + "#calculate the Molecular weight of carbon dioxide\n", + "dco= 1.9635 ##gms/lit\n", + "do= 1.4277 ##gms/lit\n", + "mo= 32. ##gms\n", + "##CALCULATIONS\n", + "mwt= dco*mo/do\n", + "##RESULTS\n", + "print'%s %.2f %s'% ('Molecular weight of carbon dioxide = ',mwt,'')\n" ], "language": "python", "metadata": {}, @@ -57,125 +46,7 @@ "output_type": "stream", "stream": "stdout", "text": [ - "The pressure rise is 75.79 psi \n", - "After rounding off,pressure rise is 75.8 psi\n", - " The head of water is 174.92 ft of water \n", - "After rounding off the value of head of water the answer is 175 ft of water.\n", - " The head of oil is 243.06 ft of oil \n", - "After rounding off the value of head of oil the answer is 243 ft of oil.\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2-pg10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math \n", - "#determine\n", - "##This numerical is Ex 1_1S,page 10.\n", - "E=0.83##efficiency\n", - "Ps=15300.\n", - "Q=87.4\n", - "Qs=87.4/3600.##flow rate in meter cube per sec\n", - "rho=998.\n", - "g=9.81\n", - "sg=0.72\n", - "dp=E*Ps/Qs\n", - "print\"%s %.2f %s \"%('\\n The change in pressure (dp)is ',dp,'')\n", - "dpr=523000##rounded value of dp\n", - "print(\"The rounded off value of dp is 523kPa.\")\n", - "dHw=dpr/(rho*g)\n", - "print\"%s %.2f %s \"%(' dHw is equal to ',dHw,' m of water')\n", - "print(\"The rounded off value of dHw is 53.4 m of water.\")\n", - "dHwr=53.4##rounded off value of dHw\n", - "print(\"Thus we can determine head of oil.\")\n", - "dHoil=dHwr/sg\n", - "print\"%s %.2f %s \"%(' dHoil is given by ',dHoil,' m of oil')\n", - "print(\"The rounded off value of dHoil is 74.2 m of oil.\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "\n", - " The change in pressure (dp)is 523070.94 \n", - "The rounded off value of dp is 523kPa.\n", - " dHw is equal to 53.42 m of water \n", - "The rounded off value of dHw is 53.4 m of water.\n", - "Thus we can determine head of oil.\n", - " dHoil is given by 74.17 m of oil \n", - "The rounded off value of dHoil is 74.2 m of oil.\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex3-pg10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#determine\n", - "##This numerical is Ex 1_2E,page 10.\n", - "Q=12000.\n", - "A=3.5\n", - "rho_a=0.0762\n", - "E=0.85\n", - "r=2.5##resistance of duct system\n", - "V=Q/(60.*A)\n", - "print\"%s %.2f %s \"%('The air flow velocity at discharge is ',V,' ft/s')\n", - "KE=(rho_a*(V**2))/(32.2*2)\n", - "print\"%s %.2f %s \"%('\\n The product is ',KE,' lb/ft^2')\n", - "##PE=KE\n", - "Hv=KE/62.4\n", - "print\"%s %.2f %s \"%('\\n The dynamic head is ',Hv,' ft')\n", - "print(\"The value of dynamic head in inches of water is 0.74.\")\n", - "Hvi=0.74##Head in inches\n", - "Ht=r+Hvi\n", - "print\"%s %.2f %s \"%('\\n The total head is ',Ht,' inches of water')\n", - "p_tot=Ht*62.4\n", - "Ps=Q*p_tot/(60.*12.*E)\n", - "print\"%s %.2f %s \"%('\\n The shaft power is ',Ps,' ft-lb/s')\n", - "print(\"The shaft power is 7.2 hp.\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The air flow velocity at discharge is 57.14 ft/s \n", - "\n", - " The product is 3.86 lb/ft^2 \n", - "\n", - " The dynamic head is 0.06 ft \n", - "The value of dynamic head in inches of water is 0.74.\n", - "\n", - " The total head is 3.24 inches of water \n", - "\n", - " The shaft power is 3964.24 ft-lb/s \n", - "The shaft power is 7.2 hp.\n" + "Molecular weight of carbon dioxide = 44.01 \n" ] } ], @@ -186,91 +57,23 @@ "level": 2, "metadata": {}, "source": [ - "Ex4-pg11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##This numerical is Ex 1_2S,page 11.\n", - "Q=340.\n", - "A=0.325\n", - "V=Q/(60.*A)\n", - "print\"%s %.2f %s \"%('The air flow velocity at discharge is ',V,' m/s')\n", - "rho_a=1.22\n", - "Vr=17.4\n", - "Hd=(rho_a*(Vr**2))/2.\n", - "print\"%s %.2f %s \"%('\\n The dynamic pressure head is ',Hd,' Pa')\n", - "Hdr=184.7##rounded off value of Hd\n", - "rho_w=998.##density of water=rhow\n", - "g=9.81\n", - "H=0.0635\n", - "dp=rho_w*g*H##static pressure head\n", - "print\"%s %.2f %s \"%('\\n The static pressure head is ',dp,' Pa')\n", - "dpr=621.7\n", - "p_tot=Hdr+dpr\n", - "print\"%s %.2f %s \"%('\\n The total pressure head is ',p_tot,' Pa')\n", - "p_tot=806.4\n", - "E=0.85##efficiency\n", - "Ps=Q*p_tot/(60*E)\n", - "print\"%s %.2f %s \"%('\\n The shaft power is',Ps, 'W')\n", - "print(\"The shaft power is 5.376 kW.\")\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "The air flow velocity at discharge is 17.44 m/s \n", - "\n", - " The dynamic pressure head is 184.68 Pa \n", - "\n", - " The static pressure head is 621.69 Pa \n", - "\n", - " The total pressure head is 806.40 Pa \n", - "\n", - " The shaft power is 5376.00 W \n", - "The shaft power is 5.376 kW.\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex5-pg11" + "Ex2-pg13" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "#determine \n", "import math\n", - "##This numerical is Ex 1_3E,page 11.\n", - "H=295.##net head in ft\n", - "Q=148.##water flow rate\n", - "n=1800.##rpm\n", - "E=0.87##efficiency\n", - "a=62.4##product of density and accelaration due to gravity\n", - "omega=(n*2.*math.pi)/60.\n", - "dp=a*H\n", - "print\"%s %.2f %s \"%('The pressure is ',dp,' lb/ft^2')\n", - "Ps=E*Q*dp\n", - "print\"%s %.2f %s \"%('\\n Output power is equal to ',Ps,' lb-ft/s')\n", - "print(\"The output output power can also be written as 2.37*10^6 lb-ft/s\")\n", - "print(\"Output power in terms of horsepower is given by 4309hp.\")\n", - "Psr=2370000##rounded off value of Ps\n", - "Torque=Psr/omega\n", - "print\"%s %.2f %s \"%(' The output torque is ',Torque,' lb-ft.')\n", - "print(\"The output torque can also be written as 12.57*10^3 lb-ft\")\n", - "\n" + "##Intitalisation of variables\n", + "#calculate the atomic weight of lead\n", + "shl= 0.031 ##cal deg^-1 g^-1\n", + "ewlc= 103.605 ##gms\n", + "n= 2.\n", + "##CALCULATIONS\n", + "aw= n*ewlc\n", + "##RESULTS\n", + "print'%s %.2f %s'% ('Atomic weight of lead = ',aw,' gms')\n" ], "language": "python", "metadata": {}, @@ -279,49 +82,33 @@ "output_type": "stream", "stream": "stdout", "text": [ - "The pressure is 18408.00 lb/ft^2 \n", - "\n", - " Output power is equal to 2370214.08 lb-ft/s \n", - "The output output power can also be written as 2.37*10^6 lb-ft/s\n", - "Output power in terms of horsepower is given by 4309hp.\n", - " The output torque is 12573.24 lb-ft. \n", - "The output torque can also be written as 12.57*10^3 lb-ft\n" + "Atomic weight of lead = 207.21 gms\n" ] } ], - "prompt_number": 6 + "prompt_number": 3 }, { "cell_type": "heading", "level": 2, "metadata": {}, "source": [ - "Ex6-pg12" + "Ex3-pg13" ] }, { "cell_type": "code", "collapsed": false, "input": [ - "#determine c\n", "import math\n", - "##This numerical is Ex 1_3S,page 12.\n", - "H=90.\n", - "Q=4.2##water flow rate(in m^3/s)\n", - "n=1800.\n", - "E=0.87##efficiency\n", - "rho=998.\n", - "g=9.81\n", - "omega=(n*2.*math.pi)/60.\n", - "dp=rho*g*H\n", - "print\"%s %.2f %s \"%('The pressure is ',dp,' N/m^2')\n", - "Ps=E*Q*dp\n", - "print\"%s %.2f %s \"%('\\n Output power is equal to ',Ps,' N-m/s')\n", - "print(\"After rounding off the value of output power is 3220 kW.\")\n", - "Psr=3220000.##rounded off value of Ps\n", - "Torque=Psr/omega\n", - "print\"%s %.2f %s \"%(' The output torque is ',Torque,' N-m.')\n", - "print(\"After rounding off the output torque comes out to be 17.1*10^3 N-m.\")\n" + "##Intitalisation of variables\n", + "\n", + "ewt= 17.337 ##gms\n", + "n=3.\n", + "##CALCULATIONS\n", + "aw= ewt*n\n", + "##RESULTS\n", + "print'%s %.2f %s'% ('Atomic weight of chromium = ',aw,' gms')\n" ], "language": "python", "metadata": {}, @@ -330,16 +117,11 @@ "output_type": "stream", "stream": "stdout", "text": [ - "The pressure is 881134.20 N/m^2 \n", - "\n", - " Output power is equal to 3219664.37 N-m/s \n", - "After rounding off the value of output power is 3220 kW.\n", - " The output torque is 17082.63 N-m. \n", - "After rounding off the output torque comes out to be 17.1*10^3 N-m.\n" + "Atomic weight of chromium = 52.01 gms\n" ] } ], - "prompt_number": 7 + "prompt_number": 2 } ], "metadata": {} diff --git a/sample_notebooks/kumargugloth/Chapter1_wopEYRj.ipynb b/sample_notebooks/kumargugloth/Chapter1_wopEYRj.ipynb deleted file mode 100644 index fdfb0cb9..00000000 --- a/sample_notebooks/kumargugloth/Chapter1_wopEYRj.ipynb +++ /dev/null @@ -1,130 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:281275d36b0e16d144d1212530d5ebac420ea6bfd258dbfe43c04ce417d0dbbc" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter1-Atomic Weight " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex1-pg12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "##Intitalisation of variables\n", - "#calculate the Molecular weight of carbon dioxide\n", - "dco= 1.9635 ##gms/lit\n", - "do= 1.4277 ##gms/lit\n", - "mo= 32. ##gms\n", - "##CALCULATIONS\n", - "mwt= dco*mo/do\n", - "##RESULTS\n", - "print'%s %.2f %s'% ('Molecular weight of carbon dioxide = ',mwt,'')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Molecular weight of carbon dioxide = 44.01 \n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex2-pg13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "##Intitalisation of variables\n", - "#calculate the atomic weight of lead\n", - "shl= 0.031 ##cal deg^-1 g^-1\n", - "ewlc= 103.605 ##gms\n", - "n= 2.\n", - "##CALCULATIONS\n", - "aw= n*ewlc\n", - "##RESULTS\n", - "print'%s %.2f %s'% ('Atomic weight of lead = ',aw,' gms')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Atomic weight of lead = 207.21 gms\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Ex3-pg13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "##Intitalisation of variables\n", - "\n", - "ewt= 17.337 ##gms\n", - "n=3.\n", - "##CALCULATIONS\n", - "aw= ewt*n\n", - "##RESULTS\n", - "print'%s %.2f %s'% ('Atomic weight of chromium = ',aw,' gms')\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Atomic weight of chromium = 52.01 gms\n" - ] - } - ], - "prompt_number": 2 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber.ipynb b/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber.ipynb new file mode 100755 index 00000000..7649fb45 --- /dev/null +++ b/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber.ipynb @@ -0,0 +1,251 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:256c8b99e0e56930e177cf311c8d82ebc12805b19dc6acba2736a9016b128039" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1: Overview of optical fiber communication" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1, Page Number: 8" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable declaration\n", + "f1 = 100*1e3 #frequency1 = 100KHz\n", + "f2 = 1e9 #frequency2 = 1GHz\n", + "T1 = 1.0/f1 #Time period1 = 0.01ms\n", + "T2 = 1.0/f2 #Time period2 = 1 ns\n", + "\n", + "#calculation\n", + "phi = (0.25)*360.0 # Phase shift(degree)\n", + "\n", + "#result\n", + "print \"Phase shift = \",round(phi),\"Degree\",\"= \",round((round(phi)*math.pi)/180,4), \"radian\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Phase shift = 90.0 Degree = 1.5708 radian\n" + ] + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2, Page Number: 10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable Declaration\n", + "flow=10*1e3 #Lowest frequency\n", + "fhigh=100*1e3 #Highest frequency\n", + "\n", + "#calculation\n", + "bandwidth=fhigh-flow\n", + "\n", + "#result\n", + "print \"Bandwidth=\",bandwidth/1000 ,\"KHz\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Bandwidth= 90.0 KHz\n" + ] + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4, Page Number: 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable Declaration\n", + "B = 10*1e6 # Bandwidth of noisy channel 1MHZ\n", + "S_N = 1 # signal to noise ratio is 1\n", + "\n", + "#calculation\n", + "C=B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)\n", + "\n", + "#result\n", + "print \"Capacity of channel =\",C/(10*1e6),\"Mb/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Capacity of channel = 1.0 Mb/s\n" + ] + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.5, Page Number: 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable Declaration\n", + "fLow = 3*1e6 #low frequency = 3MHz\n", + "fHigh = 4*1e6 #high frequency = 4MHz\n", + "SNR_dB = 20 #signal to noise ratio 20 dB\n", + "\n", + "#calculation\n", + "B = fHigh-fLow #Bandwidth(MHz)\n", + "S_N = 10**(SNR_dB/10)\n", + "C = B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)\n", + "\n", + "#result\n", + "print \"Capacity of channel=\",round(C/(1e6),1),\"Mb/s\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Capacity of channel= 6.7 Mb/s\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6, Page Number: 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable Declaration\n", + "P1 = 1 # Let p1 be 1 watt\n", + "P2 = P1*0.5 # P2 is half of p1 so 1/2\n", + "\n", + "#calculation\n", + "Atten_dB = 10*(math.log(P2/P1)/math.log(10)) #attenuation or loss of power(dB)\n", + "\n", + "#result\n", + "print \"Attenuation loss =\",round(Atten_dB,0), \"dB\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Attenuation loss = -3.0 dB\n" + ] + } + ], + "prompt_number": 28 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.7, Page Number: 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import math\n", + "\n", + "#variable Declaration\n", + "Loss_line1 = -9 #attenuation of signal between point 1 to 2 = 9 dB\n", + "Amp_gain2 = 14 #Amplification of signal between point 2 to 3 = 14 dB\n", + "Loss_line3 = -3 #attenuation of signal between point 3 to 4 = 3 dB\n", + "\n", + "#calculation\n", + "dB_at_line4 = Loss_line1+Amp_gain2+Loss_line3 #power gain\n", + "\n", + "#result\n", + "print \"Power gain for a signal travelling from point1 to another point4 = \",dB_at_line4, \"dB\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Power gain for a signal travelling from point1 to another point4 = 2 dB\n" + ] + } + ], + "prompt_number": 29 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber_communication.ipynb b/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber_communication.ipynb deleted file mode 100755 index 7649fb45..00000000 --- a/sample_notebooks/kushrami/Chapter_1_-_Overview_of_optical_fiber_communication.ipynb +++ /dev/null @@ -1,251 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:256c8b99e0e56930e177cf311c8d82ebc12805b19dc6acba2736a9016b128039" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1: Overview of optical fiber communication" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1, Page Number: 8" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable declaration\n", - "f1 = 100*1e3 #frequency1 = 100KHz\n", - "f2 = 1e9 #frequency2 = 1GHz\n", - "T1 = 1.0/f1 #Time period1 = 0.01ms\n", - "T2 = 1.0/f2 #Time period2 = 1 ns\n", - "\n", - "#calculation\n", - "phi = (0.25)*360.0 # Phase shift(degree)\n", - "\n", - "#result\n", - "print \"Phase shift = \",round(phi),\"Degree\",\"= \",round((round(phi)*math.pi)/180,4), \"radian\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Phase shift = 90.0 Degree = 1.5708 radian\n" - ] - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2, Page Number: 10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable Declaration\n", - "flow=10*1e3 #Lowest frequency\n", - "fhigh=100*1e3 #Highest frequency\n", - "\n", - "#calculation\n", - "bandwidth=fhigh-flow\n", - "\n", - "#result\n", - "print \"Bandwidth=\",bandwidth/1000 ,\"KHz\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Bandwidth= 90.0 KHz\n" - ] - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4, Page Number: 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable Declaration\n", - "B = 10*1e6 # Bandwidth of noisy channel 1MHZ\n", - "S_N = 1 # signal to noise ratio is 1\n", - "\n", - "#calculation\n", - "C=B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)\n", - "\n", - "#result\n", - "print \"Capacity of channel =\",C/(10*1e6),\"Mb/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Capacity of channel = 1.0 Mb/s\n" - ] - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.5, Page Number: 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable Declaration\n", - "fLow = 3*1e6 #low frequency = 3MHz\n", - "fHigh = 4*1e6 #high frequency = 4MHz\n", - "SNR_dB = 20 #signal to noise ratio 20 dB\n", - "\n", - "#calculation\n", - "B = fHigh-fLow #Bandwidth(MHz)\n", - "S_N = 10**(SNR_dB/10)\n", - "C = B*(math.log(1+S_N)/math.log(2)) #capacity of channel(Mb/s)\n", - "\n", - "#result\n", - "print \"Capacity of channel=\",round(C/(1e6),1),\"Mb/s\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Capacity of channel= 6.7 Mb/s\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6, Page Number: 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable Declaration\n", - "P1 = 1 # Let p1 be 1 watt\n", - "P2 = P1*0.5 # P2 is half of p1 so 1/2\n", - "\n", - "#calculation\n", - "Atten_dB = 10*(math.log(P2/P1)/math.log(10)) #attenuation or loss of power(dB)\n", - "\n", - "#result\n", - "print \"Attenuation loss =\",round(Atten_dB,0), \"dB\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Attenuation loss = -3.0 dB\n" - ] - } - ], - "prompt_number": 28 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.7, Page Number: 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "import math\n", - "\n", - "#variable Declaration\n", - "Loss_line1 = -9 #attenuation of signal between point 1 to 2 = 9 dB\n", - "Amp_gain2 = 14 #Amplification of signal between point 2 to 3 = 14 dB\n", - "Loss_line3 = -3 #attenuation of signal between point 3 to 4 = 3 dB\n", - "\n", - "#calculation\n", - "dB_at_line4 = Loss_line1+Amp_gain2+Loss_line3 #power gain\n", - "\n", - "#result\n", - "print \"Power gain for a signal travelling from point1 to another point4 = \",dB_at_line4, \"dB\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Power gain for a signal travelling from point1 to another point4 = 2 dB\n" - ] - } - ], - "prompt_number": 29 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/lalithap/CHAPTER_10.ipynb b/sample_notebooks/lalithap/CHAPTER_10.ipynb deleted file mode 100755 index d98f5fa8..00000000 --- a/sample_notebooks/lalithap/CHAPTER_10.ipynb +++ /dev/null @@ -1,438 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:3d39a49f35ba76bcb7868f57a95e89d561517d277091abd70ccf055ceb540b97" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 10-Wireless Communication Systems\n" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.1- PG NO.351" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page 351\n", - "BW=12.5*10.**3.\n", - "TDR1=512.#transmission data rate\n", - "SPef1=TDR1/BW#spectral efficiency\n", - "\n", - "TDR2=1200.\n", - "SPef2=TDR2/BW\n", - "\n", - "TDR3=2400.\n", - "SPef3=TDR3/BW\n", - "print'%s %.2f' %('the spectral efficiency in bps/Hz at 512 bps transmission data rate',SPef1)\n", - "print'%s %.3f' %('the spectral efficiency in bps/Hz at 1200 bps transmission data rate',SPef2)\n", - "print'%s %.3f' %('the spectral efficiency in bps/Hz at 2400 bps transmission data rate',SPef3)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the spectral efficiency in bps/Hz at 512 bps transmission data rate 0.04\n", - "the spectral efficiency in bps/Hz at 1200 bps transmission data rate 0.096\n", - "the spectral efficiency in bps/Hz at 2400 bps transmission data rate 0.192\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.2- PG NO.352" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.352\n", - "import math\n", - "P4dBW=-34.\n", - "PdBm4=P4dBW-30.\n", - "PW4=10**((PdBm4/10))\n", - "print '%s %.10f' %('minimum power level of class IV phone in mW',PW4)\n", - "\n", - "ERP1dBW=6.\n", - "PdBm1=ERP1dBW-30.\n", - "PW1=10.**((PdBm1/10.))\n", - "\n", - "print '%s %.6f' %('ERP of class I phone in mW',PW1)\n", - "R=PW1/PW4\n", - "RdB=10.*math.log(R)\n", - "\n", - "print '%s %.10f %s %.10f' %('minimum power level for a class I phone is greater than \\nminimum power level of class IV phone by factor of',RdB,'dB or',R)\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "minimum power level of class IV phone in mW 0.0000003981\n", - "ERP of class I phone in mW 0.003981\n", - "minimum power level for a class I phone is greater than \n", - "minimum power level of class IV phone by factor of 92.1034037198 dB or 10000.0000000000\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.3- PG NO.353" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.353\n", - "BW=25.*10.**3.#bandwidth of POCSAG=bandwidth of FLEX system\n", - "\n", - "TDR1=1200.# transmission data rate\n", - "SPef1=TDR1/BW#spectral efficiency\n", - "\n", - "TDR2=6400.\n", - "SPef2=TDR2/BW\n", - "print '%s %.3f' %('the spectral efficiency in bps/Hz at 1200 bps transmission data rate in POCSAG paging system',SPef1)\n", - "print '%s %.3f' %('the spectral efficiency in bps/Hz at 6400 bps transmission data rate in FLEX paging system',SPef2,)\n", - "\n", - "Cinc=TDR2/TDR1\n", - "print '%s %.1f' %('estimating increase in capacity in times',Cinc)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the spectral efficiency in bps/Hz at 1200 bps transmission data rate in POCSAG paging system 0.048\n", - "the spectral efficiency in bps/Hz at 6400 bps transmission data rate in FLEX paging system 0.256\n", - "estimating increase in capacity in times 5.3\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.6- PG NO.367" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.367\n", - "Bt=12.5*10.**6.\n", - "Bg=10.*10.**3.\n", - "B2g=2.*Bg#Guard band on both the ends\n", - "ABW=Bt-B2g\n", - "Bc=30000.#channel bandwidth\n", - "N=ABW/Bc\n", - "print '%s %d' %('total no. of channels available in the system',N)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "total no. of channels available in the system 416\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.8- PG NO.374" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.374\n", - "ERPmax1dB=6.\n", - "ERPmax2dB=-2.\n", - "DiffdB=ERPmax1dB-ERPmax2dB\n", - "Diff=10.**(DiffdB/10.)\n", - "Rfree=5.*(Diff)**(1./2.)#free space-case(a)\n", - "Rtypc=5.*(Diff)**(1./4.)#signal attenuation is proportional to 4th power-case(b)\n", - "print '%s %.1f' %('maximum communication range in km in a free space propogation condition-case(a)',Rfree)\n", - "print '%s %.2f' %('maximum communication range in km when signal attenuation is proportional to 4th power-case(b)',Rtypc)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "maximum communication range in km in a free space propogation condition-case(a) 12.6\n", - "maximum communication range in km when signal attenuation is proportional to 4th power-case(b) 7.92\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.11- PG NO.385" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no. 385\n", - "import math\n", - "P4dBW=-34.\n", - "PdBm4=P4dBW-30.\n", - "PW4=10.**((PdBm4/10.))\n", - "print '%s %.10f' %('minimum power level of class IV phone in mW',PW4)\n", - "\n", - "ERP1dBW=6.\n", - "PdBm1=ERP1dBW-30.\n", - "PW1=10.**((PdBm1/10.))\n", - "\n", - "print '%s %.6f' %('ERP of class I phone in mW',PW1)\n", - "R=PW1/PW4\n", - "RdB=10.*math.log(R)\n", - "\n", - "print '%s %.6f %s %.6f' %('minimum power level for a class I phone is greater than\\nminimum power level of class IV phone by factor of',RdB,'dB or',R)\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "minimum power level of class IV phone in mW 0.0000003981\n", - "ERP of class I phone in mW 0.003981\n", - "minimum power level for a class I phone is greater than\n", - "minimum power level of class IV phone by factor of 92.103404 dB or 10000.000000\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.12- PG NO.387" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.387\n", - "spfl=810*10**6\n", - "spfu=826*10**6\n", - "sprl=940*10**6\n", - "spru=956*10**6\n", - "BWf=spfu-spfl\n", - "BWr=spru-sprl\n", - "\n", - "BWc=10./100.*BWf#BWf=BWr(universal standard)\n", - "BWv=BWf-BWc\n", - "nsc=1150.\n", - "BWmax=BWv/nsc\n", - "SPef=1.68\n", - "CDRmax=BWmax*SPef\n", - "FECcr=0.5\n", - "DRnmax=FECcr*CDRmax\n", - "print '%s %.6f' %('there is a speech coder with a max. data rate of in bps',DRnmax)\n", - "\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "there is a speech coder with a max. data rate of in bps 10518.260870\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.13- PG NO.388" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.388\n", - "d=40.*10.**0.\n", - "npf=6.\n", - "dts=d/npf#duration of a time slot of a voice frame\n", - "nbv=1944.\n", - "nbpts=nbv/npf#no. of bits per time slot\n", - "db=d/nbv#duration of a bit in secs\n", - "npg=6.\n", - "tg=db*npg#guard time in secs\n", - "c=3.*10.**8.\n", - "Disrt=c*tg\n", - "Dismx=Disrt/2.#max. distance\n", - "print '%s %.4f' %('duration of a time slot of a voice frame in secs',dts)\n", - "print '%s %d' %('no. of bits per time slot',nbpts)\n", - "print '%s %.2f' %('duration of a bit in microsecs',db*1000)\n", - "print '%s %d' %('guard time in microsecs',tg*1000)\n", - "print '%s %.2f' %('maximum distance between a cell site and a mobile in kilometres',Dismx/1000000)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "duration of a time slot of a voice frame in secs 6.6667\n", - "no. of bits per time slot 324\n", - "duration of a bit in microsecs 20.58\n", - "guard time in microsecs 123\n", - "maximum distance between a cell site and a mobile in kilometres 18.52\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.14- PG NO.389" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.389\n", - "dv=40.*10.**-3.\n", - "nps=1./dv\n", - "nbpv=1944.\n", - "TGrbr=nbpv*25.\n", - "TGrbaur=TGrbr/2.#2 bits/symbol for pi/4 qpsk mod\n", - "CBW=30.*10.**3.\n", - "BWef=TGrbr/CBW\n", - "print '%s %.1f' %('total gross bit rate for the RF signal in Kbps',TGrbr/1000)\n", - "print '%s %.1f' %('total gross baud rate for the RF signal in Kbps',TGrbaur/1000)\n", - "print '%s %.1f' %('bandwidth efficiency in bps/Hz',BWef)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "total gross bit rate for the RF signal in Kbps 48.6\n", - "total gross baud rate for the RF signal in Kbps 24.3\n", - "bandwidth efficiency in bps/Hz 1.6\n" - ] - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 10.15- PG NO.391" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#PAGE NO.391\n", - "Bt=12.5*10.**6.\n", - "Bc=30.*10.**3.\n", - "K=7.#frequency reuse factor\n", - "N=Bt/Bc#total no. of available channels\n", - "M=N*(1./K)#user capacity per cell \n", - "\n", - "Nu=3.#no. of users/channel\n", - "NU=N*Nu\n", - "K1=4.\n", - "M1=NU*(1./K1)\n", - "\n", - "print '%s %d' %('capacity of 1G AMPS FDMA analog cellular system in users/cell',M)\n", - "print '%s %d' %('capacity of 2G IS-136 TDMA digital cellular system in users/cell',M1)\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "capacity of 1G AMPS FDMA analog cellular system in users/cell 59\n", - "capacity of 2G IS-136 TDMA digital cellular system in users/cell 312\n" - ] - } - ], - "prompt_number": 10 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/lalithap/lalithap_version_backup/CHAPTER_10.ipynb b/sample_notebooks/lalithap/lalithap_version_backup/CHAPTER_10.ipynb new file mode 100755 index 00000000..d98f5fa8 --- /dev/null +++ b/sample_notebooks/lalithap/lalithap_version_backup/CHAPTER_10.ipynb @@ -0,0 +1,438 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:3d39a49f35ba76bcb7868f57a95e89d561517d277091abd70ccf055ceb540b97" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 10-Wireless Communication Systems\n" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.1- PG NO.351" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page 351\n", + "BW=12.5*10.**3.\n", + "TDR1=512.#transmission data rate\n", + "SPef1=TDR1/BW#spectral efficiency\n", + "\n", + "TDR2=1200.\n", + "SPef2=TDR2/BW\n", + "\n", + "TDR3=2400.\n", + "SPef3=TDR3/BW\n", + "print'%s %.2f' %('the spectral efficiency in bps/Hz at 512 bps transmission data rate',SPef1)\n", + "print'%s %.3f' %('the spectral efficiency in bps/Hz at 1200 bps transmission data rate',SPef2)\n", + "print'%s %.3f' %('the spectral efficiency in bps/Hz at 2400 bps transmission data rate',SPef3)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the spectral efficiency in bps/Hz at 512 bps transmission data rate 0.04\n", + "the spectral efficiency in bps/Hz at 1200 bps transmission data rate 0.096\n", + "the spectral efficiency in bps/Hz at 2400 bps transmission data rate 0.192\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.2- PG NO.352" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.352\n", + "import math\n", + "P4dBW=-34.\n", + "PdBm4=P4dBW-30.\n", + "PW4=10**((PdBm4/10))\n", + "print '%s %.10f' %('minimum power level of class IV phone in mW',PW4)\n", + "\n", + "ERP1dBW=6.\n", + "PdBm1=ERP1dBW-30.\n", + "PW1=10.**((PdBm1/10.))\n", + "\n", + "print '%s %.6f' %('ERP of class I phone in mW',PW1)\n", + "R=PW1/PW4\n", + "RdB=10.*math.log(R)\n", + "\n", + "print '%s %.10f %s %.10f' %('minimum power level for a class I phone is greater than \\nminimum power level of class IV phone by factor of',RdB,'dB or',R)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "minimum power level of class IV phone in mW 0.0000003981\n", + "ERP of class I phone in mW 0.003981\n", + "minimum power level for a class I phone is greater than \n", + "minimum power level of class IV phone by factor of 92.1034037198 dB or 10000.0000000000\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.3- PG NO.353" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.353\n", + "BW=25.*10.**3.#bandwidth of POCSAG=bandwidth of FLEX system\n", + "\n", + "TDR1=1200.# transmission data rate\n", + "SPef1=TDR1/BW#spectral efficiency\n", + "\n", + "TDR2=6400.\n", + "SPef2=TDR2/BW\n", + "print '%s %.3f' %('the spectral efficiency in bps/Hz at 1200 bps transmission data rate in POCSAG paging system',SPef1)\n", + "print '%s %.3f' %('the spectral efficiency in bps/Hz at 6400 bps transmission data rate in FLEX paging system',SPef2,)\n", + "\n", + "Cinc=TDR2/TDR1\n", + "print '%s %.1f' %('estimating increase in capacity in times',Cinc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the spectral efficiency in bps/Hz at 1200 bps transmission data rate in POCSAG paging system 0.048\n", + "the spectral efficiency in bps/Hz at 6400 bps transmission data rate in FLEX paging system 0.256\n", + "estimating increase in capacity in times 5.3\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.6- PG NO.367" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.367\n", + "Bt=12.5*10.**6.\n", + "Bg=10.*10.**3.\n", + "B2g=2.*Bg#Guard band on both the ends\n", + "ABW=Bt-B2g\n", + "Bc=30000.#channel bandwidth\n", + "N=ABW/Bc\n", + "print '%s %d' %('total no. of channels available in the system',N)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "total no. of channels available in the system 416\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.8- PG NO.374" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.374\n", + "ERPmax1dB=6.\n", + "ERPmax2dB=-2.\n", + "DiffdB=ERPmax1dB-ERPmax2dB\n", + "Diff=10.**(DiffdB/10.)\n", + "Rfree=5.*(Diff)**(1./2.)#free space-case(a)\n", + "Rtypc=5.*(Diff)**(1./4.)#signal attenuation is proportional to 4th power-case(b)\n", + "print '%s %.1f' %('maximum communication range in km in a free space propogation condition-case(a)',Rfree)\n", + "print '%s %.2f' %('maximum communication range in km when signal attenuation is proportional to 4th power-case(b)',Rtypc)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "maximum communication range in km in a free space propogation condition-case(a) 12.6\n", + "maximum communication range in km when signal attenuation is proportional to 4th power-case(b) 7.92\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.11- PG NO.385" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no. 385\n", + "import math\n", + "P4dBW=-34.\n", + "PdBm4=P4dBW-30.\n", + "PW4=10.**((PdBm4/10.))\n", + "print '%s %.10f' %('minimum power level of class IV phone in mW',PW4)\n", + "\n", + "ERP1dBW=6.\n", + "PdBm1=ERP1dBW-30.\n", + "PW1=10.**((PdBm1/10.))\n", + "\n", + "print '%s %.6f' %('ERP of class I phone in mW',PW1)\n", + "R=PW1/PW4\n", + "RdB=10.*math.log(R)\n", + "\n", + "print '%s %.6f %s %.6f' %('minimum power level for a class I phone is greater than\\nminimum power level of class IV phone by factor of',RdB,'dB or',R)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "minimum power level of class IV phone in mW 0.0000003981\n", + "ERP of class I phone in mW 0.003981\n", + "minimum power level for a class I phone is greater than\n", + "minimum power level of class IV phone by factor of 92.103404 dB or 10000.000000\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.12- PG NO.387" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.387\n", + "spfl=810*10**6\n", + "spfu=826*10**6\n", + "sprl=940*10**6\n", + "spru=956*10**6\n", + "BWf=spfu-spfl\n", + "BWr=spru-sprl\n", + "\n", + "BWc=10./100.*BWf#BWf=BWr(universal standard)\n", + "BWv=BWf-BWc\n", + "nsc=1150.\n", + "BWmax=BWv/nsc\n", + "SPef=1.68\n", + "CDRmax=BWmax*SPef\n", + "FECcr=0.5\n", + "DRnmax=FECcr*CDRmax\n", + "print '%s %.6f' %('there is a speech coder with a max. data rate of in bps',DRnmax)\n", + "\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "there is a speech coder with a max. data rate of in bps 10518.260870\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.13- PG NO.388" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.388\n", + "d=40.*10.**0.\n", + "npf=6.\n", + "dts=d/npf#duration of a time slot of a voice frame\n", + "nbv=1944.\n", + "nbpts=nbv/npf#no. of bits per time slot\n", + "db=d/nbv#duration of a bit in secs\n", + "npg=6.\n", + "tg=db*npg#guard time in secs\n", + "c=3.*10.**8.\n", + "Disrt=c*tg\n", + "Dismx=Disrt/2.#max. distance\n", + "print '%s %.4f' %('duration of a time slot of a voice frame in secs',dts)\n", + "print '%s %d' %('no. of bits per time slot',nbpts)\n", + "print '%s %.2f' %('duration of a bit in microsecs',db*1000)\n", + "print '%s %d' %('guard time in microsecs',tg*1000)\n", + "print '%s %.2f' %('maximum distance between a cell site and a mobile in kilometres',Dismx/1000000)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "duration of a time slot of a voice frame in secs 6.6667\n", + "no. of bits per time slot 324\n", + "duration of a bit in microsecs 20.58\n", + "guard time in microsecs 123\n", + "maximum distance between a cell site and a mobile in kilometres 18.52\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.14- PG NO.389" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.389\n", + "dv=40.*10.**-3.\n", + "nps=1./dv\n", + "nbpv=1944.\n", + "TGrbr=nbpv*25.\n", + "TGrbaur=TGrbr/2.#2 bits/symbol for pi/4 qpsk mod\n", + "CBW=30.*10.**3.\n", + "BWef=TGrbr/CBW\n", + "print '%s %.1f' %('total gross bit rate for the RF signal in Kbps',TGrbr/1000)\n", + "print '%s %.1f' %('total gross baud rate for the RF signal in Kbps',TGrbaur/1000)\n", + "print '%s %.1f' %('bandwidth efficiency in bps/Hz',BWef)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "total gross bit rate for the RF signal in Kbps 48.6\n", + "total gross baud rate for the RF signal in Kbps 24.3\n", + "bandwidth efficiency in bps/Hz 1.6\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 10.15- PG NO.391" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#PAGE NO.391\n", + "Bt=12.5*10.**6.\n", + "Bc=30.*10.**3.\n", + "K=7.#frequency reuse factor\n", + "N=Bt/Bc#total no. of available channels\n", + "M=N*(1./K)#user capacity per cell \n", + "\n", + "Nu=3.#no. of users/channel\n", + "NU=N*Nu\n", + "K1=4.\n", + "M1=NU*(1./K1)\n", + "\n", + "print '%s %d' %('capacity of 1G AMPS FDMA analog cellular system in users/cell',M)\n", + "print '%s %d' %('capacity of 2G IS-136 TDMA digital cellular system in users/cell',M1)\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "capacity of 1G AMPS FDMA analog cellular system in users/cell 59\n", + "capacity of 2G IS-136 TDMA digital cellular system in users/cell 312\n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/maheshvattikuti/chapter1.ipynb b/sample_notebooks/maheshvattikuti/chapter1.ipynb deleted file mode 100755 index 9eda293b..00000000 --- a/sample_notebooks/maheshvattikuti/chapter1.ipynb +++ /dev/null @@ -1,1147 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "# chapter1: De Broglie Matter Waves" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.1;page no:10" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.1,page no:10\n", - "\n", - " de Broglie wavelength of earth in metres is= 3.68e-63\n" - ] - } - ], - "source": [ - "# cal of de brogle wavelength of earth\n", - "#intiation of all variables \n", - "#given that\n", - "M = 6.*10**24 # Mass of earth in Kg\n", - "v = 3.*10**4 # Orbital velocity of earth in m/s\n", - "h = 6.625*10**-34 # Plank constant\n", - "print(\"Example 1.1,page no:10\")\n", - "lamda=h/(M*v) \n", - "print(\"\\n de Broglie wavelength of earth in metres is=\"),round(lamda,65)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.2;page no:10" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.2,page no:11\n", - "\n", - " de Broglie wavelength of body in metres is= 6.625e-35\n" - ] - } - ], - "source": [ - "#cal of de Broglie wavelength of body\n", - "#intiation of all variables\n", - "#given that\n", - "M = 1 # Mass of object in Kg\n", - "v = 10 # velocity of object in m/s\n", - "h = 6.625*10**-34 # Plank constant\n", - "print(\"Example 1.2,page no:11\");\n", - "lamda=h/(M*v)#calculation of de Broglie wavelength\n", - "print(\"\\n de Broglie wavelength of body in metres is=\"),round(lamda,38)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.3;page no:11" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.3,page no:11\n", - "\n", - " de Broglie wavelength of body in metres is= 6.625e-09\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of body\n", - "#intiation of all variables \n", - "# Given that\n", - "m = 1e-30 # Mass of any object in Kg\n", - "v = 1e5 # velocity of object in m/s\n", - "h = 6.625e-34 # Plank constant\n", - "print(\"Example 1.3,page no:11\")\n", - "lamda=h/(m*v) # calculation of de Broglie wavelength in metres\n", - "print(\"\\n de Broglie wavelength of body in metres is=\"),round(lamda,12)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "##example 1.4;page no:15" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.4,page no:15\n", - "velocity of electron in m/s: 1000.0\n", - "momentum of electron in Kgm/s: 9.1e-28\n", - "de Broglie wavelength of electron is: 7.27e-07\n", - "Note:The value given in the book for lamda is wrong hence corrected above\n" - ] - } - ], - "source": [ - "#cal of velocity,momenteum and wave lenght of electron\n", - "#intiation of all variables \n", - "# Given that\n", - "import math\n", - "KE = 4.55e-25 # Kinetic energy of an electron in Joule\n", - "m = 9.1e-31 # Mass of any object in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.4,page no:15\")\n", - "v = math.sqrt(2*KE/m) # Calculation of velocity of moving electron\n", - "p = m*v #Calculation of momentum of moving electron\n", - "lamda= h/p # calculation of de Broglie wavelength\n", - "print(\"velocity of electron in m/s:\"),round(v)\n", - "print(\"momentum of electron in Kgm/s:\"),round(p,29)\n", - "print(\"de Broglie wavelength of electron is:\"),round(lamda,9)\n", - "print(\"Note:The value given in the book for lamda is wrong hence corrected above\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.5;page no:16" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.5,page no:16\n", - "de Broglie wavelength of proton is: 2.645e-14\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of proton\n", - "#intiation of all variables \n", - "#Given that\n", - "c = 3e8 # speed of light in m/s\n", - "v = c/20 # Speed of proton in m/s\n", - "m = 1.67e-27 # Mass of proton in Kg\n", - "h = 6.625e-34 # Plank constant\n", - "print(\"Example 1.5,page no:16\")\n", - "lamda= h/(m*v) # calculation of de Broglie wavelength\n", - "print(\"de Broglie wavelength of proton is:\"),round(lamda,17)\n", - "# Answer in book is 6.645e-14m which is a calculation mistake\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.6;page no:16" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.6,page no:16\n", - "\n", - " de Broglie wavelength of neutron in angstrom= 7.99e-05\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of neutron\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "e = 12.8 # Energy of neutron in MeV\n", - "c = 3.e8 # speed of light in m/s\n", - "m = 1.675e-27 # Mass of neutron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.6,page no:16\")\n", - "rest_e = m*c**2/(1e6*1.6e-19)# rest mass energy of neutron in MeV\n", - "if e/rest_e < 0.015:\n", - "\tE = e\n", - "else:\n", - "\tE = rest_e +e\n", - "lamda = h/(math.sqrt(2*m*e*1e6*1.6e-19)) # calculation of de Broglie wavelength\n", - "print(\"\\n de Broglie wavelength of neutron in angstrom=\"),round(lamda*1e10,7)\n", - "# Answer in book is 8.04e-5 angstrom which is misprinted\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.7;page no:17" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.7,page no:17\n", - "\n", - " de Broglie wavelength of neutron in angstrom= 1.734\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of neutron\n", - "#intiation of all variables \n", - "#Given that\n", - "import math\n", - "e = 1.602e-19 # charge on electron in coulomb\n", - "V = 50. # Applied voltage in volts\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.7,page no:17\")\n", - "lamda= h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", - "print(\"\\n de Broglie wavelength of neutron in angstrom=\"),round(lamda*1e10,3)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.9;page no:18" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.9,page no:18\n", - "de Broglie wavelength associated with the electron in angstrom= 1.67\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength associated with the electron\n", - "#intiation of all variables \n", - "#Given that\n", - "import math\n", - "e = 1.6e-19 # charge on electron in coulomb\n", - "V = 54 # Applied voltage in volts\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.9,page no:18\")\n", - "lamda = h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", - "print(\"de Broglie wavelength associated with the electron in angstrom=\"),round(lamda*1e10,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.10;page no:19" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.10,page no:19\n", - "velocity of electron in m/s: 59299945.33\n", - "momentum of electron in Kgm/s: 5.3963e-23\n", - "de Broglie wavelength of electron in angstrom= 0.123\n" - ] - } - ], - "source": [ - "#cal of velocity of electron,momentum of electron,de Broglie wavelength of electron\n", - "#intiation of all variables \n", - "#Given that\n", - "import math\n", - "E = 10. # Energy of electron in KeV\n", - "me = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.10,page no:19\")\n", - "v = math.sqrt(2*E*1.6e-16/me) # Calculation of velocity of moving electron\n", - "p = me*v #Calculation of momentum of moving electron\n", - "lamda = h/p # calculation of de Broglie wavelength\n", - "print(\"velocity of electron in m/s:\"),round(v,2)\n", - "print(\"momentum of electron in Kgm/s:\"),round(p,27)\n", - "print(\"de Broglie wavelength of electron in angstrom=\"),round(lamda*1e10,3)\n", - "# Answers in book are v = 5.93e6 m/s, p = 5.397e-24 kgm/s, lambda = 1.23 angstrom\n", - "# Which is due to wrong calculation" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.11;page no:20" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.11,page no:20\n", - " velocity of neutron in m/s: 3964.072\n", - " Kinetic energy of neutron in eV= 0.082\n" - ] - } - ], - "source": [ - "#cal of velocity and kinetic energy of neutron\n", - "#intiation of all variables \n", - "#Given that\n", - "lamda= 1 # de Broglie wavelength of neutron in angstrom\n", - "m = 1.67e-27 # Mass of electron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.11,page no:20\")\n", - "v = h/(m*lamda*1e-10) # Calculation of velocity of moving neutron\n", - "print(\" velocity of neutron in m/s:\"),round(v,3)\n", - "E = 1./2.*m*v**2 # Calculation of kinetic energy of moving neutron\n", - "print(\" Kinetic energy of neutron in eV=\"),round(E/1.6e-19,3)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.12;page no:20" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.12,page no:20\n", - "Wavelength of electron in metres= 2.74e-11\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of electron\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "E = 2 # Energy of accelerated electron in KeV\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.12,page no:20\")\n", - "lamda = h/math.sqrt(2*m*E*1e3*1.6e-19) # Calculation of velocity of moving electron\n", - "print(\"Wavelength of electron in metres=\"),round(lamda,13)\n", - "# Answer in book is 2.74e-12m\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.13;page no:21" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.13,page no:21\n", - "Wavelength of matter wave in angstrom= 1.48e-05\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of matter wave\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "v = 2e8 # speed of moving proton in m/s\n", - "c = 3e8 # speed of light in m/s\n", - "m = 1.67e-27 # Mass of proton in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.13,page no:21\")\n", - "lamda = h/(m*v/math.sqrt(1-(v/c)**2)) # Calculation of velocity of moving electron\n", - "print(\"Wavelength of matter wave in angstrom=\"),round(lamda*1e10,7)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.14;page no:22" - ] - }, - { - "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.14,page no:22\n", - "Momentum of photon in Kgm/s while Momentum of electron in Kgm/s which are equal: 6.63e-24 6.63e-24\n", - "Total Energy of photon in joule while Total Energy of electron in MeV: 1.989e-15 2.42e-17\n", - "Ratio of kinetic energies in: 0.0121\n" - ] - } - ], - "source": [ - "#cal of momentum,total energy and ratio of kinetic energy of photon\n", - "#intiation of all variables \n", - "#given that\n", - "lamda = 1# wavelength in m/s\n", - "m_e = 9.1e-31 # Mass of electron in Kg\n", - "m_p = 1.67e-27 # Mass of proton in kg\n", - "c = 3e8 # speed of light in m/s\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.14,page no:22\")\n", - "p_e = h/(lamda*1e-10) # Momentum of electron\n", - "p_p = h/(lamda*1e-10) # Momentum of photon\n", - "print(\"Momentum of photon in Kgm/s while Momentum of electron in Kgm/s which are equal:\"),round(p_p,26),round(p_e,26)\n", - "E_e = p_e**2/(2*m_e) +m_e*c**2 # Total energy of electron\n", - "E_e1=(2.42*10**-17)+(m_e*c**2/1.6*10**-19)\n", - "E_p = h*c/(lamda*1e-10) # Total energy of photon\n", - "print(\"Total Energy of photon in joule while Total Energy of electron in MeV:\"),round(E_p,18),E_e1\n", - "K_e = p_e**2/(2*m_e) # Kinetic energy of electron \n", - "K_p = h*c/(lamda*1e-10)# Kinetic energy of photon\n", - "r_K = K_e/K_p # Ratio of kinetic energies\n", - "print(\"Ratio of kinetic energies in:\"),round(r_K,4)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.15;page no:24" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.15,page no:24\n", - "de Broglie wavelength of neutron in angstrom: 0.0573\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of neutron\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "e = 25 # Energy of neutron in eV\n", - "c = 3e8 # speed of light in m/s\n", - "m = 1.67e-27 # Mass of neutron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.15,page no:24\")\n", - "rest_e = m*c**2/(1e6*1.6e-19)# rest mass energy of neutron in MeV\n", - "if e/rest_e < 0.015:\n", - " E = e;\n", - "else:\n", - "\tE = rest_e +e;\n", - "lamda = h/(math.sqrt(2*m*e*1.6e-19)) # calculation of de Broglie wavelength\n", - "print(\"de Broglie wavelength of neutron in angstrom:\"),round(lamda*1e10,4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.16;page no:24" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.16,page no:24\n", - "de Broglie wavelength of neutron in angstrom: 0.00717\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of neutron \n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "e = 2*1.6e-19 # charge on alpha particle in coulomb\n", - "V = 200 # Applied voltage in volts\n", - "m = 4*1.67e-27 # Mass of alpha particle in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.16,page no:24\")\n", - "lamda=h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", - "print(\"de Broglie wavelength of neutron in angstrom:\"),round(lamda*1e10,5)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.17;page no:25" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.17,page no:25\n", - "de Broglie wavelength of ball in angstrom: 6.62e-26\n", - "de Broglie wavelength of electron in angstrom: 7.27\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of ball and electron\n", - "#intiation of all variables \n", - "#given that\n", - "M = 20 # Mass of ball in Kg\n", - "V = 5 # velocity of of ball in m/s\n", - "m = 9.1e-31 #Mass of electron in Kg\n", - "v = 1e6 # velocity of of electron in m/s\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.17,page no:25\")\n", - "lambda_b = h/(M*V) # calculation of de Broglie wavelength for ball\n", - "lambda_e = h/(m*v) # calculation of de Broglie wavelength electron\n", - "print(\"de Broglie wavelength of ball in angstrom:\"),round(lambda_b*1e10,34)\n", - "print(\"de Broglie wavelength of electron in angstrom:\"),round(lambda_e*1e10,2)\n", - "# answer in book is 6.62e-22 angstrom for ball\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.18;page no:26" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.18,page no:26\n", - "Wavelength of neutron in angstrom: 0.286\n" - ] - } - ], - "source": [ - "#cal of de brogle wavelength of neutron\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "E = 1 # Energy of neutron in eV\n", - "m = 1.67e-27 # Mass of neutron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "print(\"Example 1.18,page no:26\")\n", - "lamda = h/math.sqrt(2*m*E*1.6e-19) # Calculation of velocity of moving electron\n", - "print(\"Wavelength of neutron in angstrom:\"),round(lamda*1e10,3)\n", - "# Answer in book is 6.62e-22 angstrom\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.19;page no:27" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.19,page no:27\n", - "Applied voltage on electron in V: 602.0\n" - ] - } - ], - "source": [ - "#cal of Applied voltage on electron \n", - "#intiation of all variables \n", - "#given that\n", - "lamda = 0.5# wavelength of electron in angstrom\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.62e-34 # Plank constant\n", - "q = 1.6e-19 # charge on electron in coulomb\n", - "print(\"Example 1.19,page no:27\")\n", - "V = h**2/(2*m*q*(lamda*1e-10)**2) # Calculation of velocity of moving electron\n", - "print(\"Applied voltage on electron in V:\"),round(V,1)\n", - "# Answer in book is 601.6 Volt\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.21;page no:29" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.21,page no:29\n", - "Wavelength of neutron at degree Celsius in angstrom: 1.43\n" - ] - } - ], - "source": [ - "#cal of wavelength of neutron\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "k = 8.6e-5 # Boltzmann constant\n", - "t = 37 # Temperature in degree Celsius\n", - "h = 6.62e-34 # Plank constant\n", - "m = 1.67e-27 # Mass of neutron\n", - "print(\"Example 1.21,page no:29\")\n", - "lamda = h/math.sqrt(3*m*(k*1.6e-19)*(t+273))# Calculation of wavelength\n", - "print(\"Wavelength of neutron at degree Celsius in angstrom:\"),round(lamda*1e10,2)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.22;page no:29" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.22,page no:29\n", - "Wavelength of helium at degree Celsius in angstrom: 0.727\n" - ] - } - ], - "source": [ - "#cal of wavelength of helium\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "k = 8.6e-5 # Boltzmann constant\n", - "t = 27 # Temperature in degree Celsius\n", - "h = 6.62e-34 # Plank constant\n", - "m = 6.7e-27 # Mass of helium atom\n", - "print(\"Example 1.22,page no:29\")\n", - "lamda = h/math.sqrt(3*m*(k*1.6e-19)*(t+273))# Calculation of wavelength\n", - "print(\"Wavelength of helium at degree Celsius in angstrom:\"),round(lamda*1e10,3)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.23;page no:30" - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.23,page no:30\n", - "lamda= 8.67e-11\n", - "D/2*x= 0.05\n", - "tan(theta)= 0.05\n", - "Interatomic spacing of crystal in angstrom: 8.67\n" - ] - } - ], - "source": [ - "#cal of Interatomic spacing of crystal\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "E = 200. # energy of electrons in eV\n", - "x = 20. # distance of screen in cm\n", - "D = 2. # diameter of ring in cm\n", - "h = 6.62e-34 # Plank constant\n", - "m = 9.1e-31 # Mass of electron in kg\n", - "print(\"Example 1.23,page no:30\")\n", - "lamda= h/math.sqrt(2*m*E*1.6e-19) # Calculation of wavelength\n", - "print(\"lamda=\"),round(lamda,13)\n", - "print(\"D/2*x=\"),D/(2*x)\n", - "p=D/(2*x)\n", - "print(\"tan(theta)=\"),p\n", - "d = lamda/(2*p)# calculation of interatomic spacing of crystal\n", - "print(\"Interatomic spacing of crystal in angstrom:\"),round(d*1e10,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.24;page no:31" - ] - }, - { - "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.24,page no:31\n", - "Velocity of electron in ground state in M/s= 2.31\n" - ] - } - ], - "source": [ - "#cal of velocity of electron \n", - "#intiation of all variables \n", - "#given that\n", - "r = 0.5 # Bohr radius of hydrogen in angstrom\n", - "m = 9.1e-31 # Mass of neutron in Kg\n", - "h = 6.6e-34 # Plank constant\n", - "print(\"Example 1.24,page no:31\")\n", - "v = h/(2*3.14*r*1e-10*m) # velocity of electron in ground state\n", - "print(\"Velocity of electron in ground state in M/s=\"),round(v/10**6,2)\n", - "# Answer in book is 2.31e6 m/s\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.25;page no:32" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.25,page no:32\n", - "Velocity of electron in ground state in m/s: 1237.0\n" - ] - } - ], - "source": [ - "#cal of Velocity of electron in ground state\n", - "#intiation of all variables \n", - "#given that\n", - "lamda = 5890 # wavelength of yellow radiation in angstrom\n", - "m = 9.1e-31 # Mass of neutron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.25,page no:32\")\n", - "v = h/(lamda*1e-10*m) # velocity of electron in ground state\n", - "print(\"Velocity of electron in ground state in m/s:\"),round(v,1)\n", - "# Answer in book is 1.24e3 m/s\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.26;page no:33" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.26,page no:33\n", - "Velocity of neutron in m/s: 1985.0\n", - "Kinetic energy of neutron in eV: 0.021\n" - ] - } - ], - "source": [ - "#cal of Velocity and kinetic energy of neutron\n", - "#intiation of all variables \n", - "#given that\n", - "lamda = 2 # wavelength of neutron in angstrom\n", - "m = 1.67e-27 # Mass of neutron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.26,page no:33\")\n", - "v = h/(lamda*1e-10*m) # velocity of neutron\n", - "k = 0.5*m*v**2 # Kinetic energy of neutron\n", - "print(\"Velocity of neutron in m/s:\"),round(v,1)\n", - "print(\"Kinetic energy of neutron in eV:\"),round(k/1.6e-19,3)\n", - "# Answer in book is 0.021eV\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.29;page no:36" - ] - }, - { - "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.29,page no:36\n", - "theta 72.6\n", - "theta1= 56.84\n", - "For first order, sin(theta) in For second order sin(theta) must be which is not possible for any value of angle.So no maxima occur for higher orders: 1.91\n" - ] - } - ], - "source": [ - "#cal of theta and theta1 \n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "v1 = 50 # Previous applied voltage\n", - "v2 = 65 # final applied voltage\n", - "k = 12.28 \n", - "d = 0.91 # Spacing in a crystal in angstrom\n", - "print(\"Example 1.29,page no:36\")\n", - "lamda = k/math.sqrt(v1)\n", - "theta= math.asin(lamda/(2*d))# Angel for initial applied voltage\n", - "lamda1 = k/math.sqrt(v2)# wavelength for final applied voltage\n", - "theta1 = math.asin(lamda1/(2*d))# Angel for final applied voltage\n", - "#print(\"lamda1/1.82=\"),math.asin(lamda1/1.82)\n", - "print(\"theta\"),round(theta*180/3.14,1)\n", - "print(\"theta1=\"),round(theta1*180/3.14,2)\n", - "print(\"For first order, sin(theta) in For second order sin(theta) must be which is not possible for any value of angle.So no maxima occur for higher orders:\"),round(2*math.sin(theta),2)\n", - "#print(\"Angle of diffraction for first order of beam is degree at Volts:\"),round((math.theta1*180/math.pi),2)\n", - "# Answer in book is 57.14 degree" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.30;page no:45" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.30,page no:45\n", - "Group velocity of seawater waves in m/s: 16.29\n" - ] - } - ], - "source": [ - "#cal of Group velocity of seawater waves\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "lamda = 680 # Wavelength in m\n", - "g = 9.8 #Acceleration due to gravity\n", - "print(\"Example 1.30,page no:45\")\n", - "v_g = 0.5*math.sqrt(g*lamda/(2*3.14)) # Calculation of group velocity\n", - "print(\"Group velocity of seawater waves in m/s:\"),round(v_g,2)\n", - "# Answer in book is 16.29 m/s\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.32;page no:47" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.32,page no:47\n", - "Group velocity of de Broglie waves is c : 0.9966\n", - " phase velocity of de Broglie waves is c 1.0034\n" - ] - } - ], - "source": [ - "#cal of group and phase velocity of de brogle waves \n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "lamda = 2e-13 # de Broglie wavelength of an electron in m\n", - "c = 3e8 # Speed of light in m/s\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.32,page no:47\")\n", - "E = h*c/(lamda*1.6e-19) \n", - "E_rest = m*c**2/(1.6e-19) # Calculation of rest mass energy\n", - "E_total = math.sqrt(E**2+E_rest**2) # Total energy in eV\n", - "v_g = c*math.sqrt(1-(E_rest/E_total)**2) # Group velocity\n", - "v_p = c**2/v_g # Phase velocity\n", - "print(\"Group velocity of de Broglie waves is c :\"),round(v_g/c,4)\n", - "print(\" phase velocity of de Broglie waves is c\"),round(v_p/c,4)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## example 1.33;page no:48" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 1.33,page no:48\n", - "Kinetic energy of electron in KeV: 293.33\n", - "Group velocity of de Broglie waves is c in m/s: 0.7719\n", - "phase velocity of de Broglie waves is c in m/s: 1.295\n" - ] - } - ], - "source": [ - "#cal of Kinetic energy of electron,group velocity and phase velocity of de Broglie waves\n", - "#intiation of all variables \n", - "#given that\n", - "import math\n", - "lamda = 2.e-12 # de Broglie wavelength of an electron in m\n", - "c = 3.e8 # Speed of light in m/s\n", - "m = 9.1e-31 # Mass of electron in Kg\n", - "h = 6.63e-34 # Plank constant\n", - "print(\"Example 1.33,page no:48\")\n", - "E = h*c/(lamda*1.6e-19) # Energy due to momentum\n", - "E_rest = m*c**2/(1.6e-19) # Calculation of rest mass energy\n", - "E_total = math.sqrt(E**2+E_rest**2) # Total energy in eV\n", - "KE = E_total - E_rest # Kinetic energy\n", - "v_g = c*math.sqrt(1-(E_rest/E_total)**2) # Group velocity\n", - "v_p = c**2/v_g # Phase velocity\n", - "print(\"Kinetic energy of electron in KeV:\"),round(KE/1000,2)\n", - "print(\"Group velocity of de Broglie waves is c in m/s:\"),round(v_g/c,4)\n", - "print(\"phase velocity of de Broglie waves is c in m/s:\"),round(v_p/c,3)\n", - "# Answer in book is v_g = 0.6035c & v_p = 1.657c\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/maheshvattikuti/maheshvattikuti_version_backup/chapter1.ipynb b/sample_notebooks/maheshvattikuti/maheshvattikuti_version_backup/chapter1.ipynb new file mode 100755 index 00000000..9eda293b --- /dev/null +++ b/sample_notebooks/maheshvattikuti/maheshvattikuti_version_backup/chapter1.ipynb @@ -0,0 +1,1147 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "# chapter1: De Broglie Matter Waves" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.1;page no:10" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.1,page no:10\n", + "\n", + " de Broglie wavelength of earth in metres is= 3.68e-63\n" + ] + } + ], + "source": [ + "# cal of de brogle wavelength of earth\n", + "#intiation of all variables \n", + "#given that\n", + "M = 6.*10**24 # Mass of earth in Kg\n", + "v = 3.*10**4 # Orbital velocity of earth in m/s\n", + "h = 6.625*10**-34 # Plank constant\n", + "print(\"Example 1.1,page no:10\")\n", + "lamda=h/(M*v) \n", + "print(\"\\n de Broglie wavelength of earth in metres is=\"),round(lamda,65)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.2;page no:10" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.2,page no:11\n", + "\n", + " de Broglie wavelength of body in metres is= 6.625e-35\n" + ] + } + ], + "source": [ + "#cal of de Broglie wavelength of body\n", + "#intiation of all variables\n", + "#given that\n", + "M = 1 # Mass of object in Kg\n", + "v = 10 # velocity of object in m/s\n", + "h = 6.625*10**-34 # Plank constant\n", + "print(\"Example 1.2,page no:11\");\n", + "lamda=h/(M*v)#calculation of de Broglie wavelength\n", + "print(\"\\n de Broglie wavelength of body in metres is=\"),round(lamda,38)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.3;page no:11" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.3,page no:11\n", + "\n", + " de Broglie wavelength of body in metres is= 6.625e-09\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of body\n", + "#intiation of all variables \n", + "# Given that\n", + "m = 1e-30 # Mass of any object in Kg\n", + "v = 1e5 # velocity of object in m/s\n", + "h = 6.625e-34 # Plank constant\n", + "print(\"Example 1.3,page no:11\")\n", + "lamda=h/(m*v) # calculation of de Broglie wavelength in metres\n", + "print(\"\\n de Broglie wavelength of body in metres is=\"),round(lamda,12)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "##example 1.4;page no:15" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.4,page no:15\n", + "velocity of electron in m/s: 1000.0\n", + "momentum of electron in Kgm/s: 9.1e-28\n", + "de Broglie wavelength of electron is: 7.27e-07\n", + "Note:The value given in the book for lamda is wrong hence corrected above\n" + ] + } + ], + "source": [ + "#cal of velocity,momenteum and wave lenght of electron\n", + "#intiation of all variables \n", + "# Given that\n", + "import math\n", + "KE = 4.55e-25 # Kinetic energy of an electron in Joule\n", + "m = 9.1e-31 # Mass of any object in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.4,page no:15\")\n", + "v = math.sqrt(2*KE/m) # Calculation of velocity of moving electron\n", + "p = m*v #Calculation of momentum of moving electron\n", + "lamda= h/p # calculation of de Broglie wavelength\n", + "print(\"velocity of electron in m/s:\"),round(v)\n", + "print(\"momentum of electron in Kgm/s:\"),round(p,29)\n", + "print(\"de Broglie wavelength of electron is:\"),round(lamda,9)\n", + "print(\"Note:The value given in the book for lamda is wrong hence corrected above\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.5;page no:16" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.5,page no:16\n", + "de Broglie wavelength of proton is: 2.645e-14\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of proton\n", + "#intiation of all variables \n", + "#Given that\n", + "c = 3e8 # speed of light in m/s\n", + "v = c/20 # Speed of proton in m/s\n", + "m = 1.67e-27 # Mass of proton in Kg\n", + "h = 6.625e-34 # Plank constant\n", + "print(\"Example 1.5,page no:16\")\n", + "lamda= h/(m*v) # calculation of de Broglie wavelength\n", + "print(\"de Broglie wavelength of proton is:\"),round(lamda,17)\n", + "# Answer in book is 6.645e-14m which is a calculation mistake\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.6;page no:16" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.6,page no:16\n", + "\n", + " de Broglie wavelength of neutron in angstrom= 7.99e-05\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of neutron\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "e = 12.8 # Energy of neutron in MeV\n", + "c = 3.e8 # speed of light in m/s\n", + "m = 1.675e-27 # Mass of neutron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.6,page no:16\")\n", + "rest_e = m*c**2/(1e6*1.6e-19)# rest mass energy of neutron in MeV\n", + "if e/rest_e < 0.015:\n", + "\tE = e\n", + "else:\n", + "\tE = rest_e +e\n", + "lamda = h/(math.sqrt(2*m*e*1e6*1.6e-19)) # calculation of de Broglie wavelength\n", + "print(\"\\n de Broglie wavelength of neutron in angstrom=\"),round(lamda*1e10,7)\n", + "# Answer in book is 8.04e-5 angstrom which is misprinted\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.7;page no:17" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.7,page no:17\n", + "\n", + " de Broglie wavelength of neutron in angstrom= 1.734\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of neutron\n", + "#intiation of all variables \n", + "#Given that\n", + "import math\n", + "e = 1.602e-19 # charge on electron in coulomb\n", + "V = 50. # Applied voltage in volts\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.7,page no:17\")\n", + "lamda= h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", + "print(\"\\n de Broglie wavelength of neutron in angstrom=\"),round(lamda*1e10,3)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.9;page no:18" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.9,page no:18\n", + "de Broglie wavelength associated with the electron in angstrom= 1.67\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength associated with the electron\n", + "#intiation of all variables \n", + "#Given that\n", + "import math\n", + "e = 1.6e-19 # charge on electron in coulomb\n", + "V = 54 # Applied voltage in volts\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.9,page no:18\")\n", + "lamda = h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", + "print(\"de Broglie wavelength associated with the electron in angstrom=\"),round(lamda*1e10,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.10;page no:19" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.10,page no:19\n", + "velocity of electron in m/s: 59299945.33\n", + "momentum of electron in Kgm/s: 5.3963e-23\n", + "de Broglie wavelength of electron in angstrom= 0.123\n" + ] + } + ], + "source": [ + "#cal of velocity of electron,momentum of electron,de Broglie wavelength of electron\n", + "#intiation of all variables \n", + "#Given that\n", + "import math\n", + "E = 10. # Energy of electron in KeV\n", + "me = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.10,page no:19\")\n", + "v = math.sqrt(2*E*1.6e-16/me) # Calculation of velocity of moving electron\n", + "p = me*v #Calculation of momentum of moving electron\n", + "lamda = h/p # calculation of de Broglie wavelength\n", + "print(\"velocity of electron in m/s:\"),round(v,2)\n", + "print(\"momentum of electron in Kgm/s:\"),round(p,27)\n", + "print(\"de Broglie wavelength of electron in angstrom=\"),round(lamda*1e10,3)\n", + "# Answers in book are v = 5.93e6 m/s, p = 5.397e-24 kgm/s, lambda = 1.23 angstrom\n", + "# Which is due to wrong calculation" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.11;page no:20" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.11,page no:20\n", + " velocity of neutron in m/s: 3964.072\n", + " Kinetic energy of neutron in eV= 0.082\n" + ] + } + ], + "source": [ + "#cal of velocity and kinetic energy of neutron\n", + "#intiation of all variables \n", + "#Given that\n", + "lamda= 1 # de Broglie wavelength of neutron in angstrom\n", + "m = 1.67e-27 # Mass of electron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.11,page no:20\")\n", + "v = h/(m*lamda*1e-10) # Calculation of velocity of moving neutron\n", + "print(\" velocity of neutron in m/s:\"),round(v,3)\n", + "E = 1./2.*m*v**2 # Calculation of kinetic energy of moving neutron\n", + "print(\" Kinetic energy of neutron in eV=\"),round(E/1.6e-19,3)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.12;page no:20" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.12,page no:20\n", + "Wavelength of electron in metres= 2.74e-11\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of electron\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "E = 2 # Energy of accelerated electron in KeV\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.12,page no:20\")\n", + "lamda = h/math.sqrt(2*m*E*1e3*1.6e-19) # Calculation of velocity of moving electron\n", + "print(\"Wavelength of electron in metres=\"),round(lamda,13)\n", + "# Answer in book is 2.74e-12m\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.13;page no:21" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.13,page no:21\n", + "Wavelength of matter wave in angstrom= 1.48e-05\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of matter wave\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "v = 2e8 # speed of moving proton in m/s\n", + "c = 3e8 # speed of light in m/s\n", + "m = 1.67e-27 # Mass of proton in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.13,page no:21\")\n", + "lamda = h/(m*v/math.sqrt(1-(v/c)**2)) # Calculation of velocity of moving electron\n", + "print(\"Wavelength of matter wave in angstrom=\"),round(lamda*1e10,7)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.14;page no:22" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.14,page no:22\n", + "Momentum of photon in Kgm/s while Momentum of electron in Kgm/s which are equal: 6.63e-24 6.63e-24\n", + "Total Energy of photon in joule while Total Energy of electron in MeV: 1.989e-15 2.42e-17\n", + "Ratio of kinetic energies in: 0.0121\n" + ] + } + ], + "source": [ + "#cal of momentum,total energy and ratio of kinetic energy of photon\n", + "#intiation of all variables \n", + "#given that\n", + "lamda = 1# wavelength in m/s\n", + "m_e = 9.1e-31 # Mass of electron in Kg\n", + "m_p = 1.67e-27 # Mass of proton in kg\n", + "c = 3e8 # speed of light in m/s\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.14,page no:22\")\n", + "p_e = h/(lamda*1e-10) # Momentum of electron\n", + "p_p = h/(lamda*1e-10) # Momentum of photon\n", + "print(\"Momentum of photon in Kgm/s while Momentum of electron in Kgm/s which are equal:\"),round(p_p,26),round(p_e,26)\n", + "E_e = p_e**2/(2*m_e) +m_e*c**2 # Total energy of electron\n", + "E_e1=(2.42*10**-17)+(m_e*c**2/1.6*10**-19)\n", + "E_p = h*c/(lamda*1e-10) # Total energy of photon\n", + "print(\"Total Energy of photon in joule while Total Energy of electron in MeV:\"),round(E_p,18),E_e1\n", + "K_e = p_e**2/(2*m_e) # Kinetic energy of electron \n", + "K_p = h*c/(lamda*1e-10)# Kinetic energy of photon\n", + "r_K = K_e/K_p # Ratio of kinetic energies\n", + "print(\"Ratio of kinetic energies in:\"),round(r_K,4)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.15;page no:24" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.15,page no:24\n", + "de Broglie wavelength of neutron in angstrom: 0.0573\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of neutron\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "e = 25 # Energy of neutron in eV\n", + "c = 3e8 # speed of light in m/s\n", + "m = 1.67e-27 # Mass of neutron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.15,page no:24\")\n", + "rest_e = m*c**2/(1e6*1.6e-19)# rest mass energy of neutron in MeV\n", + "if e/rest_e < 0.015:\n", + " E = e;\n", + "else:\n", + "\tE = rest_e +e;\n", + "lamda = h/(math.sqrt(2*m*e*1.6e-19)) # calculation of de Broglie wavelength\n", + "print(\"de Broglie wavelength of neutron in angstrom:\"),round(lamda*1e10,4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.16;page no:24" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.16,page no:24\n", + "de Broglie wavelength of neutron in angstrom: 0.00717\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of neutron \n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "e = 2*1.6e-19 # charge on alpha particle in coulomb\n", + "V = 200 # Applied voltage in volts\n", + "m = 4*1.67e-27 # Mass of alpha particle in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.16,page no:24\")\n", + "lamda=h/(math.sqrt(2*e*V*m)) # calculation of de Broglie wavelength\n", + "print(\"de Broglie wavelength of neutron in angstrom:\"),round(lamda*1e10,5)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.17;page no:25" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.17,page no:25\n", + "de Broglie wavelength of ball in angstrom: 6.62e-26\n", + "de Broglie wavelength of electron in angstrom: 7.27\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of ball and electron\n", + "#intiation of all variables \n", + "#given that\n", + "M = 20 # Mass of ball in Kg\n", + "V = 5 # velocity of of ball in m/s\n", + "m = 9.1e-31 #Mass of electron in Kg\n", + "v = 1e6 # velocity of of electron in m/s\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.17,page no:25\")\n", + "lambda_b = h/(M*V) # calculation of de Broglie wavelength for ball\n", + "lambda_e = h/(m*v) # calculation of de Broglie wavelength electron\n", + "print(\"de Broglie wavelength of ball in angstrom:\"),round(lambda_b*1e10,34)\n", + "print(\"de Broglie wavelength of electron in angstrom:\"),round(lambda_e*1e10,2)\n", + "# answer in book is 6.62e-22 angstrom for ball\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.18;page no:26" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.18,page no:26\n", + "Wavelength of neutron in angstrom: 0.286\n" + ] + } + ], + "source": [ + "#cal of de brogle wavelength of neutron\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "E = 1 # Energy of neutron in eV\n", + "m = 1.67e-27 # Mass of neutron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "print(\"Example 1.18,page no:26\")\n", + "lamda = h/math.sqrt(2*m*E*1.6e-19) # Calculation of velocity of moving electron\n", + "print(\"Wavelength of neutron in angstrom:\"),round(lamda*1e10,3)\n", + "# Answer in book is 6.62e-22 angstrom\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.19;page no:27" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.19,page no:27\n", + "Applied voltage on electron in V: 602.0\n" + ] + } + ], + "source": [ + "#cal of Applied voltage on electron \n", + "#intiation of all variables \n", + "#given that\n", + "lamda = 0.5# wavelength of electron in angstrom\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.62e-34 # Plank constant\n", + "q = 1.6e-19 # charge on electron in coulomb\n", + "print(\"Example 1.19,page no:27\")\n", + "V = h**2/(2*m*q*(lamda*1e-10)**2) # Calculation of velocity of moving electron\n", + "print(\"Applied voltage on electron in V:\"),round(V,1)\n", + "# Answer in book is 601.6 Volt\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.21;page no:29" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.21,page no:29\n", + "Wavelength of neutron at degree Celsius in angstrom: 1.43\n" + ] + } + ], + "source": [ + "#cal of wavelength of neutron\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "k = 8.6e-5 # Boltzmann constant\n", + "t = 37 # Temperature in degree Celsius\n", + "h = 6.62e-34 # Plank constant\n", + "m = 1.67e-27 # Mass of neutron\n", + "print(\"Example 1.21,page no:29\")\n", + "lamda = h/math.sqrt(3*m*(k*1.6e-19)*(t+273))# Calculation of wavelength\n", + "print(\"Wavelength of neutron at degree Celsius in angstrom:\"),round(lamda*1e10,2)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.22;page no:29" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.22,page no:29\n", + "Wavelength of helium at degree Celsius in angstrom: 0.727\n" + ] + } + ], + "source": [ + "#cal of wavelength of helium\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "k = 8.6e-5 # Boltzmann constant\n", + "t = 27 # Temperature in degree Celsius\n", + "h = 6.62e-34 # Plank constant\n", + "m = 6.7e-27 # Mass of helium atom\n", + "print(\"Example 1.22,page no:29\")\n", + "lamda = h/math.sqrt(3*m*(k*1.6e-19)*(t+273))# Calculation of wavelength\n", + "print(\"Wavelength of helium at degree Celsius in angstrom:\"),round(lamda*1e10,3)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.23;page no:30" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.23,page no:30\n", + "lamda= 8.67e-11\n", + "D/2*x= 0.05\n", + "tan(theta)= 0.05\n", + "Interatomic spacing of crystal in angstrom: 8.67\n" + ] + } + ], + "source": [ + "#cal of Interatomic spacing of crystal\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "E = 200. # energy of electrons in eV\n", + "x = 20. # distance of screen in cm\n", + "D = 2. # diameter of ring in cm\n", + "h = 6.62e-34 # Plank constant\n", + "m = 9.1e-31 # Mass of electron in kg\n", + "print(\"Example 1.23,page no:30\")\n", + "lamda= h/math.sqrt(2*m*E*1.6e-19) # Calculation of wavelength\n", + "print(\"lamda=\"),round(lamda,13)\n", + "print(\"D/2*x=\"),D/(2*x)\n", + "p=D/(2*x)\n", + "print(\"tan(theta)=\"),p\n", + "d = lamda/(2*p)# calculation of interatomic spacing of crystal\n", + "print(\"Interatomic spacing of crystal in angstrom:\"),round(d*1e10,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.24;page no:31" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.24,page no:31\n", + "Velocity of electron in ground state in M/s= 2.31\n" + ] + } + ], + "source": [ + "#cal of velocity of electron \n", + "#intiation of all variables \n", + "#given that\n", + "r = 0.5 # Bohr radius of hydrogen in angstrom\n", + "m = 9.1e-31 # Mass of neutron in Kg\n", + "h = 6.6e-34 # Plank constant\n", + "print(\"Example 1.24,page no:31\")\n", + "v = h/(2*3.14*r*1e-10*m) # velocity of electron in ground state\n", + "print(\"Velocity of electron in ground state in M/s=\"),round(v/10**6,2)\n", + "# Answer in book is 2.31e6 m/s\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.25;page no:32" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.25,page no:32\n", + "Velocity of electron in ground state in m/s: 1237.0\n" + ] + } + ], + "source": [ + "#cal of Velocity of electron in ground state\n", + "#intiation of all variables \n", + "#given that\n", + "lamda = 5890 # wavelength of yellow radiation in angstrom\n", + "m = 9.1e-31 # Mass of neutron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.25,page no:32\")\n", + "v = h/(lamda*1e-10*m) # velocity of electron in ground state\n", + "print(\"Velocity of electron in ground state in m/s:\"),round(v,1)\n", + "# Answer in book is 1.24e3 m/s\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.26;page no:33" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.26,page no:33\n", + "Velocity of neutron in m/s: 1985.0\n", + "Kinetic energy of neutron in eV: 0.021\n" + ] + } + ], + "source": [ + "#cal of Velocity and kinetic energy of neutron\n", + "#intiation of all variables \n", + "#given that\n", + "lamda = 2 # wavelength of neutron in angstrom\n", + "m = 1.67e-27 # Mass of neutron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.26,page no:33\")\n", + "v = h/(lamda*1e-10*m) # velocity of neutron\n", + "k = 0.5*m*v**2 # Kinetic energy of neutron\n", + "print(\"Velocity of neutron in m/s:\"),round(v,1)\n", + "print(\"Kinetic energy of neutron in eV:\"),round(k/1.6e-19,3)\n", + "# Answer in book is 0.021eV\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.29;page no:36" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.29,page no:36\n", + "theta 72.6\n", + "theta1= 56.84\n", + "For first order, sin(theta) in For second order sin(theta) must be which is not possible for any value of angle.So no maxima occur for higher orders: 1.91\n" + ] + } + ], + "source": [ + "#cal of theta and theta1 \n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "v1 = 50 # Previous applied voltage\n", + "v2 = 65 # final applied voltage\n", + "k = 12.28 \n", + "d = 0.91 # Spacing in a crystal in angstrom\n", + "print(\"Example 1.29,page no:36\")\n", + "lamda = k/math.sqrt(v1)\n", + "theta= math.asin(lamda/(2*d))# Angel for initial applied voltage\n", + "lamda1 = k/math.sqrt(v2)# wavelength for final applied voltage\n", + "theta1 = math.asin(lamda1/(2*d))# Angel for final applied voltage\n", + "#print(\"lamda1/1.82=\"),math.asin(lamda1/1.82)\n", + "print(\"theta\"),round(theta*180/3.14,1)\n", + "print(\"theta1=\"),round(theta1*180/3.14,2)\n", + "print(\"For first order, sin(theta) in For second order sin(theta) must be which is not possible for any value of angle.So no maxima occur for higher orders:\"),round(2*math.sin(theta),2)\n", + "#print(\"Angle of diffraction for first order of beam is degree at Volts:\"),round((math.theta1*180/math.pi),2)\n", + "# Answer in book is 57.14 degree" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.30;page no:45" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.30,page no:45\n", + "Group velocity of seawater waves in m/s: 16.29\n" + ] + } + ], + "source": [ + "#cal of Group velocity of seawater waves\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "lamda = 680 # Wavelength in m\n", + "g = 9.8 #Acceleration due to gravity\n", + "print(\"Example 1.30,page no:45\")\n", + "v_g = 0.5*math.sqrt(g*lamda/(2*3.14)) # Calculation of group velocity\n", + "print(\"Group velocity of seawater waves in m/s:\"),round(v_g,2)\n", + "# Answer in book is 16.29 m/s\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.32;page no:47" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.32,page no:47\n", + "Group velocity of de Broglie waves is c : 0.9966\n", + " phase velocity of de Broglie waves is c 1.0034\n" + ] + } + ], + "source": [ + "#cal of group and phase velocity of de brogle waves \n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "lamda = 2e-13 # de Broglie wavelength of an electron in m\n", + "c = 3e8 # Speed of light in m/s\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.32,page no:47\")\n", + "E = h*c/(lamda*1.6e-19) \n", + "E_rest = m*c**2/(1.6e-19) # Calculation of rest mass energy\n", + "E_total = math.sqrt(E**2+E_rest**2) # Total energy in eV\n", + "v_g = c*math.sqrt(1-(E_rest/E_total)**2) # Group velocity\n", + "v_p = c**2/v_g # Phase velocity\n", + "print(\"Group velocity of de Broglie waves is c :\"),round(v_g/c,4)\n", + "print(\" phase velocity of de Broglie waves is c\"),round(v_p/c,4)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## example 1.33;page no:48" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 1.33,page no:48\n", + "Kinetic energy of electron in KeV: 293.33\n", + "Group velocity of de Broglie waves is c in m/s: 0.7719\n", + "phase velocity of de Broglie waves is c in m/s: 1.295\n" + ] + } + ], + "source": [ + "#cal of Kinetic energy of electron,group velocity and phase velocity of de Broglie waves\n", + "#intiation of all variables \n", + "#given that\n", + "import math\n", + "lamda = 2.e-12 # de Broglie wavelength of an electron in m\n", + "c = 3.e8 # Speed of light in m/s\n", + "m = 9.1e-31 # Mass of electron in Kg\n", + "h = 6.63e-34 # Plank constant\n", + "print(\"Example 1.33,page no:48\")\n", + "E = h*c/(lamda*1.6e-19) # Energy due to momentum\n", + "E_rest = m*c**2/(1.6e-19) # Calculation of rest mass energy\n", + "E_total = math.sqrt(E**2+E_rest**2) # Total energy in eV\n", + "KE = E_total - E_rest # Kinetic energy\n", + "v_g = c*math.sqrt(1-(E_rest/E_total)**2) # Group velocity\n", + "v_p = c**2/v_g # Phase velocity\n", + "print(\"Kinetic energy of electron in KeV:\"),round(KE/1000,2)\n", + "print(\"Group velocity of de Broglie waves is c in m/s:\"),round(v_g/c,4)\n", + "print(\"phase velocity of de Broglie waves is c in m/s:\"),round(v_p/c,3)\n", + "# Answer in book is v_g = 0.6035c & v_p = 1.657c\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and.ipynb b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and.ipynb new file mode 100755 index 00000000..505cf999 --- /dev/null +++ b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and.ipynb @@ -0,0 +1,234 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Nuclear Sturcture and Radioactivity" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_1 pgno:25" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Half life of radioactive nuclide=t1/2=minutes 14.7674928978\n", + "\n", + "Time required for the activity to decrease to 25percent of the initial activity=t1=minutes 68.0335182976\n", + "\n", + "Time required for the activity to decrease to 10percent of the initial activity=t2=minutes 113.001227913\n" + ] + } + ], + "source": [ + "from math import log\n", + "N0=3396.;#no. of counts per minute given by radioactive nuclide at a given time#\n", + "N=1000.;#no. of counts per minute given by radioactive nuclide one hour later#\n", + "thalf=0.693*60/(2.303*log(N0/N));#half life of nuclide in minutes#\n", + "print'Half life of radioactive nuclide=t1/2=minutes',thalf\n", + "t1=2.303*log(100/25)*thalf/0.693;#time required for the activity to decrease to 25% of the initial activity in minutes#\n", + "print'\\nTime required for the activity to decrease to 25percent of the initial activity=t1=minutes',t1\n", + "t2=2.303*log(100/10)*thalf/0.693;#time required for the activity to decrease to 10% of the initial activity in minutes#\n", + "print'\\nTime required for the activity to decrease to 10percent of the initial activity=t2=minutes',t2\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_2 pgno:27" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Half life of 226Ra molecule=t1/2=years 1584.62090409\n" + ] + } + ], + "source": [ + "R=3.7*10**10;#no. of alpha particles per second emitted by 1g of 226Ra#\n", + "N=(6.023*10**23)/226;#no. of atoms of 226Ra#\n", + "yr=3.15*10**7;#no of seconds in a year#\n", + "thalf=0.693*N/(R*yr);#half life of 226Ra in years#\n", + "print'Half life of 226Ra molecule=t1/2=years',thalf#here the answer written in textbook is wrongly printed actual answer will be the one we are getting here#\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_3 pgno:29" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Weight of 1 Ci of 24Na=w=micrograms=1.13*10**-7grams 0.113352495089\n" + ] + } + ], + "source": [ + "thalf=14.8*60*60;#half life of 24Na atom in seconds#\n", + "L=6.023*10**23;#Avagadro number#\n", + "v=3.7*10**10;#1 Ci of radioactivity in disintegrations per second#\n", + "w=(24*10**6*v*thalf)/(0.693*L);#weight of 1 Ci of 24Na in grams#\n", + "print'Weight of 1 Ci of 24Na=w=micrograms=1.13*10**-7grams',w\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_4 pgno:30" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "dM value of H atom=dM=amu 0.00239\n", + "\n", + "Binding energy of H atom=BE=MeV 2.22509\n" + ] + } + ], + "source": [ + "Mp=1.00728;#mass of proton in amu#\n", + "Mn=1.00866;#mass of neutronin amu#\n", + "MH=2.01355;#isotopic mass of H atom in amu#\n", + "dM=((1*Mp)+(1*Mn)-MH);#dM value of H atom in amu#\n", + "print'dM value of H atom=dM=amu',dM\n", + "BE=dM*931;#binding energy of H atom in MeV#\n", + "print'\\nBinding energy of H atom=BE=MeV',BE\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_5 pgno:32" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Age of the specimen=t=%fyears 36120.0499843\n" + ] + } + ], + "source": [ + "from math import log\n", + "N0=15.3;#decay rate of Contemporary Carbon in disintegrations/min/gram#\n", + "N=2.25;#decay rate of 14C specimen in disintegrtions/min/gram#\n", + "thalf=5670.;#half life of nuclide in years#\n", + "t=2.303*log(N0/N)*thalf/0.693;#Age of the specimen in years#\n", + "print'Age of the specimen=t=years',t#here the answer given in textbook is actually wrong we get twice that of the answer which is shown through execution#\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_6 pgno:33" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Here N0 and N must be in terms of Uranium.N is proportional to 1gram og Uranium\n", + "\n", + "N0 can be calculated from the given data.0.0453grams of 206Pb corresponds to 238*0.0453/206=0.0523grams of 238U,i.e 0.0453 grams of 206Pb must have been formed by the decaying of 0.523grams of 238U.\n", + "Since N is proportional to 1,N0 is proportional to 1.0523.\n", + "\n", + "Age of the mineral=t=years=7.62*10**8years 762356478.526\n" + ] + } + ], + "source": [ + "from math import log\n", + "thalf=4.5*10**9;#half life of Uranium in years#\n", + "print'Here N0 and N must be in terms of Uranium.N is proportional to 1gram og Uranium'\n", + "print'\\nN0 can be calculated from the given data.0.0453grams of 206Pb corresponds to 238*0.0453/206=0.0523grams of 238U,i.e 0.0453 grams of 206Pb must have been formed by the decaying of 0.523grams of 238U.\\nSince N is proportional to 1,N0 is proportional to 1.0523.'\n", + "N0=1.0523;\n", + "N=1;\n", + "t=2.303*log(N0/N)*thalf/0.693;#Age of the mineral in years#\n", + "print'\\nAge of the mineral=t=years=7.62*10**8years',t#here also the answer given in textbook is wrong the one resulted through execution is the right one#\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and_Radioactivity.ipynb b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and_Radioactivity.ipynb deleted file mode 100755 index 505cf999..00000000 --- a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_2_Nuclear_Sturcture_and_Radioactivity.ipynb +++ /dev/null @@ -1,234 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Nuclear Sturcture and Radioactivity" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_1 pgno:25" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Half life of radioactive nuclide=t1/2=minutes 14.7674928978\n", - "\n", - "Time required for the activity to decrease to 25percent of the initial activity=t1=minutes 68.0335182976\n", - "\n", - "Time required for the activity to decrease to 10percent of the initial activity=t2=minutes 113.001227913\n" - ] - } - ], - "source": [ - "from math import log\n", - "N0=3396.;#no. of counts per minute given by radioactive nuclide at a given time#\n", - "N=1000.;#no. of counts per minute given by radioactive nuclide one hour later#\n", - "thalf=0.693*60/(2.303*log(N0/N));#half life of nuclide in minutes#\n", - "print'Half life of radioactive nuclide=t1/2=minutes',thalf\n", - "t1=2.303*log(100/25)*thalf/0.693;#time required for the activity to decrease to 25% of the initial activity in minutes#\n", - "print'\\nTime required for the activity to decrease to 25percent of the initial activity=t1=minutes',t1\n", - "t2=2.303*log(100/10)*thalf/0.693;#time required for the activity to decrease to 10% of the initial activity in minutes#\n", - "print'\\nTime required for the activity to decrease to 10percent of the initial activity=t2=minutes',t2\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_2 pgno:27" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Half life of 226Ra molecule=t1/2=years 1584.62090409\n" - ] - } - ], - "source": [ - "R=3.7*10**10;#no. of alpha particles per second emitted by 1g of 226Ra#\n", - "N=(6.023*10**23)/226;#no. of atoms of 226Ra#\n", - "yr=3.15*10**7;#no of seconds in a year#\n", - "thalf=0.693*N/(R*yr);#half life of 226Ra in years#\n", - "print'Half life of 226Ra molecule=t1/2=years',thalf#here the answer written in textbook is wrongly printed actual answer will be the one we are getting here#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_3 pgno:29" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Weight of 1 Ci of 24Na=w=micrograms=1.13*10**-7grams 0.113352495089\n" - ] - } - ], - "source": [ - "thalf=14.8*60*60;#half life of 24Na atom in seconds#\n", - "L=6.023*10**23;#Avagadro number#\n", - "v=3.7*10**10;#1 Ci of radioactivity in disintegrations per second#\n", - "w=(24*10**6*v*thalf)/(0.693*L);#weight of 1 Ci of 24Na in grams#\n", - "print'Weight of 1 Ci of 24Na=w=micrograms=1.13*10**-7grams',w\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_4 pgno:30" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "dM value of H atom=dM=amu 0.00239\n", - "\n", - "Binding energy of H atom=BE=MeV 2.22509\n" - ] - } - ], - "source": [ - "Mp=1.00728;#mass of proton in amu#\n", - "Mn=1.00866;#mass of neutronin amu#\n", - "MH=2.01355;#isotopic mass of H atom in amu#\n", - "dM=((1*Mp)+(1*Mn)-MH);#dM value of H atom in amu#\n", - "print'dM value of H atom=dM=amu',dM\n", - "BE=dM*931;#binding energy of H atom in MeV#\n", - "print'\\nBinding energy of H atom=BE=MeV',BE\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_5 pgno:32" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Age of the specimen=t=%fyears 36120.0499843\n" - ] - } - ], - "source": [ - "from math import log\n", - "N0=15.3;#decay rate of Contemporary Carbon in disintegrations/min/gram#\n", - "N=2.25;#decay rate of 14C specimen in disintegrtions/min/gram#\n", - "thalf=5670.;#half life of nuclide in years#\n", - "t=2.303*log(N0/N)*thalf/0.693;#Age of the specimen in years#\n", - "print'Age of the specimen=t=years',t#here the answer given in textbook is actually wrong we get twice that of the answer which is shown through execution#\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_6 pgno:33" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Here N0 and N must be in terms of Uranium.N is proportional to 1gram og Uranium\n", - "\n", - "N0 can be calculated from the given data.0.0453grams of 206Pb corresponds to 238*0.0453/206=0.0523grams of 238U,i.e 0.0453 grams of 206Pb must have been formed by the decaying of 0.523grams of 238U.\n", - "Since N is proportional to 1,N0 is proportional to 1.0523.\n", - "\n", - "Age of the mineral=t=years=7.62*10**8years 762356478.526\n" - ] - } - ], - "source": [ - "from math import log\n", - "thalf=4.5*10**9;#half life of Uranium in years#\n", - "print'Here N0 and N must be in terms of Uranium.N is proportional to 1gram og Uranium'\n", - "print'\\nN0 can be calculated from the given data.0.0453grams of 206Pb corresponds to 238*0.0453/206=0.0523grams of 238U,i.e 0.0453 grams of 206Pb must have been formed by the decaying of 0.523grams of 238U.\\nSince N is proportional to 1,N0 is proportional to 1.0523.'\n", - "N0=1.0523;\n", - "N=1;\n", - "t=2.303*log(N0/N)*thalf/0.693;#Age of the mineral in years#\n", - "print'\\nAge of the mineral=t=years=7.62*10**8years',t#here also the answer given in textbook is wrong the one resulted through execution is the right one#\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in.ipynb b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in.ipynb new file mode 100755 index 00000000..0e2a1db4 --- /dev/null +++ b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in.ipynb @@ -0,0 +1,227 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5 Imperfection in Solids" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_1 pgno:56" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 5.1\n", + "\n", + "\n", + " Equilibrium number of vacancies/m**3 is for 1273K 2.18444488963e+25\n" + ] + } + ], + "source": [ + "# given that\n", + "Na=6.023*10**23 #Avogadro No.\n", + "rho=8.4e6 #Density of Copper in g/m**3\n", + "A=63.5 #Atomic weight of Copper\n", + "Qv=0.9 #Activation energy in eV\n", + "k=8.62*10**-5 #Boltzmann Constant in eV/K\n", + "T=1000+273#Temperature in K\n", + "from math import exp\n", + "print\"Example 5.1\\n\"\n", + "N=Na*rho/A #No. of atomic site per cubic meter\n", + "Nv=N*exp(-Qv/(k*T))\n", + "print\"\\n Equilibrium number of vacancies/m**3 is for 1273K\",Nv\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_3 pgno:57" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Example 5.3\n", + "\n", + "\n", + " Atomic of Al is 98.7039833218\n", + "\n", + " Atomic of Cu is 1.29601667817\n" + ] + } + ], + "source": [ + "# given that\n", + "C_Al=97. #Aluminium wt%\n", + "C_Cu=3. #Copper wt%\n", + "A_Al=26.98 #Atomic wt of Aluminium\n", + "A_Cu=63.55 #Atomic wt of Copper\n", + "\n", + "print\" Example 5.3\\n\"\n", + "CAl=C_Al*A_Cu*100/((C_Al*A_Cu)+(C_Cu*A_Al))\n", + "CCu=C_Cu*A_Al*100/((C_Cu*A_Al)+(C_Al*A_Cu))\n", + "print\"\\n Atomic of Al is\",CAl\n", + "print\"\\n Atomic of Cu is\",CCu\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_4 pgno:58" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 5.4\n", + "\n", + "\n", + " Number of Schottky defects are defects/m**3. 5.31422380078e+19\n" + ] + } + ], + "source": [ + "# given that\n", + "Na=6.023*10**23 #Avogadro No.\n", + "rho=1.955 #Density of KCl in g/cm**3\n", + "A_k= 39.10 #Atomic weight of potassium in g/mol\n", + "A_cl= 35.45 #Atomic weight of Chlorine in g/mol\n", + "Qs=2.6 #Activation energy in eV\n", + "k=8.62*10**-5 #Boltzmann Constant in eV/K\n", + "T=500+273 #Temperature in K\n", + "from math import exp\n", + "\n", + "print\"Example 5.4\\n\"\n", + "A = A_k+A_cl # Molar mass of KCl in gram\n", + "N=Na*rho*1e6/A #No. of atomic site per cubic meter\n", + "Ns=N*exp(-Qs/(2*k*T))\n", + "print\"\\n Number of Schottky defects are defects/m**3.\",Ns\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_6 pgno:58" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Example 5.6\n", + "\n", + "\n", + " Part A\n", + "\n", + " Grain size number is \n", + "6.49185309633\n", + "\n", + " Part B\n", + "\n", + " At magnification of 85x\n", + "\n", + " Number of grains per inch square are\n", + "62.2837370242\n" + ] + } + ], + "source": [ + "# given that \n", + "N=45. #Number of grains per square inch\n", + "M=85. # magnification\n", + "from math import log\n", + "print\"Example 5.6\\n\"\n", + "print\"\\n Part A\"\n", + "n=(log(N)/log(2))+1 #calculation for grain size no. N=2**(n-1)\n", + "print\"\\n Grain size number is \\n\",n\n", + "print\"\\n Part B\"\n", + "Nm=(100/M)**2*2**(n-1)\n", + "print\"\\n At magnification of 85x\\n\"\n", + "print\" Number of grains per inch square are\\n\",Nm\n", + "# answer in book is 62.6. It is because of rounding off at intermediate stages\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in_Solids.ipynb b/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in_Solids.ipynb deleted file mode 100755 index 0e2a1db4..00000000 --- a/sample_notebooks/makarala shamukha venkatasahithi/Chapter_5_Imperfection_in_Solids.ipynb +++ /dev/null @@ -1,227 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 5 Imperfection in Solids" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_1 pgno:56" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 5.1\n", - "\n", - "\n", - " Equilibrium number of vacancies/m**3 is for 1273K 2.18444488963e+25\n" - ] - } - ], - "source": [ - "# given that\n", - "Na=6.023*10**23 #Avogadro No.\n", - "rho=8.4e6 #Density of Copper in g/m**3\n", - "A=63.5 #Atomic weight of Copper\n", - "Qv=0.9 #Activation energy in eV\n", - "k=8.62*10**-5 #Boltzmann Constant in eV/K\n", - "T=1000+273#Temperature in K\n", - "from math import exp\n", - "print\"Example 5.1\\n\"\n", - "N=Na*rho/A #No. of atomic site per cubic meter\n", - "Nv=N*exp(-Qv/(k*T))\n", - "print\"\\n Equilibrium number of vacancies/m**3 is for 1273K\",Nv\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_3 pgno:57" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Example 5.3\n", - "\n", - "\n", - " Atomic of Al is 98.7039833218\n", - "\n", - " Atomic of Cu is 1.29601667817\n" - ] - } - ], - "source": [ - "# given that\n", - "C_Al=97. #Aluminium wt%\n", - "C_Cu=3. #Copper wt%\n", - "A_Al=26.98 #Atomic wt of Aluminium\n", - "A_Cu=63.55 #Atomic wt of Copper\n", - "\n", - "print\" Example 5.3\\n\"\n", - "CAl=C_Al*A_Cu*100/((C_Al*A_Cu)+(C_Cu*A_Al))\n", - "CCu=C_Cu*A_Al*100/((C_Cu*A_Al)+(C_Al*A_Cu))\n", - "print\"\\n Atomic of Al is\",CAl\n", - "print\"\\n Atomic of Cu is\",CCu\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_4 pgno:58" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 5.4\n", - "\n", - "\n", - " Number of Schottky defects are defects/m**3. 5.31422380078e+19\n" - ] - } - ], - "source": [ - "# given that\n", - "Na=6.023*10**23 #Avogadro No.\n", - "rho=1.955 #Density of KCl in g/cm**3\n", - "A_k= 39.10 #Atomic weight of potassium in g/mol\n", - "A_cl= 35.45 #Atomic weight of Chlorine in g/mol\n", - "Qs=2.6 #Activation energy in eV\n", - "k=8.62*10**-5 #Boltzmann Constant in eV/K\n", - "T=500+273 #Temperature in K\n", - "from math import exp\n", - "\n", - "print\"Example 5.4\\n\"\n", - "A = A_k+A_cl # Molar mass of KCl in gram\n", - "N=Na*rho*1e6/A #No. of atomic site per cubic meter\n", - "Ns=N*exp(-Qs/(2*k*T))\n", - "print\"\\n Number of Schottky defects are defects/m**3.\",Ns\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_6 pgno:58" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Example 5.6\n", - "\n", - "\n", - " Part A\n", - "\n", - " Grain size number is \n", - "6.49185309633\n", - "\n", - " Part B\n", - "\n", - " At magnification of 85x\n", - "\n", - " Number of grains per inch square are\n", - "62.2837370242\n" - ] - } - ], - "source": [ - "# given that \n", - "N=45. #Number of grains per square inch\n", - "M=85. # magnification\n", - "from math import log\n", - "print\"Example 5.6\\n\"\n", - "print\"\\n Part A\"\n", - "n=(log(N)/log(2))+1 #calculation for grain size no. N=2**(n-1)\n", - "print\"\\n Grain size number is \\n\",n\n", - "print\"\\n Part B\"\n", - "Nm=(100/M)**2*2**(n-1)\n", - "print\"\\n At magnification of 85x\\n\"\n", - "print\" Number of grains per inch square are\\n\",Nm\n", - "# answer in book is 62.6. It is because of rounding off at intermediate stages\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave.ipynb b/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave.ipynb new file mode 100755 index 00000000..38d38099 --- /dev/null +++ b/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave.ipynb @@ -0,0 +1,299 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 7 Wave Guides" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_1 pgno:75" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Critical wavelength = cm\n", + "15.24\n", + "-Guide wavelength = cm 13.3\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "c=3.*(10**8);\n", + "f=3000.*(10**8);\n", + "lo=c/f;\n", + "l=lo*(10**4);\n", + "m=1.;n=0;a=7.62;\n", + "lc=2*a;\n", + "print\"-Critical wavelength = cm\\n\",lc\n", + "lg=sqrt((l*l*lc*lc)/((lc*lc)-(l*l)));\n", + "print\"-Guide wavelength = cm\",round(lg*10)/10\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_2 pgno:76" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Frequency of dominant mode = GHz 5.0\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "a=3;\n", + "lc=2*a;\n", + "Zs=500;n=377;c=3*(10**8);\n", + "lo=sqrt(1-((n/Zs)**2))*lc;\n", + "f=c/lo;\n", + "f1=f/(10**7);\n", + "print\"Frequency of dominant mode = GHz\",round(f1*100)/100\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_3 pgno:78" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i)Cutoff wavelegth = cm\n", + "9.0\n", + "(ii)Guide wavelength = cm\n", + "3.59\n", + "(iii)Phase velocity = * 10**8 m/sec\n", + "3.23\n", + " Group velocity = * 10**8 m/sec\n", + "2.79\n", + "(iv)Characteristic impedance = ohm 406.0\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "a=4.5;b=3.;f=9.*(10**9);c=3.0*(10**8);n=377.\n", + "lo=c/f;\n", + "l=lo*(10**2);\n", + "lc=2*a;\n", + "print\"(i)Cutoff wavelegth = cm\\n\",lc\n", + "lg=l /(sqrt(1-((l/lc)**2)));\n", + "print\"(ii)Guide wavelength = cm\\n\",round(lg*100)/100\n", + "Vp=(lg/l)*c*10**-8;\n", + "print\"(iii)Phase velocity = * 10**8 m/sec\\n\",round(Vp*100)/100\n", + "Vg=(l/lg)*c*10**-8;\n", + "print\" Group velocity = * 10**8 m/sec\\n\",round(Vg*100)/100\n", + "Z=n/(sqrt(1-((l/lc)**2)));\n", + "print\"(iv)Characteristic impedance = ohm\",round(Z)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_4 pgno:79" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total attenuation = db 681.88\n", + "The difference in result is due to erroneous value in textbook\n" + ] + } + ], + "source": [ + "a=1.;c=3.*(10**8);f=(10**9);d=25.;\n", + "lc=2*a;\n", + "lo=c/f;\n", + "l=lo/(10**2);\n", + "att=(54.55/lc)*d;\n", + "print\"Total attenuation = db\",round(att*100)/100\n", + "#the difference in result is due to erroneous value in textbook.\n", + "print (\"The difference in result is due to erroneous value in textbook\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_5 pgno:80" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Phase velocity Vp = * 10**8 m/sec\n", + "4.2\n", + "-Group velocity Vg = * 10**8 m/sec\n", + "2.2\n", + "-Phase constant = radians/m 45.0\n" + ] + } + ], + "source": [ + "from math import sqrt,pi\n", + "c=3.*(10**8);f=3000.*(10**6);a=.0722;\n", + "lo=c/f;\n", + "lc=2*a;\n", + "lg=lo/(sqrt(1-((lo/lc)**2)));\n", + "Vp=(lg/lo)*c*10**-8;\n", + "print\"-Phase velocity Vp = * 10**8 m/sec\\n\",round(Vp*10)/10\n", + "Vg=(lo/lg)*c*10**-8;\n", + "print\"-Group velocity Vg = * 10**8 m/sec\\n\",round(Vg*10)/10\n", + "b=(2*pi)/lg;\n", + "print\"-Phase constant = radians/m\",round(b)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_6 pgno:81" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(i)Cutoff frequency for TE11 = GHz\n", + "3.52\n", + "(ii)Cutoff frequency for TE01 = GHz 4.6\n" + ] + } + ], + "source": [ + "\n", + "d=5.;c=3.*(10**8);\n", + "lo=1.706*d;\n", + "f=c/lo;\n", + "ff=f/(10**7);\n", + "print\"(i)Cutoff frequency for TE11 = GHz\\n\",round(ff*100)/100\n", + "l=1.306*d;\n", + "fc=c/l;\n", + "ffc=fc/(10**7);\n", + "print\"(ii)Cutoff frequency for TE01 = GHz\",round(ffc*10)/10\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 7_7 pgno:82" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "-Cutoff wavelength = cm\n", + "8.54\n", + "-Guide wavelength = cm\n", + "4.17\n", + "-Characteristic wave impedance = ohm 419.7\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "c=3.*(10**8);f=8.*(10**9);r=2.5;h=1.84;n=377.;\n", + "l=c/f;\n", + "lo=l*(10**2);\n", + "lc=2*pi*r/h;\n", + "print\"-Cutoff wavelength = cm\\n\",round(lc*100)/100\n", + "lp=lo/(sqrt(1-((lo/lc)**2)));\n", + "print\"-Guide wavelength = cm\\n\",round(lp*100)/100\n", + "Zo=n/(sqrt(1-((lo/lc)**2)));\n", + "print\"-Characteristic wave impedance = ohm\",round(Zo*10)/10\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave_Guides.ipynb b/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave_Guides.ipynb deleted file mode 100755 index 38d38099..00000000 --- a/sample_notebooks/manchukondasrinivasa rao/Chapter_7_Wave_Guides.ipynb +++ /dev/null @@ -1,299 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 7 Wave Guides" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_1 pgno:75" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Critical wavelength = cm\n", - "15.24\n", - "-Guide wavelength = cm 13.3\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "c=3.*(10**8);\n", - "f=3000.*(10**8);\n", - "lo=c/f;\n", - "l=lo*(10**4);\n", - "m=1.;n=0;a=7.62;\n", - "lc=2*a;\n", - "print\"-Critical wavelength = cm\\n\",lc\n", - "lg=sqrt((l*l*lc*lc)/((lc*lc)-(l*l)));\n", - "print\"-Guide wavelength = cm\",round(lg*10)/10\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_2 pgno:76" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Frequency of dominant mode = GHz 5.0\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "a=3;\n", - "lc=2*a;\n", - "Zs=500;n=377;c=3*(10**8);\n", - "lo=sqrt(1-((n/Zs)**2))*lc;\n", - "f=c/lo;\n", - "f1=f/(10**7);\n", - "print\"Frequency of dominant mode = GHz\",round(f1*100)/100\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_3 pgno:78" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i)Cutoff wavelegth = cm\n", - "9.0\n", - "(ii)Guide wavelength = cm\n", - "3.59\n", - "(iii)Phase velocity = * 10**8 m/sec\n", - "3.23\n", - " Group velocity = * 10**8 m/sec\n", - "2.79\n", - "(iv)Characteristic impedance = ohm 406.0\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "a=4.5;b=3.;f=9.*(10**9);c=3.0*(10**8);n=377.\n", - "lo=c/f;\n", - "l=lo*(10**2);\n", - "lc=2*a;\n", - "print\"(i)Cutoff wavelegth = cm\\n\",lc\n", - "lg=l /(sqrt(1-((l/lc)**2)));\n", - "print\"(ii)Guide wavelength = cm\\n\",round(lg*100)/100\n", - "Vp=(lg/l)*c*10**-8;\n", - "print\"(iii)Phase velocity = * 10**8 m/sec\\n\",round(Vp*100)/100\n", - "Vg=(l/lg)*c*10**-8;\n", - "print\" Group velocity = * 10**8 m/sec\\n\",round(Vg*100)/100\n", - "Z=n/(sqrt(1-((l/lc)**2)));\n", - "print\"(iv)Characteristic impedance = ohm\",round(Z)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_4 pgno:79" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Total attenuation = db 681.88\n", - "The difference in result is due to erroneous value in textbook\n" - ] - } - ], - "source": [ - "a=1.;c=3.*(10**8);f=(10**9);d=25.;\n", - "lc=2*a;\n", - "lo=c/f;\n", - "l=lo/(10**2);\n", - "att=(54.55/lc)*d;\n", - "print\"Total attenuation = db\",round(att*100)/100\n", - "#the difference in result is due to erroneous value in textbook.\n", - "print (\"The difference in result is due to erroneous value in textbook\")\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_5 pgno:80" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Phase velocity Vp = * 10**8 m/sec\n", - "4.2\n", - "-Group velocity Vg = * 10**8 m/sec\n", - "2.2\n", - "-Phase constant = radians/m 45.0\n" - ] - } - ], - "source": [ - "from math import sqrt,pi\n", - "c=3.*(10**8);f=3000.*(10**6);a=.0722;\n", - "lo=c/f;\n", - "lc=2*a;\n", - "lg=lo/(sqrt(1-((lo/lc)**2)));\n", - "Vp=(lg/lo)*c*10**-8;\n", - "print\"-Phase velocity Vp = * 10**8 m/sec\\n\",round(Vp*10)/10\n", - "Vg=(lo/lg)*c*10**-8;\n", - "print\"-Group velocity Vg = * 10**8 m/sec\\n\",round(Vg*10)/10\n", - "b=(2*pi)/lg;\n", - "print\"-Phase constant = radians/m\",round(b)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_6 pgno:81" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(i)Cutoff frequency for TE11 = GHz\n", - "3.52\n", - "(ii)Cutoff frequency for TE01 = GHz 4.6\n" - ] - } - ], - "source": [ - "\n", - "d=5.;c=3.*(10**8);\n", - "lo=1.706*d;\n", - "f=c/lo;\n", - "ff=f/(10**7);\n", - "print\"(i)Cutoff frequency for TE11 = GHz\\n\",round(ff*100)/100\n", - "l=1.306*d;\n", - "fc=c/l;\n", - "ffc=fc/(10**7);\n", - "print\"(ii)Cutoff frequency for TE01 = GHz\",round(ffc*10)/10\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 7_7 pgno:82" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "-Cutoff wavelength = cm\n", - "8.54\n", - "-Guide wavelength = cm\n", - "4.17\n", - "-Characteristic wave impedance = ohm 419.7\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "c=3.*(10**8);f=8.*(10**9);r=2.5;h=1.84;n=377.;\n", - "l=c/f;\n", - "lo=l*(10**2);\n", - "lc=2*pi*r/h;\n", - "print\"-Cutoff wavelength = cm\\n\",round(lc*100)/100\n", - "lp=lo/(sqrt(1-((lo/lc)**2)));\n", - "print\"-Guide wavelength = cm\\n\",round(lp*100)/100\n", - "Zo=n/(sqrt(1-((lo/lc)**2)));\n", - "print\"-Characteristic wave impedance = ohm\",round(Zo*10)/10\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/marupeddisameer chaitanya/Chapter_4_Diffusion_and_Reaction_in_Porous_Catalysts.ipynb b/sample_notebooks/marupeddisameer chaitanya/Chapter_4_Diffusion_and_Reaction_in_Porous_Catalysts.ipynb deleted file mode 100755 index a01d0a9f..00000000 --- a/sample_notebooks/marupeddisameer chaitanya/Chapter_4_Diffusion_and_Reaction_in_Porous_Catalysts.ipynb +++ /dev/null @@ -1,303 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 4 Diffusion and Reaction in Porous Catalysts" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4_1 pgno:135" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " OUTPUT Ex4.1.a\n", - "\n", - "=================================================\n", - "\n", - "The predicted diffusivity of Chlorine is cm2/s 0.00217149494706\n", - "\n", - "\n", - " OUTPUT Ex4.1.b\n", - "\n", - "=================================================\n", - "\n", - "The tortusity value = 1.25277093159\n", - "\n", - "\n", - " OUTPUT Ex4.1.b\n", - "\n", - "=================================================\n", - "\n", - "The Effective diffusivity of Chlorine K a atm = cm2/sec 573.0 15.0 1.83302312261e-09\n" - ] - } - ], - "source": [ - "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc.,USA,pp 436.\n", - "#Chapter-4 Ex4.1 Pg No. 135\n", - "#Title:Diffusivity of Chlorine and tortuosity in catalyst pellet\n", - "#===========================================================================================================\n", - "# COMMON INPUT \n", - "S_g=235.;#Total surface per gram (m2/g)\n", - "V_g=0.29E-6;#Pore volume per gram (cm3/g)\n", - "rho_p=1.41;#Density of particle (g/cm3)\n", - "D_He=0.0065;#Effective diffusivity of He (cm2/sec)\n", - "D_AB=0.73;# at 1atm and 298K\n", - "M_He=4.;#Molecular weight of He\n", - "M_Cl2=70.09;#Molecular weight of Cl2\n", - "T_ref=293;#Reference temperature\n", - "T_degC=300.;\n", - "T_01=T_degC+273;#Reaction temperature(K) (Ex4.1.a)\n", - "T_02=298.;#Operating temperature (Ex4.1.b)\n", - "T_03=573.;#operating temperature (Ex4.1.c)\n", - "P_ref=1;#Reference pressure\n", - "D_Cl2_CH4=0.15;#at 1atm 273K\n", - "P=15.;#operating pressure \n", - "#tau=1.25;#From value calculated in Ex4.1.b Pg. No. 136\n", - "from math import sqrt\n", - "\n", - "\n", - "#CALCULATION (Ex4.1.a)\n", - "r_bar=2*V_g/S_g;#Mean Pore radius\n", - "D_Cl2_Ex_a=D_He*((M_He/M_Cl2)*(T_01/T_ref))**(0.5);#Assuming Knudsen flow at 573K\n", - "\n", - "#CALCULATION (Ex4.1.b)\n", - "r_bar=2.*V_g*(10**6)/(S_g *(10**4));\n", - "D_K=9700.*(r_bar)*(T_ref/M_He)**(0.5);#Knudsen flow\n", - "D_AB1=D_AB*(293./298.)**(1.7)# at 1.5 atm and 293K\n", - "D_pore=1./((1./D_K)+(1./D_AB1));#pore diffusion\n", - "Epsilon=V_g*rho_p*(10**6);\n", - "tau=(D_pore*Epsilon)/D_He;#Tortusity\n", - "\n", - "#CALCULATION (Ex4.1.c)\n", - "D_Cl2_CH4_new=D_Cl2_CH4*(P_ref/P)*(T_03/T_ref)**(1.7);\n", - "D_K_Cl2=9700*r_bar*sqrt(T_03/M_Cl2);\n", - "D_pore=1/((1/D_Cl2_CH4_new)+(1/D_K_Cl2));\n", - "Epsilon=V_g*rho_p;\n", - "D_Cl2_Ex_c=D_pore*Epsilon/tau;\n", - "\n", - "\n", - "#OUTPUT\n", - "print '\\n OUTPUT Ex4.1.a'\n", - "print '\\n================================================='\n", - "print '\\nThe predicted diffusivity of Chlorine is cm2/s ',D_Cl2_Ex_a\n", - "print '\\n\\n OUTPUT Ex4.1.b'\n", - "print '\\n================================================='\n", - "print '\\nThe tortusity value = ',tau\n", - "print '\\n\\n OUTPUT Ex4.1.b'\n", - "print '\\n================================================='\n", - "print '\\nThe Effective diffusivity of Chlorine K a atm = cm2/sec ',T_03, P, D_Cl2_Ex_c\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4_2 pgno:140" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " OUTPUT Ex4.2.a\n", - "\n", - "=================================================\n", - "\n", - " The effective diffusivity of O2 in air = cm2/s 0.0235933499021\n", - "\n", - "\n", - " OUTPUT Ex4.2.b\n", - "\n", - "=================================================\n", - "\n", - " The calculated surface mean pore radius = cm 6e-07\n", - "\n", - " The predicted pore diffusivity = cm2/sec 0.0218264089105\n", - "\n", - " The corresponding tortusity = 0.499558598529\n" - ] - } - ], - "source": [ - "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc.,USA,pp 436.\n", - "#Chapter-4 Ex4.2 Pg No. 140\n", - "#Title:Effective diffusivity of O2 in air\n", - "#============================================================================================================\n", - "\n", - "# COMMON INPUT\n", - "S_g=150.;#Total surface per gram (m2/g)\n", - "V_g=0.45;#Pore volume per gram (cm3/g)\n", - "V_i=0.30;#Micropore volume per gram (cm3/g)\n", - "V_a=0.15;# Macropore volume per gram (cm3/g)\n", - "rho_P=1.2;#Density of particle (g/cm3)\n", - "tau=2.5;# Tortusity\n", - "r_bar_i=40*(10**(-8));#Micropore radius\n", - "r_bar_a=2000*(10**(-8));#Macropore radius\n", - "D_AB=0.49;#For N2O2 at 1 atm (cm2/s)\n", - "M_O2=32.;#Molecular weight of O2\n", - "T=493.;#Opereating Temperature (K)\n", - "from math import sqrt\n", - "\n", - "\n", - "\n", - "#CALCULATION (Ex4.2.a)\n", - "Epsilon=V_g*rho_P;\n", - "D_K_i=9700*(r_bar_i)*sqrt(T/M_O2);#Knudsen flow for micropore\n", - "D_Pore_i=1/((1/D_K_i)+(1/D_AB))\n", - "D_K_a=9700*(r_bar_a)*sqrt(T/M_O2);\n", - "D_Pore_a=1/((1/D_K_a)+(1/D_AB));##Knudsen flow for macropore\n", - "D_Pore_Avg=(V_i*D_Pore_i+V_a*D_Pore_a)/(V_i+V_a);\n", - "D_e=Epsilon*D_Pore_Avg/tau;\n", - "\n", - "#CALCULATION (Ex4.2.b)\n", - "Epsilon=V_g*rho_P;\n", - "r_bar=2*V_g/(S_g*10**4);\n", - "D_K=9700*(r_bar)*sqrt(T/M_O2);#Knudsen Flow\n", - "D_Pore=1/((1/D_K)+(1/D_AB));\n", - "tau=D_Pore*Epsilon/D_e;\n", - "\n", - "#OUTPUT\n", - "print '\\n OUTPUT Ex4.2.a'\n", - "print '\\n================================================='\n", - "print '\\n The effective diffusivity of O2 in air = cm2/s',D_e \n", - "print '\\n\\n OUTPUT Ex4.2.b'\n", - "print '\\n================================================='\n", - "print '\\n The calculated surface mean pore radius = cm',r_bar \n", - "print '\\n The predicted pore diffusivity = cm2/sec',D_Pore \n", - "print '\\n The corresponding tortusity = ',tau\n", - "\n", - "\n", - "\n", - "#======================================================END OF PROGRAM========================================\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 4_4 pgno:157" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\tBased on average pressures calculated Rate and Effectiveness factor\n", - "\n", - "\t r : (mol/s cm3) 1.17056498924e-05\n", - "\n", - "\t eta_calc : 0.174804371726\n", - "\n", - " The actual value of Effectiveness factor eta_actual : 0.427402185863\n" - ] - } - ], - "source": [ - "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc. USA,pp 436.\n", - "#Chapter-4 Ex4.4 Pg No.157\n", - "#Title: Effectiveness factor for solid catalyzed reaction\n", - "#======================================================================================================================\n", - "\n", - "#INPUT\n", - "D_e_A=0.02;#(cm2/s)\n", - "D_e_B=0.03;#(cm2/s)\n", - "D_e_C=0.015;#(cm2/s)\n", - "X_f_A=0.3;\n", - "X_f_B=(1-X_f_A);\n", - "eta_assumed=0.68;#Effectiveness factor from Fig.4.8 for first order reaction\n", - "T=150.;#(deg C)\n", - "T_K=T+273;#(K)\n", - "r=0.3;#(cm)Radius of catalyst sphere\n", - "P_opt=4.;#(atm)Operating Pressure \n", - "R=82.056;#(cm3 atm/K mol)Gas constant \n", - "\n", - "\n", - "#CALCULATION\n", - "#Kinetic equation r= (2.5*10**-5*P_A*P_B)/(1+0.1*P_A+2*P_C)**2\n", - "P_A=X_f_A*P_opt;\n", - "P_B=X_f_B*P_opt;\n", - "r_star=(2.5*10**-5*P_A*P_B)/(1+0.1*P_A)**2;\n", - "C_A=P_A/(R*T_K);\n", - "k=r_star/C_A;\n", - "Phi= r*(k/D_e_A)**(0.5);\n", - "P_A_bar=eta_assumed*P_A;\n", - "delta_P_A=P_A*(1-eta_assumed);\n", - "delta_P_B=delta_P_A*(D_e_A/D_e_B);\n", - "P_B_bar=P_B-delta_P_B;\n", - "delta_P_C=delta_P_A*(D_e_A/D_e_C);\n", - "P_C_bar=delta_P_C;\n", - "r_calc=(2.5*10**-5*P_A_bar*P_B_bar)/(1+0.1*P_A_bar+2*P_C_bar)**2\n", - "eta_calc=r_calc/r_star;\n", - "eta_approx=(eta_calc+eta_assumed)/2;\n", - "\n", - "#OUTPUT\n", - "#Console Output\n", - "print'\\tBased on average pressures calculated Rate and Effectiveness factor'\n", - "print'\\n\\t r : (mol/s cm3)',r_calc\n", - "print'\\n\\t eta_calc : ',eta_calc\n", - "print'\\n The actual value of Effectiveness factor eta_actual :',eta_approx\n", - "\n", - "#================================================END OF PROGRAM==================================================================================\n", - "\n", - "\n", - "\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter.ipynb b/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter.ipynb new file mode 100755 index 00000000..bff5435f --- /dev/null +++ b/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter.ipynb @@ -0,0 +1,247 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 9 : Theories of Mass Transfer" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.1.1 pgno31" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The film thickness is cm 0.00765\n" + ] + } + ], + "source": [ + "#initialization of variables\n", + "p1 = 10. # pressure in atm\n", + "H = 600. # henrys constant in atm\n", + "c1 = 0 # gmol/cc\n", + "N1 = 2.3*10**-6 # mass flux in mol/cm**2-sec\n", + "c = 1./18. #total Concentration in g-mol/cc\n", + "D = 1.9*10**-5 # Diffusion co efficient in cm**2/sec\n", + "#Calculations\n", + "c1i = (p1/H)*c # Component concentration in gmol/cc\n", + "k = N1/(c1i-c1)#Mass transfer co efficient in cm/sec\n", + "l = D/k # Film thickness in cm\n", + "#Results\n", + "print\"The film thickness is cm\",round(l,5)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.2.1 pgno:34" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The contact time sec 3.9\n", + "\n", + "The surface resident time sec 3.0\n" + ] + } + ], + "source": [ + "#initialization of variables\n", + "D = 1.9*10**-5 #Diffusion co efficient in cm**2/sec\n", + "k = 2.5*10**-3 # M.T.C in cm/sec\n", + "from math import pi\n", + "#Calculations\n", + "Lbyvmax = 4*D/((k**2)*pi)#sec\n", + "tou = D/k**2 # sec\n", + "#Results\n", + "print\"The contact time sec\",round(Lbyvmax,1)\n", + "print\"\\nThe surface resident time sec\",round(tou,1)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.3.1 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The apparent m.t.c for the first case is cm/sec 0.000379885493042\n", + "\n", + "The apparent m.t.c for the second case is cm/sec 0.000742723884992\n", + "\n", + "The apparent is proportional to the power of of the velocity 0.61\n" + ] + } + ], + "source": [ + "#initialization of variables\n", + "const = 0.5 # The part of flow in the system which bypasses the region where the mass transfer occurs\n", + "v1 = 1. # cm/sec\n", + "al = 10**3\n", + "k = 10**-3 # cm/sec\n", + "v2 = 3. # cm/sec\n", + "from math import log\n", + "from math import exp\n", + "#Calculations\n", + "C1byC10first = const + (1-const)*(exp(-k*al/v1))# c1/c10\n", + "appk1 = (v1/al)*(log(1/C1byC10first))# Apparent m.t.c for first case in cm/sec\n", + "C1byC10second = const + (1-const)*(exp(-((3)**0.5)*k*al/v2))#c1/c10 in second case\n", + "appk2 = (v2/al)*log(1/C1byC10second)# apparent m.t.c for second case in cm/sec\n", + "power = log(appk2/appk1)/log(v2/v1)\n", + "#Results\n", + "print\"The apparent m.t.c for the first case is cm/sec\",appk1\n", + "print\"\\nThe apparent m.t.c for the second case is cm/sec\",appk2\n", + "print\"\\nThe apparent is proportional to the power of of the velocity\",round(power,2)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.4.1 pgno:37" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The average mass transfer coefficient is cm/sec 0.000431530124388\n" + ] + } + ], + "source": [ + "#initialization of variables\n", + "D = 1*10**-5 #cm**2/sec\n", + "d = 2.3 # cm\n", + "L = 14 # cm\n", + "v0 = 6.1 # cm/sec\n", + "#gamma(4./3.)=0.8909512761;\n", + "#calculations\n", + "k = ((3**(1./3.))/(0.8909512761))*((D/d))*(((d**2)*v0/(D*L))**(1./3.))# cm/sec\n", + "#Results\n", + "print\"The average mass transfer coefficient is cm/sec\",k\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 9.4.2 pgno:40" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The distance at which turbulent flow starts is cm 300.0\n", + "\n", + "The boundary layer for flow at this point is cm 300.0\n", + "\n", + "The boundary layer for concentration at this point is cm 300.0\n", + "\n", + "The local m.t.c at the leading edge and at the position of transistion is x10**-5 cm/sec 0.589714620247\n" + ] + } + ], + "source": [ + "#initialization of variables\n", + "tn = 300000 # turbulence number\n", + "v0 = 10 # cm/sec\n", + "p = 1 # g/cc\n", + "mu = 0.01 # g/cm-sec\n", + "delta = 2.5 #cm\n", + "D = 1*10**-5 # cm**2/sec\n", + "#Calculations\n", + "x = tn*mu/(v0*p)# cm\n", + "delta = ((280/13)**(1/2))*x*((mu/(x*v0*p))**(1/2))#cm\n", + "deltac = ((D*p/mu)**(1/3))*delta#cm\n", + "k = (0.323*(D/x)*((x*v0*p/mu)**0.5)*((mu/(p*D))**(1/3)))*10**5# x*10**-5 cm/sec\n", + "#Results\n", + "print\"The distance at which turbulent flow starts is cm\",x\n", + "print\"\\nThe boundary layer for flow at this point is cm\",delta\n", + "print\"\\nThe boundary layer for concentration at this point is cm\",deltac\n", + "print\"\\nThe local m.t.c at the leading edge and at the position of transistion is x10**-5 cm/sec\",k\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter_9).ipynb b/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter_9).ipynb deleted file mode 100755 index bff5435f..00000000 --- a/sample_notebooks/marupeddisameer chaitanya/Sample_(chapter_9).ipynb +++ /dev/null @@ -1,247 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 9 : Theories of Mass Transfer" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 9.1.1 pgno31" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The film thickness is cm 0.00765\n" - ] - } - ], - "source": [ - "#initialization of variables\n", - "p1 = 10. # pressure in atm\n", - "H = 600. # henrys constant in atm\n", - "c1 = 0 # gmol/cc\n", - "N1 = 2.3*10**-6 # mass flux in mol/cm**2-sec\n", - "c = 1./18. #total Concentration in g-mol/cc\n", - "D = 1.9*10**-5 # Diffusion co efficient in cm**2/sec\n", - "#Calculations\n", - "c1i = (p1/H)*c # Component concentration in gmol/cc\n", - "k = N1/(c1i-c1)#Mass transfer co efficient in cm/sec\n", - "l = D/k # Film thickness in cm\n", - "#Results\n", - "print\"The film thickness is cm\",round(l,5)\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 9.2.1 pgno:34" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The contact time sec 3.9\n", - "\n", - "The surface resident time sec 3.0\n" - ] - } - ], - "source": [ - "#initialization of variables\n", - "D = 1.9*10**-5 #Diffusion co efficient in cm**2/sec\n", - "k = 2.5*10**-3 # M.T.C in cm/sec\n", - "from math import pi\n", - "#Calculations\n", - "Lbyvmax = 4*D/((k**2)*pi)#sec\n", - "tou = D/k**2 # sec\n", - "#Results\n", - "print\"The contact time sec\",round(Lbyvmax,1)\n", - "print\"\\nThe surface resident time sec\",round(tou,1)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 9.3.1 pgno:35" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The apparent m.t.c for the first case is cm/sec 0.000379885493042\n", - "\n", - "The apparent m.t.c for the second case is cm/sec 0.000742723884992\n", - "\n", - "The apparent is proportional to the power of of the velocity 0.61\n" - ] - } - ], - "source": [ - "#initialization of variables\n", - "const = 0.5 # The part of flow in the system which bypasses the region where the mass transfer occurs\n", - "v1 = 1. # cm/sec\n", - "al = 10**3\n", - "k = 10**-3 # cm/sec\n", - "v2 = 3. # cm/sec\n", - "from math import log\n", - "from math import exp\n", - "#Calculations\n", - "C1byC10first = const + (1-const)*(exp(-k*al/v1))# c1/c10\n", - "appk1 = (v1/al)*(log(1/C1byC10first))# Apparent m.t.c for first case in cm/sec\n", - "C1byC10second = const + (1-const)*(exp(-((3)**0.5)*k*al/v2))#c1/c10 in second case\n", - "appk2 = (v2/al)*log(1/C1byC10second)# apparent m.t.c for second case in cm/sec\n", - "power = log(appk2/appk1)/log(v2/v1)\n", - "#Results\n", - "print\"The apparent m.t.c for the first case is cm/sec\",appk1\n", - "print\"\\nThe apparent m.t.c for the second case is cm/sec\",appk2\n", - "print\"\\nThe apparent is proportional to the power of of the velocity\",round(power,2)\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 9.4.1 pgno:37" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The average mass transfer coefficient is cm/sec 0.000431530124388\n" - ] - } - ], - "source": [ - "#initialization of variables\n", - "D = 1*10**-5 #cm**2/sec\n", - "d = 2.3 # cm\n", - "L = 14 # cm\n", - "v0 = 6.1 # cm/sec\n", - "#gamma(4./3.)=0.8909512761;\n", - "#calculations\n", - "k = ((3**(1./3.))/(0.8909512761))*((D/d))*(((d**2)*v0/(D*L))**(1./3.))# cm/sec\n", - "#Results\n", - "print\"The average mass transfer coefficient is cm/sec\",k\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 9.4.2 pgno:40" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The distance at which turbulent flow starts is cm 300.0\n", - "\n", - "The boundary layer for flow at this point is cm 300.0\n", - "\n", - "The boundary layer for concentration at this point is cm 300.0\n", - "\n", - "The local m.t.c at the leading edge and at the position of transistion is x10**-5 cm/sec 0.589714620247\n" - ] - } - ], - "source": [ - "#initialization of variables\n", - "tn = 300000 # turbulence number\n", - "v0 = 10 # cm/sec\n", - "p = 1 # g/cc\n", - "mu = 0.01 # g/cm-sec\n", - "delta = 2.5 #cm\n", - "D = 1*10**-5 # cm**2/sec\n", - "#Calculations\n", - "x = tn*mu/(v0*p)# cm\n", - "delta = ((280/13)**(1/2))*x*((mu/(x*v0*p))**(1/2))#cm\n", - "deltac = ((D*p/mu)**(1/3))*delta#cm\n", - "k = (0.323*(D/x)*((x*v0*p/mu)**0.5)*((mu/(p*D))**(1/3)))*10**5# x*10**-5 cm/sec\n", - "#Results\n", - "print\"The distance at which turbulent flow starts is cm\",x\n", - "print\"\\nThe boundary layer for flow at this point is cm\",delta\n", - "print\"\\nThe boundary layer for concentration at this point is cm\",deltac\n", - "print\"\\nThe local m.t.c at the leading edge and at the position of transistion is x10**-5 cm/sec\",k\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/marupeddisameer chaitanya/marupeddisameer chaitanya_version_backup/Chapter_4_Diffusion_and_Reaction_in_Porous.ipynb b/sample_notebooks/marupeddisameer chaitanya/marupeddisameer chaitanya_version_backup/Chapter_4_Diffusion_and_Reaction_in_Porous.ipynb new file mode 100755 index 00000000..a01d0a9f --- /dev/null +++ b/sample_notebooks/marupeddisameer chaitanya/marupeddisameer chaitanya_version_backup/Chapter_4_Diffusion_and_Reaction_in_Porous.ipynb @@ -0,0 +1,303 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 4 Diffusion and Reaction in Porous Catalysts" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4_1 pgno:135" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " OUTPUT Ex4.1.a\n", + "\n", + "=================================================\n", + "\n", + "The predicted diffusivity of Chlorine is cm2/s 0.00217149494706\n", + "\n", + "\n", + " OUTPUT Ex4.1.b\n", + "\n", + "=================================================\n", + "\n", + "The tortusity value = 1.25277093159\n", + "\n", + "\n", + " OUTPUT Ex4.1.b\n", + "\n", + "=================================================\n", + "\n", + "The Effective diffusivity of Chlorine K a atm = cm2/sec 573.0 15.0 1.83302312261e-09\n" + ] + } + ], + "source": [ + "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc.,USA,pp 436.\n", + "#Chapter-4 Ex4.1 Pg No. 135\n", + "#Title:Diffusivity of Chlorine and tortuosity in catalyst pellet\n", + "#===========================================================================================================\n", + "# COMMON INPUT \n", + "S_g=235.;#Total surface per gram (m2/g)\n", + "V_g=0.29E-6;#Pore volume per gram (cm3/g)\n", + "rho_p=1.41;#Density of particle (g/cm3)\n", + "D_He=0.0065;#Effective diffusivity of He (cm2/sec)\n", + "D_AB=0.73;# at 1atm and 298K\n", + "M_He=4.;#Molecular weight of He\n", + "M_Cl2=70.09;#Molecular weight of Cl2\n", + "T_ref=293;#Reference temperature\n", + "T_degC=300.;\n", + "T_01=T_degC+273;#Reaction temperature(K) (Ex4.1.a)\n", + "T_02=298.;#Operating temperature (Ex4.1.b)\n", + "T_03=573.;#operating temperature (Ex4.1.c)\n", + "P_ref=1;#Reference pressure\n", + "D_Cl2_CH4=0.15;#at 1atm 273K\n", + "P=15.;#operating pressure \n", + "#tau=1.25;#From value calculated in Ex4.1.b Pg. No. 136\n", + "from math import sqrt\n", + "\n", + "\n", + "#CALCULATION (Ex4.1.a)\n", + "r_bar=2*V_g/S_g;#Mean Pore radius\n", + "D_Cl2_Ex_a=D_He*((M_He/M_Cl2)*(T_01/T_ref))**(0.5);#Assuming Knudsen flow at 573K\n", + "\n", + "#CALCULATION (Ex4.1.b)\n", + "r_bar=2.*V_g*(10**6)/(S_g *(10**4));\n", + "D_K=9700.*(r_bar)*(T_ref/M_He)**(0.5);#Knudsen flow\n", + "D_AB1=D_AB*(293./298.)**(1.7)# at 1.5 atm and 293K\n", + "D_pore=1./((1./D_K)+(1./D_AB1));#pore diffusion\n", + "Epsilon=V_g*rho_p*(10**6);\n", + "tau=(D_pore*Epsilon)/D_He;#Tortusity\n", + "\n", + "#CALCULATION (Ex4.1.c)\n", + "D_Cl2_CH4_new=D_Cl2_CH4*(P_ref/P)*(T_03/T_ref)**(1.7);\n", + "D_K_Cl2=9700*r_bar*sqrt(T_03/M_Cl2);\n", + "D_pore=1/((1/D_Cl2_CH4_new)+(1/D_K_Cl2));\n", + "Epsilon=V_g*rho_p;\n", + "D_Cl2_Ex_c=D_pore*Epsilon/tau;\n", + "\n", + "\n", + "#OUTPUT\n", + "print '\\n OUTPUT Ex4.1.a'\n", + "print '\\n================================================='\n", + "print '\\nThe predicted diffusivity of Chlorine is cm2/s ',D_Cl2_Ex_a\n", + "print '\\n\\n OUTPUT Ex4.1.b'\n", + "print '\\n================================================='\n", + "print '\\nThe tortusity value = ',tau\n", + "print '\\n\\n OUTPUT Ex4.1.b'\n", + "print '\\n================================================='\n", + "print '\\nThe Effective diffusivity of Chlorine K a atm = cm2/sec ',T_03, P, D_Cl2_Ex_c\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4_2 pgno:140" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " OUTPUT Ex4.2.a\n", + "\n", + "=================================================\n", + "\n", + " The effective diffusivity of O2 in air = cm2/s 0.0235933499021\n", + "\n", + "\n", + " OUTPUT Ex4.2.b\n", + "\n", + "=================================================\n", + "\n", + " The calculated surface mean pore radius = cm 6e-07\n", + "\n", + " The predicted pore diffusivity = cm2/sec 0.0218264089105\n", + "\n", + " The corresponding tortusity = 0.499558598529\n" + ] + } + ], + "source": [ + "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc.,USA,pp 436.\n", + "#Chapter-4 Ex4.2 Pg No. 140\n", + "#Title:Effective diffusivity of O2 in air\n", + "#============================================================================================================\n", + "\n", + "# COMMON INPUT\n", + "S_g=150.;#Total surface per gram (m2/g)\n", + "V_g=0.45;#Pore volume per gram (cm3/g)\n", + "V_i=0.30;#Micropore volume per gram (cm3/g)\n", + "V_a=0.15;# Macropore volume per gram (cm3/g)\n", + "rho_P=1.2;#Density of particle (g/cm3)\n", + "tau=2.5;# Tortusity\n", + "r_bar_i=40*(10**(-8));#Micropore radius\n", + "r_bar_a=2000*(10**(-8));#Macropore radius\n", + "D_AB=0.49;#For N2O2 at 1 atm (cm2/s)\n", + "M_O2=32.;#Molecular weight of O2\n", + "T=493.;#Opereating Temperature (K)\n", + "from math import sqrt\n", + "\n", + "\n", + "\n", + "#CALCULATION (Ex4.2.a)\n", + "Epsilon=V_g*rho_P;\n", + "D_K_i=9700*(r_bar_i)*sqrt(T/M_O2);#Knudsen flow for micropore\n", + "D_Pore_i=1/((1/D_K_i)+(1/D_AB))\n", + "D_K_a=9700*(r_bar_a)*sqrt(T/M_O2);\n", + "D_Pore_a=1/((1/D_K_a)+(1/D_AB));##Knudsen flow for macropore\n", + "D_Pore_Avg=(V_i*D_Pore_i+V_a*D_Pore_a)/(V_i+V_a);\n", + "D_e=Epsilon*D_Pore_Avg/tau;\n", + "\n", + "#CALCULATION (Ex4.2.b)\n", + "Epsilon=V_g*rho_P;\n", + "r_bar=2*V_g/(S_g*10**4);\n", + "D_K=9700*(r_bar)*sqrt(T/M_O2);#Knudsen Flow\n", + "D_Pore=1/((1/D_K)+(1/D_AB));\n", + "tau=D_Pore*Epsilon/D_e;\n", + "\n", + "#OUTPUT\n", + "print '\\n OUTPUT Ex4.2.a'\n", + "print '\\n================================================='\n", + "print '\\n The effective diffusivity of O2 in air = cm2/s',D_e \n", + "print '\\n\\n OUTPUT Ex4.2.b'\n", + "print '\\n================================================='\n", + "print '\\n The calculated surface mean pore radius = cm',r_bar \n", + "print '\\n The predicted pore diffusivity = cm2/sec',D_Pore \n", + "print '\\n The corresponding tortusity = ',tau\n", + "\n", + "\n", + "\n", + "#======================================================END OF PROGRAM========================================\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 4_4 pgno:157" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\tBased on average pressures calculated Rate and Effectiveness factor\n", + "\n", + "\t r : (mol/s cm3) 1.17056498924e-05\n", + "\n", + "\t eta_calc : 0.174804371726\n", + "\n", + " The actual value of Effectiveness factor eta_actual : 0.427402185863\n" + ] + } + ], + "source": [ + "#Harriot P.,2003,Chemical Reactor Design (I-Edition) Marcel Dekker,Inc. USA,pp 436.\n", + "#Chapter-4 Ex4.4 Pg No.157\n", + "#Title: Effectiveness factor for solid catalyzed reaction\n", + "#======================================================================================================================\n", + "\n", + "#INPUT\n", + "D_e_A=0.02;#(cm2/s)\n", + "D_e_B=0.03;#(cm2/s)\n", + "D_e_C=0.015;#(cm2/s)\n", + "X_f_A=0.3;\n", + "X_f_B=(1-X_f_A);\n", + "eta_assumed=0.68;#Effectiveness factor from Fig.4.8 for first order reaction\n", + "T=150.;#(deg C)\n", + "T_K=T+273;#(K)\n", + "r=0.3;#(cm)Radius of catalyst sphere\n", + "P_opt=4.;#(atm)Operating Pressure \n", + "R=82.056;#(cm3 atm/K mol)Gas constant \n", + "\n", + "\n", + "#CALCULATION\n", + "#Kinetic equation r= (2.5*10**-5*P_A*P_B)/(1+0.1*P_A+2*P_C)**2\n", + "P_A=X_f_A*P_opt;\n", + "P_B=X_f_B*P_opt;\n", + "r_star=(2.5*10**-5*P_A*P_B)/(1+0.1*P_A)**2;\n", + "C_A=P_A/(R*T_K);\n", + "k=r_star/C_A;\n", + "Phi= r*(k/D_e_A)**(0.5);\n", + "P_A_bar=eta_assumed*P_A;\n", + "delta_P_A=P_A*(1-eta_assumed);\n", + "delta_P_B=delta_P_A*(D_e_A/D_e_B);\n", + "P_B_bar=P_B-delta_P_B;\n", + "delta_P_C=delta_P_A*(D_e_A/D_e_C);\n", + "P_C_bar=delta_P_C;\n", + "r_calc=(2.5*10**-5*P_A_bar*P_B_bar)/(1+0.1*P_A_bar+2*P_C_bar)**2\n", + "eta_calc=r_calc/r_star;\n", + "eta_approx=(eta_calc+eta_assumed)/2;\n", + "\n", + "#OUTPUT\n", + "#Console Output\n", + "print'\\tBased on average pressures calculated Rate and Effectiveness factor'\n", + "print'\\n\\t r : (mol/s cm3)',r_calc\n", + "print'\\n\\t eta_calc : ',eta_calc\n", + "print'\\n The actual value of Effectiveness factor eta_actual :',eta_approx\n", + "\n", + "#================================================END OF PROGRAM==================================================================================\n", + "\n", + "\n", + "\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/mokshagunda/Chapter_2.ipynb b/sample_notebooks/mokshagunda/Chapter_2.ipynb new file mode 100755 index 00000000..9af6a743 --- /dev/null +++ b/sample_notebooks/mokshagunda/Chapter_2.ipynb @@ -0,0 +1,365 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 DIFFRACTION" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_1 pg.no:29" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "No of lines per centimeter is 5000\n" + ] + } + ], + "source": [ + "#To calculate the no of lines in one cm of grating surface\n", + "from math import pi,sin\n", + "k=2.\n", + "lamda=5*10**-5 #units in cm\n", + "theta=30 # units in degrees\n", + "#We have nooflines=1/e=(k∗lamda)/sin(theta)\n", + "nooflines=sin(theta*pi/180)/(k*lamda) #units in cm\n", + "print \"No of lines per centimeter is %.f\"%nooflines\n", + "#In text book the answer is printed wrong as 10ˆ3\n", + "#The correct answer is 5∗10ˆ3" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_2 pg.no:30" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "For First order spectra theta1=17.5 degrees\n", + "For Third order spectra theta3=64.2 degrees\n", + "Difference in Angles of deviation in first and third order spectra is theta3−theta1=46.70 degrees\n" + ] + } + ], + "source": [ + "#To Find the difference in angles of deviation in first and third order spectra\n", + "from math import pi,asin\n", + "lamda=5000. # units in armstrongs\n", + "lamda=lamda*10**-8 # units in cm\n", + "e=1./6000.\n", + "#For first order e∗sin(theta1)=1∗lamda\n", + "theta1=asin(lamda/e) # units in radians\n", + "theta1=theta1*180./pi # units in degrees\n", + "print \"For First order spectra theta1=%.1f degrees\"%theta1\n", + "#For third order e∗sin(theta3)=3∗lamda\n", + "theta3=asin(3.*lamda/e) # units in radians\n", + "theta3=theta3*180/pi # units in degrees\n", + "print \"For Third order spectra theta3=%.1f degrees\"%theta3\n", + "diffe=theta3-theta1 #units in degrees\n", + "print \"Difference in Angles of deviation in first and third order spectra is theta3−theta1=%.2f degrees\"%diffe" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_3 pg.no:30" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "No of lines per cm=196.0 \n" + ] + } + ], + "source": [ + "#To calculate minimum no of lines per centimeter\n", + "lamda1=5890 # units in armstrongs\n", + "lamda2=5896 # units in armstrongs\n", + "dlamda=lamda2-lamda1 #units in armstrongs\n", + "k=2\n", + "n=lamda1/(k*dlamda)\n", + "width=2.5 #units in cm\n", + "nooflines=n/width\n", + "print \"No of lines per cm=%.1f \"%nooflines" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_4 pg.no:31" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "As total no of lines required for resolution in first order is 981 and total no of lines in grating is 850 the lines will not be resolved in first order\n", + "As total no of lines required for resolution in first order is 490 and total no of lines in grating is 850 the lines will be resolved in second order\n" + ] + } + ], + "source": [ + "#To examine two spectral lines are clearly resolved in first order and second order\n", + "n=425.\n", + "tno=2.*n\n", + "lamda1=5890 # units in armstrongs\n", + "lamda2=5896 # units in armstrongs\n", + "dlamda=lamda2 -lamda1\n", + "#For first order\n", + "n=lamda1/dlamda\n", + "print\"As total no of lines required for resolution in first order is %.f and total no of lines in grating is %d the lines will not be resolved in first order\"%(n,tno)\n", + "#For second order\n", + "n=lamda1/(2*dlamda)\n", + "print\"As total no of lines required for resolution in first order is %.f and total no of lines in grating is %d the lines will be resolved in second order\"%(n,tno)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_5 pg.no:32" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Angle of separation is 16 minutes\n" + ] + } + ], + "source": [ + "#To find the angle of separation\n", + "from math import asin,pi\n", + "\n", + "lamda1=5016. # units in armstrongs\n", + "lamda2=5048. # units in armstrongs\n", + "lamda1=lamda1*10**-8 # units in cm\n", + "lamda2=lamda2*10**-8 # units in cm\n", + "k=2.\n", + "n=15000\n", + "e=2.54/n # units in cm \n", + "theta1=asin((2*lamda1)/e)*(180/pi) # units in in degrees\n", + "theta2=asin((2*lamda2)/e)*(180/pi) # units in in degrees\n", + "diffe=theta2-theta1 # units in in degrees\n", + "diffe=diffe*60 # units in minutes\n", + "print \"Angle of separation is %.f minutes\"%diffe" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_6 pg.no:32" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The dispersive power of the grating is 15000\n" + ] + } + ], + "source": [ + "#To Calculate the dispersive power of the grating\n", + "from math import pi,asin,cos\n", + "n=4000.\n", + "e=1/n #units in cm\n", + "k=3.\n", + "lamda=5000 # units in armstrongs\n", + "lamda=lamda*10**-8 # units in cm\n", + "theta=asin((k*lamda)/e)*(180/pi) # units in degrees\n", + "costheta=cos(theta*pi/180)\n", + "disppower=(k*n)/costheta\n", + "print \"The dispersive power of the grating is %.f\"%disppower" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_7 pg.no:33" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The highest order spectrum Seen with monochromatic light is 3.33\n" + ] + } + ], + "source": [ + "#To Calculate highest power of spectrum seen with mono chromaic light\n", + "lamda=6000. # units in armstrongs\n", + "lamda=lamda*10**-8 #units in cm\n", + "n=5000.\n", + "e=1/n #units in cm\n", + "k=e/lamda\n", + "print \"The highest order spectrum Seen with monochromatic light is %.2f\"%k" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_8 pg.no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Wavelength of the lines is 0.0000606 cms\n", + "Minimum grating width required is 4.2 cm \n" + ] + } + ], + "source": [ + "#To calculate the wavelength\n", + "from math import pi,sin\n", + "k=2.\n", + "theta1=10.\n", + "dtheta=3.\n", + "dlamda=5*10**-9\n", + "lamda=(sin((theta1*pi)/180)*dlamda*60*60)/(cos((theta1*pi)/180)*dtheta*(pi/180)) # units in cm\n", + "print \"Wavelength of the lines is %.7f cms\"%lamda\n", + "lamda_dlamda=lamda+dlamda # units in cm\n", + "N=6063\n", + "Ne=(N*k*lamda)/sin((theta1*pi)/180) # units in cm\n", + "print \"Minimum grating width required is %.1f cm \"%Ne" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_9 pg.no:35" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Resolving power is 10000 \n" + ] + } + ], + "source": [ + "#To calculate resolving power in second order\n", + "#We have e∗sin(theta)=k∗lamda\n", + "#We have e∗0.2=k∗lamda −>1\n", + "#And e∗0.3=(k+1)∗lamda −>2\n", + "#Subtracting one and two 3∗0.1=lamda\n", + "lamda=5000. # units in armstrongs\n", + "lamda=lamda*10**-8 # units in cm\n", + "e=lamda/0.1 # units in cm\n", + "width=2.5 #units in cm\n", + "N=width/e\n", + "respower=2*N\n", + "print \"Resolving power is %.f \"%respower" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.10" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/mokshagunda/Chapter_2_DIFFRACTION.ipynb b/sample_notebooks/mokshagunda/Chapter_2_DIFFRACTION.ipynb deleted file mode 100755 index 9af6a743..00000000 --- a/sample_notebooks/mokshagunda/Chapter_2_DIFFRACTION.ipynb +++ /dev/null @@ -1,365 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 DIFFRACTION" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_1 pg.no:29" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "No of lines per centimeter is 5000\n" - ] - } - ], - "source": [ - "#To calculate the no of lines in one cm of grating surface\n", - "from math import pi,sin\n", - "k=2.\n", - "lamda=5*10**-5 #units in cm\n", - "theta=30 # units in degrees\n", - "#We have nooflines=1/e=(k∗lamda)/sin(theta)\n", - "nooflines=sin(theta*pi/180)/(k*lamda) #units in cm\n", - "print \"No of lines per centimeter is %.f\"%nooflines\n", - "#In text book the answer is printed wrong as 10ˆ3\n", - "#The correct answer is 5∗10ˆ3" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_2 pg.no:30" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "For First order spectra theta1=17.5 degrees\n", - "For Third order spectra theta3=64.2 degrees\n", - "Difference in Angles of deviation in first and third order spectra is theta3−theta1=46.70 degrees\n" - ] - } - ], - "source": [ - "#To Find the difference in angles of deviation in first and third order spectra\n", - "from math import pi,asin\n", - "lamda=5000. # units in armstrongs\n", - "lamda=lamda*10**-8 # units in cm\n", - "e=1./6000.\n", - "#For first order e∗sin(theta1)=1∗lamda\n", - "theta1=asin(lamda/e) # units in radians\n", - "theta1=theta1*180./pi # units in degrees\n", - "print \"For First order spectra theta1=%.1f degrees\"%theta1\n", - "#For third order e∗sin(theta3)=3∗lamda\n", - "theta3=asin(3.*lamda/e) # units in radians\n", - "theta3=theta3*180/pi # units in degrees\n", - "print \"For Third order spectra theta3=%.1f degrees\"%theta3\n", - "diffe=theta3-theta1 #units in degrees\n", - "print \"Difference in Angles of deviation in first and third order spectra is theta3−theta1=%.2f degrees\"%diffe" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_3 pg.no:30" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false, - "scrolled": true - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "No of lines per cm=196.0 \n" - ] - } - ], - "source": [ - "#To calculate minimum no of lines per centimeter\n", - "lamda1=5890 # units in armstrongs\n", - "lamda2=5896 # units in armstrongs\n", - "dlamda=lamda2-lamda1 #units in armstrongs\n", - "k=2\n", - "n=lamda1/(k*dlamda)\n", - "width=2.5 #units in cm\n", - "nooflines=n/width\n", - "print \"No of lines per cm=%.1f \"%nooflines" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_4 pg.no:31" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "As total no of lines required for resolution in first order is 981 and total no of lines in grating is 850 the lines will not be resolved in first order\n", - "As total no of lines required for resolution in first order is 490 and total no of lines in grating is 850 the lines will be resolved in second order\n" - ] - } - ], - "source": [ - "#To examine two spectral lines are clearly resolved in first order and second order\n", - "n=425.\n", - "tno=2.*n\n", - "lamda1=5890 # units in armstrongs\n", - "lamda2=5896 # units in armstrongs\n", - "dlamda=lamda2 -lamda1\n", - "#For first order\n", - "n=lamda1/dlamda\n", - "print\"As total no of lines required for resolution in first order is %.f and total no of lines in grating is %d the lines will not be resolved in first order\"%(n,tno)\n", - "#For second order\n", - "n=lamda1/(2*dlamda)\n", - "print\"As total no of lines required for resolution in first order is %.f and total no of lines in grating is %d the lines will be resolved in second order\"%(n,tno)" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_5 pg.no:32" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Angle of separation is 16 minutes\n" - ] - } - ], - "source": [ - "#To find the angle of separation\n", - "from math import asin,pi\n", - "\n", - "lamda1=5016. # units in armstrongs\n", - "lamda2=5048. # units in armstrongs\n", - "lamda1=lamda1*10**-8 # units in cm\n", - "lamda2=lamda2*10**-8 # units in cm\n", - "k=2.\n", - "n=15000\n", - "e=2.54/n # units in cm \n", - "theta1=asin((2*lamda1)/e)*(180/pi) # units in in degrees\n", - "theta2=asin((2*lamda2)/e)*(180/pi) # units in in degrees\n", - "diffe=theta2-theta1 # units in in degrees\n", - "diffe=diffe*60 # units in minutes\n", - "print \"Angle of separation is %.f minutes\"%diffe" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_6 pg.no:32" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The dispersive power of the grating is 15000\n" - ] - } - ], - "source": [ - "#To Calculate the dispersive power of the grating\n", - "from math import pi,asin,cos\n", - "n=4000.\n", - "e=1/n #units in cm\n", - "k=3.\n", - "lamda=5000 # units in armstrongs\n", - "lamda=lamda*10**-8 # units in cm\n", - "theta=asin((k*lamda)/e)*(180/pi) # units in degrees\n", - "costheta=cos(theta*pi/180)\n", - "disppower=(k*n)/costheta\n", - "print \"The dispersive power of the grating is %.f\"%disppower" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_7 pg.no:33" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The highest order spectrum Seen with monochromatic light is 3.33\n" - ] - } - ], - "source": [ - "#To Calculate highest power of spectrum seen with mono chromaic light\n", - "lamda=6000. # units in armstrongs\n", - "lamda=lamda*10**-8 #units in cm\n", - "n=5000.\n", - "e=1/n #units in cm\n", - "k=e/lamda\n", - "print \"The highest order spectrum Seen with monochromatic light is %.2f\"%k" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_8 pg.no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Wavelength of the lines is 0.0000606 cms\n", - "Minimum grating width required is 4.2 cm \n" - ] - } - ], - "source": [ - "#To calculate the wavelength\n", - "from math import pi,sin\n", - "k=2.\n", - "theta1=10.\n", - "dtheta=3.\n", - "dlamda=5*10**-9\n", - "lamda=(sin((theta1*pi)/180)*dlamda*60*60)/(cos((theta1*pi)/180)*dtheta*(pi/180)) # units in cm\n", - "print \"Wavelength of the lines is %.7f cms\"%lamda\n", - "lamda_dlamda=lamda+dlamda # units in cm\n", - "N=6063\n", - "Ne=(N*k*lamda)/sin((theta1*pi)/180) # units in cm\n", - "print \"Minimum grating width required is %.1f cm \"%Ne" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_9 pg.no:35" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Resolving power is 10000 \n" - ] - } - ], - "source": [ - "#To calculate resolving power in second order\n", - "#We have e∗sin(theta)=k∗lamda\n", - "#We have e∗0.2=k∗lamda −>1\n", - "#And e∗0.3=(k+1)∗lamda −>2\n", - "#Subtracting one and two 3∗0.1=lamda\n", - "lamda=5000. # units in armstrongs\n", - "lamda=lamda*10**-8 # units in cm\n", - "e=lamda/0.1 # units in cm\n", - "width=2.5 #units in cm\n", - "N=width/e\n", - "respower=2*N\n", - "print \"Resolving power is %.f \"%respower" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.10" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/nishumittal/chapter1.ipynb b/sample_notebooks/nishumittal/chapter1.ipynb deleted file mode 100755 index 56991b68..00000000 --- a/sample_notebooks/nishumittal/chapter1.ipynb +++ /dev/null @@ -1,165 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:b803a1650997e1a91a43f6f6211bc977cbde8d0a8e079033f5645dae7b99d4ba" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 1 Introduction " - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.1 Page no 9" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "Rs=50 #ohm\n", - "\n", - "#Calculation\n", - "Rl=100*Rs\n", - "\n", - "#Result\n", - "print\"Load resistance is\",Rl*10**-3,\"ohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Load resistance is 5.0 ohm\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.2 Page no 12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "Rs=10*10**3 #Kohm\n", - "\n", - "#Calculation\n", - "Rl=0.01*Rs\n", - "\n", - "#Result\n", - "print\"Value of load resistance is\",Rl,\"Kohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Value of load resistance is 100.0 Kohm\n" - ] - } - ], - "prompt_number": 7 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.4 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "R1=3 #ohm\n", - "R2=6\n", - "R3=4\n", - "\n", - "#Calculation\n", - "Vth=24\n", - "Rth=R3+((R1*R2)/(R1+R2))\n", - "\n", - "#Result\n", - "print\"Thevenin Voltage is\",Vth,\"V\"\n", - "print\"Thevenin resistance is\",Rth,\"Kohm\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Thevenin Voltage is 24 V\n", - "Thevenin resistance is 6 Kohm\n" - ] - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 1.6 Page no 19" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "V=10 #V\n", - "R=2.0 #Kohm\n", - "\n", - "#Calculation\n", - "I=V/R\n", - "\n", - "#Result\n", - "print\"Nortan current is\", I,\"mA\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Nortan current is 5.0 mA\n" - ] - } - ], - "prompt_number": 16 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/nishumittal/chapter2.ipynb b/sample_notebooks/nishumittal/chapter2.ipynb deleted file mode 100755 index 3d83df64..00000000 --- a/sample_notebooks/nishumittal/chapter2.ipynb +++ /dev/null @@ -1,710 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:46bc70330d4213802afb03e252b2ad32eb9319ed4cc2a32fe2c16df97a5f1978" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2 Particle nature of Radiation; The origin of Quantum theory" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.2 Page no-12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "E=40 #W\n", - "lembda=6000*10**-10 #m\n", - "h=6.63*10**-34 #Js\n", - "c=3*10**8 #m/s\n", - "\n", - "#Calculation\n", - "n=(E*lembda)/(h*c)\n", - "\n", - "#Result\n", - "print\"No. of photons emitted per second are given by \",round(n*10**-19,2),\"*10**19\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No. of photons emitted per second are given by 12.07 *10**19\n" - ] - } - ], - "prompt_number": 27 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.3 Page no-12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "a=3.2 #ev\n", - "energy=3.8 #ev\n", - "e=1.6*10**-19\n", - "\n", - "#Calculation\n", - "c=energy-a\n", - "Energy=c*e\n", - "\n", - "#Result\n", - "print\"Kinetic energy of the photoelectron is given by \",Energy,\"Joule\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Kinetic energy of the photoelectron is given by 9.6e-20 Joule\n" - ] - } - ], - "prompt_number": 31 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.4 Page no-12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "W=3.45 #ev\n", - "h=6.63*10**-34 #Js\n", - "c=3*10**8 #m/s\n", - "e=1.6*10**-19\n", - "\n", - "#Calculation\n", - "lembda=(h*c)/(W*e)\n", - "\n", - "#Result\n", - "print\"Maximum wavelength of photon is \",round(lembda*10**10,0),\"A\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum wavelength of photon is 3603.0 A\n" - ] - } - ], - "prompt_number": 193 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.5 Page no-12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "W=3 #ev\n", - "h=6.63*10**-34\n", - "e=1.6*10**-19\n", - "lembda=3.0*10**-7 #m\n", - "c=3*10**8 #m/s\n", - "\n", - "#Calculation\n", - "v0=(W*e)/h\n", - "v=c/lembda\n", - "E=h*(v-v0)\n", - "E1=(h*(v-v0))/(1.6*10**-19)\n", - "V0=E/e\n", - "\n", - "#Result\n", - "print\"(a) Threshold frequency \",round(v0*10**-15,2),\"*10**15 HZ\"\n", - "print\"(b) Maximum energy of photoelectron \",round(E1,2),\"eV\"\n", - "print\"(c) Stopping potential \",round(V0,2),\"V\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Threshold frequency 0.72 *10**15 HZ\n", - "(b) Maximum energy of photoelectron 1.14 eV\n", - "(c) Stopping potential 1.14 V\n" - ] - } - ], - "prompt_number": 197 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.6 Page no-13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "v0=6*10**14 #s**-1\n", - "h=6.63*10**-34\n", - "e=1.6*10**-19\n", - "V0=3\n", - "\n", - "#Calculaton\n", - "W=h*v0\n", - "W0=(h*v0)/e\n", - "V=(e*V0+h*v0)/h\n", - "\n", - "#Result \n", - "print\"work function is given by \",round(W0,3),\"ev\"\n", - "print\"frequency is given by \",round(V*10**-15,2),\"*10**15 s-1\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "work function is given by 2.486 ev\n", - "frequency is given by 1.32 *10**15 s-1\n" - ] - } - ], - "prompt_number": 88 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.7 Page no 13" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "lembda=6800.0*10**-10 #m\n", - "h=6.6*10**-34\n", - "W=2.3 #ev\n", - "c=3*10**8 #m/s\n", - "\n", - "#Calculation\n", - "E=((h*c)/lembda)/1.6*10**-19\n", - "\n", - "#Result\n", - "print\"Energy is \",round(E*10**38,2),\"ev\"\n", - "print\"since the energy of incident photon is less then the work function of Na, photoelecrticemession is not possible with the given light.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Energy is 1.82 ev\n", - "since the energy of incident photon is less then the work function of Na, photoelecrticemession is not possible with the given light.\n" - ] - } - ], - "prompt_number": 200 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.8 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "lembda=3500*10**-10 #m\n", - "h=6.6*10**-34\n", - "c=3*10**8 #m/s\n", - "\n", - "#calculation \n", - "E=((h*c)/lembda)/1.6*10**-19\n", - "\n", - "#Result\n", - "print\"Energy is \" ,round(E*10**38,2),\"ev\"\n", - "print\"1.9 ev < E < 4.2 ev,only metal B will yield photoelectrons\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Energy is 3.54 ev\n", - "1.9 ev < E < 4.2 ev,only metal B will yield photoelectrons\n" - ] - } - ], - "prompt_number": 201 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.9 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "lembda=6.2*10**-6\n", - "W=0.1 #ev\n", - "h=6.6*10**-34 #Js\n", - "c=3*10**8 #m/s\n", - "e=1.6*10**-19\n", - "\n", - "#Calculation\n", - "E=((h*c)/(lembda*e))-W\n", - "\n", - "#Result\n", - "print\"Maximum kinetic energy of photoelectron \",round(E,1),\"ev\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Maximum kinetic energy of photoelectron 0.1 ev\n" - ] - } - ], - "prompt_number": 112 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.10 Page no 14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "e=1.60*10**-19 #C\n", - "slope=4.12*10**-15 #Vs\n", - "\n", - "#Calculation\n", - "h=slope*e\n", - "\n", - "#Result\n", - "print\"Value of plank's constant \",h,\"Js\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Value of plank's constant 6.592e-34 Js\n" - ] - } - ], - "prompt_number": 114 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.11 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "W=2.26*1.6*10**-19 #ev\n", - "v=10**6 #m/s\n", - "m=9*10**-31\n", - "\n", - "#Calculation\n", - "V=((1/2.0)*m*v**2+W)/h\n", - "\n", - "#Result\n", - "print\"frequency of incident radiation \",round(V*10**-15,2),\"*10**15 HZ\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "frequency of incident radiation 1.23 *10**15 HZ\n" - ] - } - ], - "prompt_number": 118 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.12 Page no 15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "V1=.82 #volts\n", - "V2=1.85 #volts\n", - "lembda1=4.0*10**-7 #m\n", - "lembda2=3.0*10**-7\n", - "e=1.6*10**-19\n", - "c=3.0*10**8 #m/s\n", - "\n", - "#Calculation\n", - "lembda=(1/lembda2)-(1/lembda1)\n", - "h=(e*(V2-V1))/(c*lembda)\n", - "\n", - "#Result\n", - "print\"(a) plank's constant \",h,\"Js\"\n", - "print\"(b) no, because the stopping potentialdepends only on the wavelength of light and not on its intensity.\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) plank's constant 6.592e-34 Js\n", - "(b) no, because the stopping potentialdepends only on the wavelength of light and not on its intensity.\n" - ] - } - ], - "prompt_number": 202 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.13 Page no 16" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "h=6.62*10**-34 #Js\n", - "c=3*10**8 #m/s\n", - "lembda=4560.0*10**-10 #m\n", - "p=1*10**-3 #W\n", - "a=0.5/100\n", - "e=1.6*10**-19\n", - "\n", - "#calculation\n", - "E=(h*c)/lembda\n", - "N=p/E #Number of photons incedent on the surface\n", - "n=N*a\n", - "I=n*e\n", - "\n", - "#result\n", - "print\"Photoelectric current \",round(I*10**6,2),\"*10**-6 A\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Photoelectric current 1.84 *10**-6 A\n" - ] - } - ], - "prompt_number": 131 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.14 Page no 22" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#given\n", - "m0=9.1*10**-31 #Kg\n", - "c=3*10**8 #m/s\n", - "h=6.6*10**-34 #Js\n", - "v1=2.0*10**-10 #m\n", - "\n", - "#Calculation\n", - "import math\n", - "v= (h/(m0*c))*(1-(math.cos(90))*3.14/180.0)\n", - "v2=v+v1\n", - "v0=v2-v1\n", - "E=(h*c*(v0))/(v1*v2)\n", - "b=(1/(math.sin(90)*3.14/180.0))*((v2*10**-10/v1)-math.cos(90)*3.14/180.0)\n", - "angle=3.14/2.0-math.atan(b)\n", - "\n", - "#Result\n", - "print \"(a) the wavelength of scattered photon is \",round(v2*10**10,3),\"A\"\n", - "print\"(b) The energy of recoil electron is \",round(E*10**17,2),\"*10**-17 J\"\n", - "print\"(c) angle at which the recoil electron appears \",round(angle,2),\"degree\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) the wavelength of scattered photon is 2.024 A\n", - "(b) The energy of recoil electron is 1.19 *10**-17 J\n", - "(c) angle at which the recoil electron appears 1.11 degree\n" - ] - } - ], - "prompt_number": 278 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.15 Page no 23" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given \n", - "E=0.9 #Mev\n", - "a=120 #degree\n", - "m=9.1*10**-31 #Kg\n", - "c=3*10**8 #m/s\n", - "\n", - "#calculation\n", - "b=((m*c**2)/1.6*10**-19)*10**32\n", - "energy=E/(1+2*(E/b)*(3/4.0))\n", - "\n", - "#Result\n", - "print \"energy of scattered photon \",round(energy,3),\"Mev\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "energy of scattered photon 0.247 Mev\n" - ] - } - ], - "prompt_number": 142 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.16 Page no 24" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "v1=2.000*10**-10 #m\n", - "v2=2.048*10**-10 #m\n", - "a=180 #degree\n", - "a1=60 #degree\n", - "h=6.6*10**-34\n", - "c=3*10**8\n", - "\n", - "#Calculation\n", - "import math\n", - "b=(v2-v1)/(1-math.cos(a*3.14/180.0))\n", - "V=v1+b*(1-math.cos(60*3.14/180.0))\n", - "E=(h*c*(V-v1))/(V*v1)\n", - "\n", - "#Result\n", - "print\"(a) wavelength of radiation scattered at an angle of 60 degree \",round(V*10**10,3),\"A\"\n", - "print \"(b) Energy of the recoiul electron is \",round(E*10**18,2),\"*10**-18 J\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) wavelength of radiation scattered at an angle of 60 degree 2.012 A\n", - "(b) Energy of the recoiul electron is 5.9 *10**-18 J\n" - ] - } - ], - "prompt_number": 277 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.17 Page no 24" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "E=4*10**3*1.6*10**-19\n", - "m0=9.1*10**-31\n", - "b=6.4*10**-16\n", - "d=102.39*10**-16\n", - "h=6.3*10**-34\n", - "c=3*10**8\n", - "\n", - "#Calculation\n", - "import math\n", - "p=math.sqrt(2*m0*E)\n", - "d=b+d\n", - "lembda=(2*h*c)/d\n", - "\n", - "#Result\n", - "print\"Wavelength of incident photon is \", round(lembda*10**10,2),\"A\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Wavelength of incident photon is 0.35 A\n" - ] - } - ], - "prompt_number": 233 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example 2.19 Page no 26" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#Given\n", - "E=1.02 #Mev\n", - "b=0.51\n", - "\n", - "#Calculation\n", - "import math\n", - "alpha=E/b\n", - "a=1/(math.sqrt(2*(alpha+2)))\n", - "angle=2*(math.asin(a)*180/3.14)\n", - "e=E/(1.0+alpha*(1-(math.cos(angle*3.14/180.0))))\n", - "\n", - "#Result\n", - "print\"(a) Angle for symmetric scattering is \", round(angle,1),\"degree\"\n", - "print \"(b) energy of the scattered photon is \",round(e,2),\"Mev\"" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "(a) Angle for symmetric scattering is 41.4 degree\n", - "(b) energy of the scattered photon is 0.68 Mev\n" - ] - } - ], - "prompt_number": 263 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/nishumittal/nishumittal_version_backup/chapter1.ipynb b/sample_notebooks/nishumittal/nishumittal_version_backup/chapter1.ipynb new file mode 100755 index 00000000..56991b68 --- /dev/null +++ b/sample_notebooks/nishumittal/nishumittal_version_backup/chapter1.ipynb @@ -0,0 +1,165 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:b803a1650997e1a91a43f6f6211bc977cbde8d0a8e079033f5645dae7b99d4ba" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 1 Introduction " + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.1 Page no 9" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "Rs=50 #ohm\n", + "\n", + "#Calculation\n", + "Rl=100*Rs\n", + "\n", + "#Result\n", + "print\"Load resistance is\",Rl*10**-3,\"ohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Load resistance is 5.0 ohm\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.2 Page no 12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "Rs=10*10**3 #Kohm\n", + "\n", + "#Calculation\n", + "Rl=0.01*Rs\n", + "\n", + "#Result\n", + "print\"Value of load resistance is\",Rl,\"Kohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of load resistance is 100.0 Kohm\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.4 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "R1=3 #ohm\n", + "R2=6\n", + "R3=4\n", + "\n", + "#Calculation\n", + "Vth=24\n", + "Rth=R3+((R1*R2)/(R1+R2))\n", + "\n", + "#Result\n", + "print\"Thevenin Voltage is\",Vth,\"V\"\n", + "print\"Thevenin resistance is\",Rth,\"Kohm\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Thevenin Voltage is 24 V\n", + "Thevenin resistance is 6 Kohm\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 1.6 Page no 19" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "V=10 #V\n", + "R=2.0 #Kohm\n", + "\n", + "#Calculation\n", + "I=V/R\n", + "\n", + "#Result\n", + "print\"Nortan current is\", I,\"mA\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Nortan current is 5.0 mA\n" + ] + } + ], + "prompt_number": 16 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/nishumittal/nishumittal_version_backup/chapter2.ipynb b/sample_notebooks/nishumittal/nishumittal_version_backup/chapter2.ipynb new file mode 100755 index 00000000..3d83df64 --- /dev/null +++ b/sample_notebooks/nishumittal/nishumittal_version_backup/chapter2.ipynb @@ -0,0 +1,710 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:46bc70330d4213802afb03e252b2ad32eb9319ed4cc2a32fe2c16df97a5f1978" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2 Particle nature of Radiation; The origin of Quantum theory" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.2 Page no-12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "E=40 #W\n", + "lembda=6000*10**-10 #m\n", + "h=6.63*10**-34 #Js\n", + "c=3*10**8 #m/s\n", + "\n", + "#Calculation\n", + "n=(E*lembda)/(h*c)\n", + "\n", + "#Result\n", + "print\"No. of photons emitted per second are given by \",round(n*10**-19,2),\"*10**19\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No. of photons emitted per second are given by 12.07 *10**19\n" + ] + } + ], + "prompt_number": 27 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.3 Page no-12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "a=3.2 #ev\n", + "energy=3.8 #ev\n", + "e=1.6*10**-19\n", + "\n", + "#Calculation\n", + "c=energy-a\n", + "Energy=c*e\n", + "\n", + "#Result\n", + "print\"Kinetic energy of the photoelectron is given by \",Energy,\"Joule\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Kinetic energy of the photoelectron is given by 9.6e-20 Joule\n" + ] + } + ], + "prompt_number": 31 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.4 Page no-12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "W=3.45 #ev\n", + "h=6.63*10**-34 #Js\n", + "c=3*10**8 #m/s\n", + "e=1.6*10**-19\n", + "\n", + "#Calculation\n", + "lembda=(h*c)/(W*e)\n", + "\n", + "#Result\n", + "print\"Maximum wavelength of photon is \",round(lembda*10**10,0),\"A\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum wavelength of photon is 3603.0 A\n" + ] + } + ], + "prompt_number": 193 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.5 Page no-12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "W=3 #ev\n", + "h=6.63*10**-34\n", + "e=1.6*10**-19\n", + "lembda=3.0*10**-7 #m\n", + "c=3*10**8 #m/s\n", + "\n", + "#Calculation\n", + "v0=(W*e)/h\n", + "v=c/lembda\n", + "E=h*(v-v0)\n", + "E1=(h*(v-v0))/(1.6*10**-19)\n", + "V0=E/e\n", + "\n", + "#Result\n", + "print\"(a) Threshold frequency \",round(v0*10**-15,2),\"*10**15 HZ\"\n", + "print\"(b) Maximum energy of photoelectron \",round(E1,2),\"eV\"\n", + "print\"(c) Stopping potential \",round(V0,2),\"V\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Threshold frequency 0.72 *10**15 HZ\n", + "(b) Maximum energy of photoelectron 1.14 eV\n", + "(c) Stopping potential 1.14 V\n" + ] + } + ], + "prompt_number": 197 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.6 Page no-13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "v0=6*10**14 #s**-1\n", + "h=6.63*10**-34\n", + "e=1.6*10**-19\n", + "V0=3\n", + "\n", + "#Calculaton\n", + "W=h*v0\n", + "W0=(h*v0)/e\n", + "V=(e*V0+h*v0)/h\n", + "\n", + "#Result \n", + "print\"work function is given by \",round(W0,3),\"ev\"\n", + "print\"frequency is given by \",round(V*10**-15,2),\"*10**15 s-1\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "work function is given by 2.486 ev\n", + "frequency is given by 1.32 *10**15 s-1\n" + ] + } + ], + "prompt_number": 88 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.7 Page no 13" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "lembda=6800.0*10**-10 #m\n", + "h=6.6*10**-34\n", + "W=2.3 #ev\n", + "c=3*10**8 #m/s\n", + "\n", + "#Calculation\n", + "E=((h*c)/lembda)/1.6*10**-19\n", + "\n", + "#Result\n", + "print\"Energy is \",round(E*10**38,2),\"ev\"\n", + "print\"since the energy of incident photon is less then the work function of Na, photoelecrticemession is not possible with the given light.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Energy is 1.82 ev\n", + "since the energy of incident photon is less then the work function of Na, photoelecrticemession is not possible with the given light.\n" + ] + } + ], + "prompt_number": 200 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.8 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "lembda=3500*10**-10 #m\n", + "h=6.6*10**-34\n", + "c=3*10**8 #m/s\n", + "\n", + "#calculation \n", + "E=((h*c)/lembda)/1.6*10**-19\n", + "\n", + "#Result\n", + "print\"Energy is \" ,round(E*10**38,2),\"ev\"\n", + "print\"1.9 ev < E < 4.2 ev,only metal B will yield photoelectrons\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Energy is 3.54 ev\n", + "1.9 ev < E < 4.2 ev,only metal B will yield photoelectrons\n" + ] + } + ], + "prompt_number": 201 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.9 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "lembda=6.2*10**-6\n", + "W=0.1 #ev\n", + "h=6.6*10**-34 #Js\n", + "c=3*10**8 #m/s\n", + "e=1.6*10**-19\n", + "\n", + "#Calculation\n", + "E=((h*c)/(lembda*e))-W\n", + "\n", + "#Result\n", + "print\"Maximum kinetic energy of photoelectron \",round(E,1),\"ev\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Maximum kinetic energy of photoelectron 0.1 ev\n" + ] + } + ], + "prompt_number": 112 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.10 Page no 14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "e=1.60*10**-19 #C\n", + "slope=4.12*10**-15 #Vs\n", + "\n", + "#Calculation\n", + "h=slope*e\n", + "\n", + "#Result\n", + "print\"Value of plank's constant \",h,\"Js\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Value of plank's constant 6.592e-34 Js\n" + ] + } + ], + "prompt_number": 114 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.11 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "W=2.26*1.6*10**-19 #ev\n", + "v=10**6 #m/s\n", + "m=9*10**-31\n", + "\n", + "#Calculation\n", + "V=((1/2.0)*m*v**2+W)/h\n", + "\n", + "#Result\n", + "print\"frequency of incident radiation \",round(V*10**-15,2),\"*10**15 HZ\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "frequency of incident radiation 1.23 *10**15 HZ\n" + ] + } + ], + "prompt_number": 118 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.12 Page no 15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "V1=.82 #volts\n", + "V2=1.85 #volts\n", + "lembda1=4.0*10**-7 #m\n", + "lembda2=3.0*10**-7\n", + "e=1.6*10**-19\n", + "c=3.0*10**8 #m/s\n", + "\n", + "#Calculation\n", + "lembda=(1/lembda2)-(1/lembda1)\n", + "h=(e*(V2-V1))/(c*lembda)\n", + "\n", + "#Result\n", + "print\"(a) plank's constant \",h,\"Js\"\n", + "print\"(b) no, because the stopping potentialdepends only on the wavelength of light and not on its intensity.\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) plank's constant 6.592e-34 Js\n", + "(b) no, because the stopping potentialdepends only on the wavelength of light and not on its intensity.\n" + ] + } + ], + "prompt_number": 202 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.13 Page no 16" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "h=6.62*10**-34 #Js\n", + "c=3*10**8 #m/s\n", + "lembda=4560.0*10**-10 #m\n", + "p=1*10**-3 #W\n", + "a=0.5/100\n", + "e=1.6*10**-19\n", + "\n", + "#calculation\n", + "E=(h*c)/lembda\n", + "N=p/E #Number of photons incedent on the surface\n", + "n=N*a\n", + "I=n*e\n", + "\n", + "#result\n", + "print\"Photoelectric current \",round(I*10**6,2),\"*10**-6 A\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Photoelectric current 1.84 *10**-6 A\n" + ] + } + ], + "prompt_number": 131 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.14 Page no 22" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#given\n", + "m0=9.1*10**-31 #Kg\n", + "c=3*10**8 #m/s\n", + "h=6.6*10**-34 #Js\n", + "v1=2.0*10**-10 #m\n", + "\n", + "#Calculation\n", + "import math\n", + "v= (h/(m0*c))*(1-(math.cos(90))*3.14/180.0)\n", + "v2=v+v1\n", + "v0=v2-v1\n", + "E=(h*c*(v0))/(v1*v2)\n", + "b=(1/(math.sin(90)*3.14/180.0))*((v2*10**-10/v1)-math.cos(90)*3.14/180.0)\n", + "angle=3.14/2.0-math.atan(b)\n", + "\n", + "#Result\n", + "print \"(a) the wavelength of scattered photon is \",round(v2*10**10,3),\"A\"\n", + "print\"(b) The energy of recoil electron is \",round(E*10**17,2),\"*10**-17 J\"\n", + "print\"(c) angle at which the recoil electron appears \",round(angle,2),\"degree\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) the wavelength of scattered photon is 2.024 A\n", + "(b) The energy of recoil electron is 1.19 *10**-17 J\n", + "(c) angle at which the recoil electron appears 1.11 degree\n" + ] + } + ], + "prompt_number": 278 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.15 Page no 23" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given \n", + "E=0.9 #Mev\n", + "a=120 #degree\n", + "m=9.1*10**-31 #Kg\n", + "c=3*10**8 #m/s\n", + "\n", + "#calculation\n", + "b=((m*c**2)/1.6*10**-19)*10**32\n", + "energy=E/(1+2*(E/b)*(3/4.0))\n", + "\n", + "#Result\n", + "print \"energy of scattered photon \",round(energy,3),\"Mev\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "energy of scattered photon 0.247 Mev\n" + ] + } + ], + "prompt_number": 142 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.16 Page no 24" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "v1=2.000*10**-10 #m\n", + "v2=2.048*10**-10 #m\n", + "a=180 #degree\n", + "a1=60 #degree\n", + "h=6.6*10**-34\n", + "c=3*10**8\n", + "\n", + "#Calculation\n", + "import math\n", + "b=(v2-v1)/(1-math.cos(a*3.14/180.0))\n", + "V=v1+b*(1-math.cos(60*3.14/180.0))\n", + "E=(h*c*(V-v1))/(V*v1)\n", + "\n", + "#Result\n", + "print\"(a) wavelength of radiation scattered at an angle of 60 degree \",round(V*10**10,3),\"A\"\n", + "print \"(b) Energy of the recoiul electron is \",round(E*10**18,2),\"*10**-18 J\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) wavelength of radiation scattered at an angle of 60 degree 2.012 A\n", + "(b) Energy of the recoiul electron is 5.9 *10**-18 J\n" + ] + } + ], + "prompt_number": 277 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.17 Page no 24" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "E=4*10**3*1.6*10**-19\n", + "m0=9.1*10**-31\n", + "b=6.4*10**-16\n", + "d=102.39*10**-16\n", + "h=6.3*10**-34\n", + "c=3*10**8\n", + "\n", + "#Calculation\n", + "import math\n", + "p=math.sqrt(2*m0*E)\n", + "d=b+d\n", + "lembda=(2*h*c)/d\n", + "\n", + "#Result\n", + "print\"Wavelength of incident photon is \", round(lembda*10**10,2),\"A\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Wavelength of incident photon is 0.35 A\n" + ] + } + ], + "prompt_number": 233 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 2.19 Page no 26" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#Given\n", + "E=1.02 #Mev\n", + "b=0.51\n", + "\n", + "#Calculation\n", + "import math\n", + "alpha=E/b\n", + "a=1/(math.sqrt(2*(alpha+2)))\n", + "angle=2*(math.asin(a)*180/3.14)\n", + "e=E/(1.0+alpha*(1-(math.cos(angle*3.14/180.0))))\n", + "\n", + "#Result\n", + "print\"(a) Angle for symmetric scattering is \", round(angle,1),\"degree\"\n", + "print \"(b) energy of the scattered photon is \",round(e,2),\"Mev\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "(a) Angle for symmetric scattering is 41.4 degree\n", + "(b) energy of the scattered photon is 0.68 Mev\n" + ] + } + ], + "prompt_number": 263 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/pramodkumardesu/Chapter_2_Transmission.ipynb b/sample_notebooks/pramodkumardesu/Chapter_2_Transmission.ipynb new file mode 100755 index 00000000..b232b9ae --- /dev/null +++ b/sample_notebooks/pramodkumardesu/Chapter_2_Transmission.ipynb @@ -0,0 +1,263 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 2 Transmission Lines" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_1 pgno:65" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Maximum field = V/m per volt 42064315640.1\n" + ] + } + ], + "source": [ + "#Chapter 2, Example 1, page 65\n", + "#Calculate the maximum field at the sphere surface\n", + "\n", + "#Calulating Field at surface E based on figure 2.31 and table 2.3\n", + "from math import pi\n", + "Q1 = 0.25\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "RV1= ((1/0.25**2)+(0.067/(0.25-0.067)**2)+(0.0048/(0.25-0.067)**2))\n", + "RV2= ((0.25+0.01795+0.00128)/(0.75-0.067)**2)\n", + "RV= RV1+RV2\n", + "E = (Q1*RV)/(4*pi*e0)\n", + "print\"Maximum field = V/m per volt\",E\n", + "\n", + "#Answers vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_2 pgno:66" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Part a\t\n", + "Equivalent radius = m \t0.0887411967465\n", + "Charge per bundle = uC/m \t4.88704086264e-06\n", + "Charge per sunconducter = uC/m \t2.44352043132e-06\n", + "\tPart b\n", + "\tSub part 1\t\n", + "Maximum feild = kV/m \t2607466.95017\n", + "Maximum feild = kV/m \t2412255.52075\n", + "Maximum feild = kV/m \t2509861.23546\n", + "\tSub part 2\t\n", + "EO1 = kV/m \t2597956.83558\n", + "EO2 = kV/m \t2597429.47744\n", + "EI1 = kV/m \t2402709.21273\n", + "EI2 = kV/m \t2402258.0563\n", + "\tPart c\t\n", + "The average of the maximum gradient = kV/m \t2597693.15651\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 2, page 66\n", + "\n", + "\n", + "#calculation based on figure 2.32\n", + "from math import sqrt,pi,log\n", + "\n", + "#(a)Charge on each bundle\n", + "print\"Part a\\t\"\n", + "req = sqrt(0.0175*0.45)\n", + "print\"Equivalent radius = m \\t\", req\n", + "V = 400*10**3 #Voltage\n", + "H = 12. #bundle height in m\n", + "d = 9. #pole to pole spacing in m\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "Hd = sqrt((2*H)**2+d**2)#2*H**2 + d**2\n", + "Q = V*2*pi*e0/(log((2*H/req))-log((Hd/d)))\n", + "q = Q/2\n", + "print\"Charge per bundle = uC/m \\t\",Q #micro C/m\n", + "print\"Charge per sunconducter = uC/m \\t\",q #micro C/m\n", + "\n", + "#(b part i)Maximim & average surface feild\n", + "print\"\\tPart b\"\n", + "print\"\\tSub part 1\\t\"\n", + "r = 0.0175 #subconductor radius\n", + "R = 0.45 #conductor to subconductor spacing\n", + "MF = (q/(2*pi*e0))*((1/r)+(1/R)) # maximum feild\n", + "print\"Maximum feild = kV/m \\t\",MF\n", + "MSF = (q/(2*pi*e0))*((1/r)-(1/R)) # maximum surface feild\n", + "print\"Maximum feild = kV/m \\t\",MSF\n", + "ASF = (q/(2*pi*e0))*(1/r) # Average surface feild\n", + "print\"Maximum feild = kV/m \\t\",ASF\n", + "\n", + "#(b part ii) Considering the two sunconductors on the left\n", + "print\"\\tSub part 2\\t\"\n", + "#field at the outer point of subconductor #1 \n", + "drO1 = 1/(d+r)\n", + "dRrO1 = 1/(d+R+r)\n", + "EO1 = MF -((q/(2*pi*e0))*(drO1+dRrO1))\n", + "print\"EO1 = kV/m \\t\",EO1\n", + "#field at the outer point of subconductor #2 \n", + "drO2 = 1/(d-r)\n", + "dRrO2 = 1/(d-R-r)\n", + "EO2 = MF -((q/(2*pi*e0))*(dRrO2+drO2))\n", + "print\"EO2 = kV/m \\t\",EO2\n", + "\n", + "#field at the inner point of subconductor #1 \n", + "drI1 = 1/(d-r)\n", + "dRrI1 = 1/(d+R-r)\n", + "EI1 = MSF -((q/(2*pi*e0))*(drI1+dRrI1))\n", + "print\"EI1 = kV/m \\t\",EI1\n", + "#field at the inner point of subconductor #2 \n", + "drI2 = 1/(d+r)\n", + "dRrI2 = 1/(d-R+r)\n", + "EI2 = MSF -((q/(2*pi*e0))*(dRrI2+drI2)) \n", + "print\"EI2 = kV/m \\t\",EI2\n", + "\n", + "#(part c)Average of the maximim gradient\n", + "print\"\\tPart c\\t\"\n", + "Eavg = (EO1+EO2)/2\n", + "print\"The average of the maximum gradient = kV/m \\t\",Eavg\n", + "\n", + "#Answers might vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_3 pgno:69" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Electric Feild = V/m \t35950238891.0\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 3, page 69\n", + "#Electric feild induced at x\n", + "from math import pi\n", + "e0 = 8.85418*10**-12 #Epselon nought\n", + "q = 1 # C/m\n", + "C = (q/(2*pi*e0))\n", + "#Based on figure 2.33\n", + "E = C-(C*(1/3+1/7))+(C*(1+1/5+1/9))+(C*(1/5+1/9))-(C*(1/3+1/7))\n", + "print\"Electric Feild = V/m \\t\",E\n", + "\n", + "#Answers might vary due to round off error\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 2_4 pgno:70" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\tThickness of graded design= cm \t4.24264068712\n", + "Curve = cm**2 \t62.4264068712\n", + "V1 = cm**3 \t47402.906725\n", + "Thickness of regular design = cm \t14.684289433\n", + "V2 = cm**3 \t861.944682812\n" + ] + } + ], + "source": [ + "#Chapter 2, Exmaple 4, page 70\n", + "#Calculate the volume of the insulator\n", + "from math import sqrt,pi,e\n", + "#Thinkness of graded design\n", + "V = 150*sqrt(2)\n", + "Ebd = 50\n", + "T = V/Ebd\n", + "print\"\\tThickness of graded design= cm \\t\",T\n", + "#Based on figure 2.24\n", + "r = 2 # radius of the conductor\n", + "l = 10 #length of graded cylinder; The textbook uses 10 instead of 20\n", + "zr = l*(T+r)\n", + "print\"Curve = cm**2 \\t\",zr\n", + "#Volume of graded design V1\n", + "V1 = 4*pi*zr*(zr-r)\n", + "print\"V1 = cm**3 \\t\",V1 #Unit is wrong in the textbook\n", + "#Thickness of regular design as obtained form Eq.2.77\n", + "pow = V/(2*Ebd)\n", + "t = 2*(e**pow-1)\n", + "print\"Thickness of regular design = cm \\t\",t\n", + "#Volume of regular design V2\n", + "V2 = pi*((2+t)**2-4)\n", + "print\"V2 = cm**3 \\t\",V2#unit not mentioned in textbook\n", + " \n", + "#Answers may vary due to round off error\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/pramodkumardesu/Chapter_2_Transmission_Lines.ipynb b/sample_notebooks/pramodkumardesu/Chapter_2_Transmission_Lines.ipynb deleted file mode 100755 index b232b9ae..00000000 --- a/sample_notebooks/pramodkumardesu/Chapter_2_Transmission_Lines.ipynb +++ /dev/null @@ -1,263 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 2 Transmission Lines" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_1 pgno:65" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Maximum field = V/m per volt 42064315640.1\n" - ] - } - ], - "source": [ - "#Chapter 2, Example 1, page 65\n", - "#Calculate the maximum field at the sphere surface\n", - "\n", - "#Calulating Field at surface E based on figure 2.31 and table 2.3\n", - "from math import pi\n", - "Q1 = 0.25\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "RV1= ((1/0.25**2)+(0.067/(0.25-0.067)**2)+(0.0048/(0.25-0.067)**2))\n", - "RV2= ((0.25+0.01795+0.00128)/(0.75-0.067)**2)\n", - "RV= RV1+RV2\n", - "E = (Q1*RV)/(4*pi*e0)\n", - "print\"Maximum field = V/m per volt\",E\n", - "\n", - "#Answers vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_2 pgno:66" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Part a\t\n", - "Equivalent radius = m \t0.0887411967465\n", - "Charge per bundle = uC/m \t4.88704086264e-06\n", - "Charge per sunconducter = uC/m \t2.44352043132e-06\n", - "\tPart b\n", - "\tSub part 1\t\n", - "Maximum feild = kV/m \t2607466.95017\n", - "Maximum feild = kV/m \t2412255.52075\n", - "Maximum feild = kV/m \t2509861.23546\n", - "\tSub part 2\t\n", - "EO1 = kV/m \t2597956.83558\n", - "EO2 = kV/m \t2597429.47744\n", - "EI1 = kV/m \t2402709.21273\n", - "EI2 = kV/m \t2402258.0563\n", - "\tPart c\t\n", - "The average of the maximum gradient = kV/m \t2597693.15651\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 2, page 66\n", - "\n", - "\n", - "#calculation based on figure 2.32\n", - "from math import sqrt,pi,log\n", - "\n", - "#(a)Charge on each bundle\n", - "print\"Part a\\t\"\n", - "req = sqrt(0.0175*0.45)\n", - "print\"Equivalent radius = m \\t\", req\n", - "V = 400*10**3 #Voltage\n", - "H = 12. #bundle height in m\n", - "d = 9. #pole to pole spacing in m\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "Hd = sqrt((2*H)**2+d**2)#2*H**2 + d**2\n", - "Q = V*2*pi*e0/(log((2*H/req))-log((Hd/d)))\n", - "q = Q/2\n", - "print\"Charge per bundle = uC/m \\t\",Q #micro C/m\n", - "print\"Charge per sunconducter = uC/m \\t\",q #micro C/m\n", - "\n", - "#(b part i)Maximim & average surface feild\n", - "print\"\\tPart b\"\n", - "print\"\\tSub part 1\\t\"\n", - "r = 0.0175 #subconductor radius\n", - "R = 0.45 #conductor to subconductor spacing\n", - "MF = (q/(2*pi*e0))*((1/r)+(1/R)) # maximum feild\n", - "print\"Maximum feild = kV/m \\t\",MF\n", - "MSF = (q/(2*pi*e0))*((1/r)-(1/R)) # maximum surface feild\n", - "print\"Maximum feild = kV/m \\t\",MSF\n", - "ASF = (q/(2*pi*e0))*(1/r) # Average surface feild\n", - "print\"Maximum feild = kV/m \\t\",ASF\n", - "\n", - "#(b part ii) Considering the two sunconductors on the left\n", - "print\"\\tSub part 2\\t\"\n", - "#field at the outer point of subconductor #1 \n", - "drO1 = 1/(d+r)\n", - "dRrO1 = 1/(d+R+r)\n", - "EO1 = MF -((q/(2*pi*e0))*(drO1+dRrO1))\n", - "print\"EO1 = kV/m \\t\",EO1\n", - "#field at the outer point of subconductor #2 \n", - "drO2 = 1/(d-r)\n", - "dRrO2 = 1/(d-R-r)\n", - "EO2 = MF -((q/(2*pi*e0))*(dRrO2+drO2))\n", - "print\"EO2 = kV/m \\t\",EO2\n", - "\n", - "#field at the inner point of subconductor #1 \n", - "drI1 = 1/(d-r)\n", - "dRrI1 = 1/(d+R-r)\n", - "EI1 = MSF -((q/(2*pi*e0))*(drI1+dRrI1))\n", - "print\"EI1 = kV/m \\t\",EI1\n", - "#field at the inner point of subconductor #2 \n", - "drI2 = 1/(d+r)\n", - "dRrI2 = 1/(d-R+r)\n", - "EI2 = MSF -((q/(2*pi*e0))*(dRrI2+drI2)) \n", - "print\"EI2 = kV/m \\t\",EI2\n", - "\n", - "#(part c)Average of the maximim gradient\n", - "print\"\\tPart c\\t\"\n", - "Eavg = (EO1+EO2)/2\n", - "print\"The average of the maximum gradient = kV/m \\t\",Eavg\n", - "\n", - "#Answers might vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_3 pgno:69" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Electric Feild = V/m \t35950238891.0\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 3, page 69\n", - "#Electric feild induced at x\n", - "from math import pi\n", - "e0 = 8.85418*10**-12 #Epselon nought\n", - "q = 1 # C/m\n", - "C = (q/(2*pi*e0))\n", - "#Based on figure 2.33\n", - "E = C-(C*(1/3+1/7))+(C*(1+1/5+1/9))+(C*(1/5+1/9))-(C*(1/3+1/7))\n", - "print\"Electric Feild = V/m \\t\",E\n", - "\n", - "#Answers might vary due to round off error\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 2_4 pgno:70" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\tThickness of graded design= cm \t4.24264068712\n", - "Curve = cm**2 \t62.4264068712\n", - "V1 = cm**3 \t47402.906725\n", - "Thickness of regular design = cm \t14.684289433\n", - "V2 = cm**3 \t861.944682812\n" - ] - } - ], - "source": [ - "#Chapter 2, Exmaple 4, page 70\n", - "#Calculate the volume of the insulator\n", - "from math import sqrt,pi,e\n", - "#Thinkness of graded design\n", - "V = 150*sqrt(2)\n", - "Ebd = 50\n", - "T = V/Ebd\n", - "print\"\\tThickness of graded design= cm \\t\",T\n", - "#Based on figure 2.24\n", - "r = 2 # radius of the conductor\n", - "l = 10 #length of graded cylinder; The textbook uses 10 instead of 20\n", - "zr = l*(T+r)\n", - "print\"Curve = cm**2 \\t\",zr\n", - "#Volume of graded design V1\n", - "V1 = 4*pi*zr*(zr-r)\n", - "print\"V1 = cm**3 \\t\",V1 #Unit is wrong in the textbook\n", - "#Thickness of regular design as obtained form Eq.2.77\n", - "pow = V/(2*Ebd)\n", - "t = 2*(e**pow-1)\n", - "print\"Thickness of regular design = cm \\t\",t\n", - "#Volume of regular design V2\n", - "V2 = pi*((2+t)**2-4)\n", - "print\"V2 = cm**3 \\t\",V2#unit not mentioned in textbook\n", - " \n", - "#Answers may vary due to round off error\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics.ipynb b/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics.ipynb new file mode 100644 index 00000000..62799900 --- /dev/null +++ b/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics.ipynb @@ -0,0 +1,461 @@ +{ + "metadata": { + "name": " Chapter 1 Basics of thermodynamics Rudramani" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Basics of Thermodynamics" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.1 # pageno 34" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "f=-40 # medium temperature in -40 degree\nf1=32 # standard value in 32\nT=(f-f1)*5/9 #temperature in degree\nprint \"hence -40 on the fahrenheit scale is equal to \",T,\" on the degree celsius\"", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "hence -40 on the fahrenheit scale is equal to -40 on the degree celsius\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.2 # pageno 34" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find density\nmass=1600 #mass in kg\nv=2 # volume in 2m3\nd=mass/v # density in kg/m3\nprint 'Density =mass/volume =',d,'kg/m3'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Density =mass/volume = 800 kg/m3\n" + } + ], + "prompt_number": 107 + }, + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Ex 1.3 # page no 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find specific weight of oil\nm=1600 # mass of oil\ng=9.81 # acceleration due to gravity\nv=2 # volume\ns=(m*g)/v # specific gravity\nprint s,\"N/m3\"", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "7848.0 N/m3\n" + } + ], + "prompt_number": 106 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.4 #pageno 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "Do=float(800) #Density of oil\nDW=float(1000) #Density of water\n\n#calculation\nSG=float(Do/DW) #Specific grav\n#print SG\n#print ('%.1f' %(SG*.1))\n#output\nprint \"Specific gravity \",SG", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Specific gravity 0.8\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.5 # pageno 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find kinematic viscosity\nu=0.001 #viscosity of oil\np=800 # specific gravity\nk=u/p # kinematic viscosity\nprint \"kinematic viscosity\", k,\"m2/s\"", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "kinematic viscosity 1.25e-06 m2/s\n" + } + ], + "prompt_number": 40 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.6 # pageno 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find the absolute pressure\np1=13600 # atmospheric pressue\ng=9.81# vaccum pressure\nh=0.76 #barometric pressure of mercury\nBa=p1*g*h\nprint 'Barometric pressure',round(Ba/1000,1),'kN/m2'\ngauge= 5000# gauge pressure\nAb=(Ba/1000)+gauge # Absolute pressure=atmospheric pressure + gauge pressure\nprint 'Absoulte pressure',round(Ab,1),'kPa = or ',round(Ab/1000,1),'bar'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Barometric pressure 101.4 kN/m2\nAbsoulte pressure 5101.4 kPa = or 5.1 bar\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.7 #pageno 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find absolute temperature\nbar=760 # barometeric pressure\nvac=700 # vacuum pressure\nab=bar-vac\nprint ab,'mm of Hg'\np=13600 # specific gravity \ng=9.81 # accelration due to gravity\nh=0.06 # N/m2\nAb=(p*g*h)\nprint 'Absolute pressure',Ab,'N/m2'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "60 mm of Hg\nAbsolute pressure 8004.96 N/m2\n" + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.8 #pageno 35" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#page no35 to find heat required \nt2=1300 # temperature in kelvin\nt1=290 # temperature 290k\nc=.49 # mass 0.49 kj/kg k\nm=200 # mass in kg\nH=(m*c)*(t2-t1)\nprint 'Heat required',H,'kJ'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Heat required 98980.0 kJ\n" + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.9 #pageno 36" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find change in internal energy\nm=-0.3 # mechanical stirrer\nt=5 # min\nt1=5*60 # minutes into seconds\nw=m*t1 # work done by mechanical stirrer\nprint 'work done by mechanical stirrer',w,'kJ'\nq=5*300 # charge in t*w\nu=q+w # U=Q-W\nprint 'change in internal energy of water U=Q-W',u,'kJ'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "work done by mechanical stirrer -90.0 kJ\nchange in internal energy of water U=Q-W 1410.0 kJ\n" + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.10 # pageno 36" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# from tables h=460.545 \nh=460.545 #kJ/kg \nv=0.066484 # m3/kg\np=400 # pressure from table \nu=h-(p*v) # kJ/kg\nprint 'U=',u,'kJ/kg'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "U= 433.9514 kJ/kg\n" + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.11 #pageno 36" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to calculate total work done\np1=4 # bar 1\np2=1 # bar2\ng=1.4 # gamma\nt1=425 # t1 in temperature 425k\nte=(g-1)/g #gamma-1/gamma\ng1=(p1/p2)**te\nt2=t1/g1 # temperature T2\nprint 'T2 =',round(t2,1),'K'\nv1=0.2 # volume of 0.2 m3\nv3=1/g # 1/gamma\nv2=(0.25)**v3\nprint 'V1/V2',round(v2,4)\nvol=v1/v2\nprint 'V2 = ',round(vol,4),'m3'\nR=1-v3\nprint 'R=cp-cv=',round(R*1000,1),'J/kg K'\nm=(p1*v1*10**5)/(t2*t1)\nprint round(m,3),'kg'\nen=70\nt3=(en/m)+(t2)\nprint 'T3 =',round(t3,1),'K'\nV3=vol*t3/t2\nprint 'V3 =',round(V3,3),'m3'\nW=((p1*v1*10**5)-(p2*vol*10**5))/0.4\nprint 'W1-2 =',round(W/1000,3),'kJ'\nW2=p2*10**5*(V3-vol)\nprint 'W2-3 = ',round(W2*100,2),'kJ'\nW1=W+W2\nprint 'W =W1-2+W2-3 =',round(W1/1000,3),'kJ'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "T2 = 286.0 K\nV1/V2 0.3715\nV2 = 0.5384 m3\nR=cp-cv= 285.7 J/kg K\n0.658 kg\nT3 = 392.4 K\nV3 = 0.739 m3\nW1-2 = 65.41 kJ\nW2-3 = 2002026.54 kJ\nW =W1-2+W2-3 = 85.43 kJ\n" + } + ], + "prompt_number": 51 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex1.12\n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# pageno 36 to find final temperature\n#from figure ddepicts the process given in book\nT1=300 # temperature in 300K\nv2=float(0.003) #volume in 0.003m3\nv1=float(0.03)\nn=float(1.3)#n\nt=(v2/v1)**(n-1)\nprint round(t,3)\nT2=T1/t # temperature in degree c\np=2\nprint 'T2 =',round(T2),'=' ,round(T2-273),' degree C'\np1=(v2/v1)**n\np2=p/p1\nprint 'P2 =',round(p2),'bar=',round(p2),'10**5 N/m2'\nw=((p2*10**5*v2)-(p*10**5*v1))/(n-1)# work done during compression\nprint 'W1-2= ',round(w),'J',round(w,1)/1000,'kJ' ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "0.501\nT2 = 599.0 = 326.0 degree C\nP2 = 40.0 bar= 40.0 10**5 N/m2\nW1-2= 19905.0 J 19.9052 kJ\n" + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "EX 1.13 #pageno 38" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "Thigh=float(1200) # temperature in high\nK=float(273) # 273 in kelvin\nth=float(Thigh+K) #convert degree into kelvin\nTlow = float(150) # temperature in low\ntl=float(Tlow+K) #convert degree into kelvin\nn=float((th-tl)/th) #effiency in percentage of engine\nprint 'Effiency = ',round(n,3),'=',round(n*100,3),'%'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Effiency = 0.713 = 71.283 %\n" + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex1.14 #pageno 38" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#to find heat supplied by each source and to effiency of the engine\n# to find reversible engine mentioned in figure in the textbook\nt1=float(1000) # constant temperature\nt2=float(310)# constant temperature\nn1=float((t1-t2)/t1)\nprint 'n1 =',n1\nt3=float(800)# constant temperature\nn2=float((t3-t2)/t3)\nprint 'n2 =',n2\nQ1=25.8 \nQ2=134.2\nW=100# work obtained\nth=W/(Q1+Q2) # heat supllied from the source\nprint 'Thermal efficiency of the engine = ',th,'=',th*100,'%'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "n1 = 0.69\nn2 = 0.6125\nThermal efficiency of the engine = 0.625 = 62.5 %\n" + } + ], + "prompt_number": 104 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.15 " + }, + { + "cell_type": "code", + "collapsed": false, + "input": "#to find power required to drive the plant\ntlow=float(263) # low temperature\nthigh=float(300) # high temperature\ncop=float(tlow/(thigh-tlow)) #coefficient of performance ideal\nprint 'COP ideal =',round(cop,2)\np=0.6\ncopac=cop*p #coefficient of performance actual\nprint 'COP actual =',round(copac,3)\nhe= 30*10**3\nw=he/copac # power required to drive plant\nprint 'power required to run the plant = ',round(w/1000,3),'kW'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "COP ideal = 7.11\nCOP actual = 4.265\npower required to run the plant = 7.034 kW\n" + } + ], + "prompt_number": 83 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "\nEx 1.16 \n" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find conduction heat transfer rate through the plate\nT2=600 # high temperature\nT1=100# low temperature\nL=0.1 # thickness of slab\nK=20 # thermal conductivity \nA=1 # area in m2\nQ=(K*A)*(T2-T1)/L\nprint 'Q =',Q/1000,'kW'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q = 100.0 kW\n" + } + ], + "prompt_number": 88 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex1.17" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# To find heat conduction \nt1=1300 #temperature at 1300 degree c\nt3=115 # temperature at 115 degree c\nl1=0.5 # thickneess of slab\nk1=1.4 # thermal conductivity\na=1 # constant a=1\nl2=0.161 # thickness of slab 2\nk2=0.35 # thermal conductivity of second slab\nQ=(t1-t3)/((l1/(a*k1))+(l2/(a*k2))) # conduction of heat transfer\nprint 'Q=',round(Q,1),'W =',round(Q/1000,2),'kW'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q= 1450.2 W = 1.45 kW\n" + } + ], + "prompt_number": 8 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.18 pageno 40" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find conduction transfer\nimport math\nt1=float(300)\nt2=float(200)\nl=float(2)\nk=float(70)\nr2=float(0.1)\nr1=float(0.05)\nQ=float((k*2*3.14*l*(t1-t2))/(math.log((r2/r1))))\nprint 'Q= ',round(Q,2),'W =',round(Q/1000,2),'kW'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q= 126841.75 W = 126.84 kW\n" + } + ], + "prompt_number": 53 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "EX 1.19 pageno 40" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find internal temperature and conduction transfer rate\nimport math\nt1=float(225)# temperature in degree\nt4=float(25) # temperature in degree\nL=1 #length in m\nk1=float(50) #thermal conductivity constant\nr1=float(5)#thermal conductivity constant\nr2=float(5.5)#thermal conductivity constant\nk2=float(0.06) #thermal conductivity constant\nr3=float(10.0)#thermal conductivity constant\nr4=float(15.5)#thermal conductivity constant\nk4=float(1/(k1)) #1/k1\nk3=0.12 #thermal conductivity constant\np=float(1/(2*math.pi*L)) #1/2pil\nk5=float(1/(k2)) #1/k2\nk6=float(1/(k3)) #1/k3\nQ=float((t1-t4)/(p*((k4*math.log(r1/r2))+(k5*math.log(r3/r2))+(k6*math.log(r4/r3))))) #Conduction transfer\nprint 'Q= ',round(Q,2),'W'\nprint 'calculation error in textbook' # error in textbook\nT2=(t1-float(Q*p*(k4*math.log(r2/r1)))) # internal temperature T2\nprint 'T2 = ',round(T2,1),'Degree C' \nT3 =(T2-float(Q*p*(k5*math.log(r3/r2)))) # internal temperature T3\nprint 'T3 =',round(T3,2),'Degree C'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q= 92.3 W\ncalculation error in textbook\nT2 = 225.0 Degree C\nT3 = 78.6 Degree C\n" + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.20 pageno 41" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to find conduction heat transfer rate through hallow sphere\nimport math3\nt1=290 # inner surface temperature\nt3=20 # outter surface temperature\nk1=float(70) # thermal conductivity k1\nr2=float(0.15) # radius r2\nr1=0.05 # radius r1\nk2=float(15) # thermal conductivity k2\nr3= float(0.2) # radius r3\np=float(1/(4*3.14)) #1/4pi\nr5=float((1)/(k1)) # 1/k1\nr4=float((1)/(k2)) #1/k2\nQ=float((t1-t3)/((p)*((r5*((r2-r1)/(r1*r2)))+(r4*((r3-r2)/(r3*r2)))))) # thermal conductivity\nprint 'Q= ',round(Q,2),'W'\n ", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q= 11244.51 W\n" + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Ex 1.21 #page no 41" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "# to determine radiation heat exchange between to plates\nsigma=0.567*10**-7 # surface density of square plate\nt1=1273# temperature of plate1\nt2=773 # temperature of plate 2\nf12=0.415 # shape factor\na1=1 # area of size 1mx1m\nQ=a1*f12*sigma*((t1**4)-(t2**4)) # thermal conductivity\nprint 'Q=',round(Q,2),'W =',round(Q/1000,2),'kW'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Q= 53392.43 W = 53.39 kW\n" + } + ], + "prompt_number": 44 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics_Rudramani.ipynb b/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics_Rudramani.ipynb deleted file mode 100644 index 62799900..00000000 --- a/sample_notebooks/ravindra m gowda/Chapter_1_Basics_of_thermodynamics_Rudramani.ipynb +++ /dev/null @@ -1,461 +0,0 @@ -{ - "metadata": { - "name": " Chapter 1 Basics of thermodynamics Rudramani" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Basics of Thermodynamics" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.1 # pageno 34" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "f=-40 # medium temperature in -40 degree\nf1=32 # standard value in 32\nT=(f-f1)*5/9 #temperature in degree\nprint \"hence -40 on the fahrenheit scale is equal to \",T,\" on the degree celsius\"", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "hence -40 on the fahrenheit scale is equal to -40 on the degree celsius\n" - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.2 # pageno 34" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find density\nmass=1600 #mass in kg\nv=2 # volume in 2m3\nd=mass/v # density in kg/m3\nprint 'Density =mass/volume =',d,'kg/m3'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Density =mass/volume = 800 kg/m3\n" - } - ], - "prompt_number": 107 - }, - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Ex 1.3 # page no 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find specific weight of oil\nm=1600 # mass of oil\ng=9.81 # acceleration due to gravity\nv=2 # volume\ns=(m*g)/v # specific gravity\nprint s,\"N/m3\"", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "7848.0 N/m3\n" - } - ], - "prompt_number": 106 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.4 #pageno 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "Do=float(800) #Density of oil\nDW=float(1000) #Density of water\n\n#calculation\nSG=float(Do/DW) #Specific grav\n#print SG\n#print ('%.1f' %(SG*.1))\n#output\nprint \"Specific gravity \",SG", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Specific gravity 0.8\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.5 # pageno 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find kinematic viscosity\nu=0.001 #viscosity of oil\np=800 # specific gravity\nk=u/p # kinematic viscosity\nprint \"kinematic viscosity\", k,\"m2/s\"", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "kinematic viscosity 1.25e-06 m2/s\n" - } - ], - "prompt_number": 40 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.6 # pageno 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find the absolute pressure\np1=13600 # atmospheric pressue\ng=9.81# vaccum pressure\nh=0.76 #barometric pressure of mercury\nBa=p1*g*h\nprint 'Barometric pressure',round(Ba/1000,1),'kN/m2'\ngauge= 5000# gauge pressure\nAb=(Ba/1000)+gauge # Absolute pressure=atmospheric pressure + gauge pressure\nprint 'Absoulte pressure',round(Ab,1),'kPa = or ',round(Ab/1000,1),'bar'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Barometric pressure 101.4 kN/m2\nAbsoulte pressure 5101.4 kPa = or 5.1 bar\n" - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.7 #pageno 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find absolute temperature\nbar=760 # barometeric pressure\nvac=700 # vacuum pressure\nab=bar-vac\nprint ab,'mm of Hg'\np=13600 # specific gravity \ng=9.81 # accelration due to gravity\nh=0.06 # N/m2\nAb=(p*g*h)\nprint 'Absolute pressure',Ab,'N/m2'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "60 mm of Hg\nAbsolute pressure 8004.96 N/m2\n" - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.8 #pageno 35" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#page no35 to find heat required \nt2=1300 # temperature in kelvin\nt1=290 # temperature 290k\nc=.49 # mass 0.49 kj/kg k\nm=200 # mass in kg\nH=(m*c)*(t2-t1)\nprint 'Heat required',H,'kJ'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Heat required 98980.0 kJ\n" - } - ], - "prompt_number": 19 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.9 #pageno 36" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find change in internal energy\nm=-0.3 # mechanical stirrer\nt=5 # min\nt1=5*60 # minutes into seconds\nw=m*t1 # work done by mechanical stirrer\nprint 'work done by mechanical stirrer',w,'kJ'\nq=5*300 # charge in t*w\nu=q+w # U=Q-W\nprint 'change in internal energy of water U=Q-W',u,'kJ'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "work done by mechanical stirrer -90.0 kJ\nchange in internal energy of water U=Q-W 1410.0 kJ\n" - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.10 # pageno 36" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# from tables h=460.545 \nh=460.545 #kJ/kg \nv=0.066484 # m3/kg\np=400 # pressure from table \nu=h-(p*v) # kJ/kg\nprint 'U=',u,'kJ/kg'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "U= 433.9514 kJ/kg\n" - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.11 #pageno 36" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to calculate total work done\np1=4 # bar 1\np2=1 # bar2\ng=1.4 # gamma\nt1=425 # t1 in temperature 425k\nte=(g-1)/g #gamma-1/gamma\ng1=(p1/p2)**te\nt2=t1/g1 # temperature T2\nprint 'T2 =',round(t2,1),'K'\nv1=0.2 # volume of 0.2 m3\nv3=1/g # 1/gamma\nv2=(0.25)**v3\nprint 'V1/V2',round(v2,4)\nvol=v1/v2\nprint 'V2 = ',round(vol,4),'m3'\nR=1-v3\nprint 'R=cp-cv=',round(R*1000,1),'J/kg K'\nm=(p1*v1*10**5)/(t2*t1)\nprint round(m,3),'kg'\nen=70\nt3=(en/m)+(t2)\nprint 'T3 =',round(t3,1),'K'\nV3=vol*t3/t2\nprint 'V3 =',round(V3,3),'m3'\nW=((p1*v1*10**5)-(p2*vol*10**5))/0.4\nprint 'W1-2 =',round(W/1000,3),'kJ'\nW2=p2*10**5*(V3-vol)\nprint 'W2-3 = ',round(W2*100,2),'kJ'\nW1=W+W2\nprint 'W =W1-2+W2-3 =',round(W1/1000,3),'kJ'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "T2 = 286.0 K\nV1/V2 0.3715\nV2 = 0.5384 m3\nR=cp-cv= 285.7 J/kg K\n0.658 kg\nT3 = 392.4 K\nV3 = 0.739 m3\nW1-2 = 65.41 kJ\nW2-3 = 2002026.54 kJ\nW =W1-2+W2-3 = 85.43 kJ\n" - } - ], - "prompt_number": 51 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex1.12\n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# pageno 36 to find final temperature\n#from figure ddepicts the process given in book\nT1=300 # temperature in 300K\nv2=float(0.003) #volume in 0.003m3\nv1=float(0.03)\nn=float(1.3)#n\nt=(v2/v1)**(n-1)\nprint round(t,3)\nT2=T1/t # temperature in degree c\np=2\nprint 'T2 =',round(T2),'=' ,round(T2-273),' degree C'\np1=(v2/v1)**n\np2=p/p1\nprint 'P2 =',round(p2),'bar=',round(p2),'10**5 N/m2'\nw=((p2*10**5*v2)-(p*10**5*v1))/(n-1)# work done during compression\nprint 'W1-2= ',round(w),'J',round(w,1)/1000,'kJ' ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "0.501\nT2 = 599.0 = 326.0 degree C\nP2 = 40.0 bar= 40.0 10**5 N/m2\nW1-2= 19905.0 J 19.9052 kJ\n" - } - ], - "prompt_number": 9 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "EX 1.13 #pageno 38" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "Thigh=float(1200) # temperature in high\nK=float(273) # 273 in kelvin\nth=float(Thigh+K) #convert degree into kelvin\nTlow = float(150) # temperature in low\ntl=float(Tlow+K) #convert degree into kelvin\nn=float((th-tl)/th) #effiency in percentage of engine\nprint 'Effiency = ',round(n,3),'=',round(n*100,3),'%'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Effiency = 0.713 = 71.283 %\n" - } - ], - "prompt_number": 12 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex1.14 #pageno 38" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#to find heat supplied by each source and to effiency of the engine\n# to find reversible engine mentioned in figure in the textbook\nt1=float(1000) # constant temperature\nt2=float(310)# constant temperature\nn1=float((t1-t2)/t1)\nprint 'n1 =',n1\nt3=float(800)# constant temperature\nn2=float((t3-t2)/t3)\nprint 'n2 =',n2\nQ1=25.8 \nQ2=134.2\nW=100# work obtained\nth=W/(Q1+Q2) # heat supllied from the source\nprint 'Thermal efficiency of the engine = ',th,'=',th*100,'%'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "n1 = 0.69\nn2 = 0.6125\nThermal efficiency of the engine = 0.625 = 62.5 %\n" - } - ], - "prompt_number": 104 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.15 " - }, - { - "cell_type": "code", - "collapsed": false, - "input": "#to find power required to drive the plant\ntlow=float(263) # low temperature\nthigh=float(300) # high temperature\ncop=float(tlow/(thigh-tlow)) #coefficient of performance ideal\nprint 'COP ideal =',round(cop,2)\np=0.6\ncopac=cop*p #coefficient of performance actual\nprint 'COP actual =',round(copac,3)\nhe= 30*10**3\nw=he/copac # power required to drive plant\nprint 'power required to run the plant = ',round(w/1000,3),'kW'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "COP ideal = 7.11\nCOP actual = 4.265\npower required to run the plant = 7.034 kW\n" - } - ], - "prompt_number": 83 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "\nEx 1.16 \n" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find conduction heat transfer rate through the plate\nT2=600 # high temperature\nT1=100# low temperature\nL=0.1 # thickness of slab\nK=20 # thermal conductivity \nA=1 # area in m2\nQ=(K*A)*(T2-T1)/L\nprint 'Q =',Q/1000,'kW'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q = 100.0 kW\n" - } - ], - "prompt_number": 88 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex1.17" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# To find heat conduction \nt1=1300 #temperature at 1300 degree c\nt3=115 # temperature at 115 degree c\nl1=0.5 # thickneess of slab\nk1=1.4 # thermal conductivity\na=1 # constant a=1\nl2=0.161 # thickness of slab 2\nk2=0.35 # thermal conductivity of second slab\nQ=(t1-t3)/((l1/(a*k1))+(l2/(a*k2))) # conduction of heat transfer\nprint 'Q=',round(Q,1),'W =',round(Q/1000,2),'kW'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q= 1450.2 W = 1.45 kW\n" - } - ], - "prompt_number": 8 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.18 pageno 40" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find conduction transfer\nimport math\nt1=float(300)\nt2=float(200)\nl=float(2)\nk=float(70)\nr2=float(0.1)\nr1=float(0.05)\nQ=float((k*2*3.14*l*(t1-t2))/(math.log((r2/r1))))\nprint 'Q= ',round(Q,2),'W =',round(Q/1000,2),'kW'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q= 126841.75 W = 126.84 kW\n" - } - ], - "prompt_number": 53 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "EX 1.19 pageno 40" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find internal temperature and conduction transfer rate\nimport math\nt1=float(225)# temperature in degree\nt4=float(25) # temperature in degree\nL=1 #length in m\nk1=float(50) #thermal conductivity constant\nr1=float(5)#thermal conductivity constant\nr2=float(5.5)#thermal conductivity constant\nk2=float(0.06) #thermal conductivity constant\nr3=float(10.0)#thermal conductivity constant\nr4=float(15.5)#thermal conductivity constant\nk4=float(1/(k1)) #1/k1\nk3=0.12 #thermal conductivity constant\np=float(1/(2*math.pi*L)) #1/2pil\nk5=float(1/(k2)) #1/k2\nk6=float(1/(k3)) #1/k3\nQ=float((t1-t4)/(p*((k4*math.log(r1/r2))+(k5*math.log(r3/r2))+(k6*math.log(r4/r3))))) #Conduction transfer\nprint 'Q= ',round(Q,2),'W'\nprint 'calculation error in textbook' # error in textbook\nT2=(t1-float(Q*p*(k4*math.log(r2/r1)))) # internal temperature T2\nprint 'T2 = ',round(T2,1),'Degree C' \nT3 =(T2-float(Q*p*(k5*math.log(r3/r2)))) # internal temperature T3\nprint 'T3 =',round(T3,2),'Degree C'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q= 92.3 W\ncalculation error in textbook\nT2 = 225.0 Degree C\nT3 = 78.6 Degree C\n" - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.20 pageno 41" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to find conduction heat transfer rate through hallow sphere\nimport math3\nt1=290 # inner surface temperature\nt3=20 # outter surface temperature\nk1=float(70) # thermal conductivity k1\nr2=float(0.15) # radius r2\nr1=0.05 # radius r1\nk2=float(15) # thermal conductivity k2\nr3= float(0.2) # radius r3\np=float(1/(4*3.14)) #1/4pi\nr5=float((1)/(k1)) # 1/k1\nr4=float((1)/(k2)) #1/k2\nQ=float((t1-t3)/((p)*((r5*((r2-r1)/(r1*r2)))+(r4*((r3-r2)/(r3*r2)))))) # thermal conductivity\nprint 'Q= ',round(Q,2),'W'\n ", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q= 11244.51 W\n" - } - ], - "prompt_number": 41 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Ex 1.21 #page no 41" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "# to determine radiation heat exchange between to plates\nsigma=0.567*10**-7 # surface density of square plate\nt1=1273# temperature of plate1\nt2=773 # temperature of plate 2\nf12=0.415 # shape factor\na1=1 # area of size 1mx1m\nQ=a1*f12*sigma*((t1**4)-(t2**4)) # thermal conductivity\nprint 'Q=',round(Q,2),'W =',round(Q/1000,2),'kW'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Q= 53392.43 W = 53.39 kW\n" - } - ], - "prompt_number": 44 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/sai kiranmalepati/Sample_Notebook.ipynb b/sample_notebooks/sai kiranmalepati/Sample_Notebook.ipynb deleted file mode 100644 index 03ccf753..00000000 --- a/sample_notebooks/sai kiranmalepati/Sample_Notebook.ipynb +++ /dev/null @@ -1,349 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# SAMPLE NOTEBOOK" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "## ch-9 page 227 pb-1" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('load current =', 21.78649237472767)\n", - "('design current=', 28.32244008714597)\n", - "('Derating factor=', 0.92)\n", - "('fuse rating=', 30.785260964289098)\n" - ] - } - ], - "source": [ - "\n", - "from __future__ import division\n", - "\n", - "import math\n", - "\n", - "vi=120;\n", - "k=1000;\n", - "pi=2*k;\n", - "eff=0.90;\n", - "pf=0.85;\n", - "t=65;\n", - "\n", - "lc=(pi)/(vi*eff*pf);\n", - "print('load current =',lc);\n", - "\n", - "dc=1.3*lc;\n", - "print('design current=',dc);\n", - "\n", - "df=(0.2/100)*(t-25);\n", - "df=11.5*df;\n", - "print('Derating factor=',df);\n", - "\n", - "fr=dc/df;\n", - "print('fuse rating=',fr);\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "## ch-10 page 268 pb-6" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('power delivered =', 500000.0, 'watts')\n", - "('power loss=', 10000.0, 'watts')\n", - "(510583.1892725521, 241709.44403085182)\n", - "('kvar_cap=', 268.87374524170025)\n", - "('c=', 10.111669570616154, 'micro farad/ph')\n", - "('differences in kva demand=', 158.7301587301588)\n", - "('loss in cable =', 0.6049382716049381)\n", - "('cost saving=', 5294.849999999999)\n", - "('total three phase capacitor cost=', 48397.274143506045, '$')\n", - "('capacitor cost will be recoverred in', 9.140442910281887, 'months')\n" - ] - } - ], - "source": [ - "\n", - "from __future__ import division\n", - "\n", - "import math\n", - "\n", - "lpf1=0.70;\n", - "lpf2=0.90;\n", - "vi=460;\n", - "f=60;\n", - "k=1000;\n", - "p=1500*k;\n", - "time=300;\n", - "cost=60;\n", - "l=2/100;\n", - "theta1=45.6;\n", - "theta2=25.8;\n", - "pd=p/3; #since 3 phase;\n", - "pl=l*pd;\n", - "\n", - "print('power delivered =',pd,'watts');\n", - "print('power loss=',pl,'watts');\n", - "\n", - "var1=pd*(math.tan((math.pi/180)*theta1));\n", - "var2=pd*(math.tan((math.pi/180)*theta2));\n", - "var=var1-var2;\n", - "print(var1,var2);\n", - "kvar=var/1000;\n", - "print('kvar_cap=',kvar);\n", - "\n", - "vp=vi/(math.sqrt(3));\n", - "w=2*math.pi*f;\n", - "\n", - "c=(1000*kvar)/(w*vp*vp);\n", - "c=c*1000;\n", - "print('c=',c,'micro farad/ph');\n", - "\n", - "kva1=(pd/1000)/lpf1;\n", - "kva2=(pd/1000)/lpf2;\n", - "\n", - "dkva=kva1-kva2;\n", - "print('differences in kva demand=',dkva);\n", - "\n", - "loss=(lpf1/lpf2)*(lpf1/lpf2);\n", - "print('loss in cable =',loss);\n", - "\n", - "kvas=3*158.72;\n", - "\n", - "scl=3*3.95;\n", - "\n", - "tcost=10*kvas+0.15*scl*time;\n", - "print('cost saving=',tcost);\n", - "\n", - "tccost=cost*3*kvar;\n", - "\n", - "print('total three phase capacitor cost=',tccost,'$');\n", - "\n", - "duration=tccost/tcost;\n", - "print('capacitor cost will be recoverred in',duration,'months');\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "## ch-13 page 340 pb-3" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('duty cycle=', 0.5)\n", - "('avg o/p voltage=', 60.0)\n", - "('avg o/p current=', 4.0)\n", - "('avg o/p power=', 240.0)\n", - "('L min=', 3.0, 'mhenry')\n" - ] - } - ], - "source": [ - "\n", - "from __future__ import division\n", - "\n", - "import math\n", - "\n", - "v=120;\n", - "i=2;\n", - "f=1000;\n", - "to=(0.5)/1000;\n", - "\n", - "T=1/f;\n", - "\n", - "dr=(to)/T;\n", - "print('duty cycle=',dr);\n", - "\n", - "vo=dr*v;\n", - "io=i/dr;\n", - "po=vo*io;\n", - "\n", - "print('avg o/p voltage=',vo);\n", - "print('avg o/p current=',io);\n", - "print('avg o/p power=',po);\n", - "\n", - "L=(dr*(v/10))/2;\n", - "\n", - "print('L min=',L,'mhenry');\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "## ch-14 page 363 pb-4" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('V dc=', 339.4112549695428)\n", - "('I dc=', 5.892556509887896)\n", - "('fundamental ac side rms current =', 8.333333333333334)\n", - "('THD=', 0.8259394650941436)\n", - "('I ac(rms)=', 10.77677544021814)\n", - "('I dc(rms)=', 9.023118455759443)\n" - ] - } - ], - "source": [ - "\n", - "from __future__ import division\n", - "import math\n", - "\n", - "v=240;\n", - "f=60;\n", - "p=2000;\n", - "dpf=1;\n", - "k1=73.2;k2=36.6;k3=8.1;k4=5.7;\n", - "k5=4.1;k6=2.9;k7=0.8;k8=0.4;\n", - "h1=3;h2=5;h3=7;h4=9;h5=11;h6=13;h7=17;\n", - "\n", - "vdc=math.sqrt(2)*v;\n", - "\n", - "idc=p/vdc;\n", - "print('V dc=',vdc);\n", - "print('I dc=',idc);\n", - "pac=p/dpf;\n", - "\n", - "\n", - "is1=p/v;\n", - "\n", - "print('fundamental ac side rms current =',is1);\n", - "\n", - "k=(k1*k1)+k2*k2+k3*k3+k4*k4+k5*k5+k6*k6+k7*k7;\n", - "thd=(math.sqrt(k))/100;\n", - "print('THD=',thd);\n", - "\n", - "iac=is1*(math.sqrt(1+(0.82*0.82)));\n", - "\n", - "idcr=math.sqrt((iac*iac)-(idc*idc));\n", - "\n", - "print('I ac(rms)=',iac);\n", - "print('I dc(rms)=',idcr);\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "\n", - "\n", - "\n", - "## ch-16 page 454 pb-6" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('fundamental load current =', 240.5626121623441)\n" - ] - } - ], - "source": [ - "\n", - "from __future__ import division\n", - "import math\n", - "\n", - "v=480;\n", - "k=1000;\n", - "p=200*k;\n", - "thd=600;\n", - "\n", - "lc=p/(math.sqrt(3)*v);\n", - "\n", - "print('fundamental load current =',lc);\n" - ] - } - ], - "metadata": { - "anaconda-cloud": {}, - "kernelspec": { - "display_name": "Python [default]", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.12" - } - }, - "nbformat": 4, - "nbformat_minor": 1 -} diff --git a/sample_notebooks/sai kiranmalepati/sai kiranmalepati_version_backup/Sample.ipynb b/sample_notebooks/sai kiranmalepati/sai kiranmalepati_version_backup/Sample.ipynb new file mode 100644 index 00000000..03ccf753 --- /dev/null +++ b/sample_notebooks/sai kiranmalepati/sai kiranmalepati_version_backup/Sample.ipynb @@ -0,0 +1,349 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# SAMPLE NOTEBOOK" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## ch-9 page 227 pb-1" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('load current =', 21.78649237472767)\n", + "('design current=', 28.32244008714597)\n", + "('Derating factor=', 0.92)\n", + "('fuse rating=', 30.785260964289098)\n" + ] + } + ], + "source": [ + "\n", + "from __future__ import division\n", + "\n", + "import math\n", + "\n", + "vi=120;\n", + "k=1000;\n", + "pi=2*k;\n", + "eff=0.90;\n", + "pf=0.85;\n", + "t=65;\n", + "\n", + "lc=(pi)/(vi*eff*pf);\n", + "print('load current =',lc);\n", + "\n", + "dc=1.3*lc;\n", + "print('design current=',dc);\n", + "\n", + "df=(0.2/100)*(t-25);\n", + "df=11.5*df;\n", + "print('Derating factor=',df);\n", + "\n", + "fr=dc/df;\n", + "print('fuse rating=',fr);\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## ch-10 page 268 pb-6" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('power delivered =', 500000.0, 'watts')\n", + "('power loss=', 10000.0, 'watts')\n", + "(510583.1892725521, 241709.44403085182)\n", + "('kvar_cap=', 268.87374524170025)\n", + "('c=', 10.111669570616154, 'micro farad/ph')\n", + "('differences in kva demand=', 158.7301587301588)\n", + "('loss in cable =', 0.6049382716049381)\n", + "('cost saving=', 5294.849999999999)\n", + "('total three phase capacitor cost=', 48397.274143506045, '$')\n", + "('capacitor cost will be recoverred in', 9.140442910281887, 'months')\n" + ] + } + ], + "source": [ + "\n", + "from __future__ import division\n", + "\n", + "import math\n", + "\n", + "lpf1=0.70;\n", + "lpf2=0.90;\n", + "vi=460;\n", + "f=60;\n", + "k=1000;\n", + "p=1500*k;\n", + "time=300;\n", + "cost=60;\n", + "l=2/100;\n", + "theta1=45.6;\n", + "theta2=25.8;\n", + "pd=p/3; #since 3 phase;\n", + "pl=l*pd;\n", + "\n", + "print('power delivered =',pd,'watts');\n", + "print('power loss=',pl,'watts');\n", + "\n", + "var1=pd*(math.tan((math.pi/180)*theta1));\n", + "var2=pd*(math.tan((math.pi/180)*theta2));\n", + "var=var1-var2;\n", + "print(var1,var2);\n", + "kvar=var/1000;\n", + "print('kvar_cap=',kvar);\n", + "\n", + "vp=vi/(math.sqrt(3));\n", + "w=2*math.pi*f;\n", + "\n", + "c=(1000*kvar)/(w*vp*vp);\n", + "c=c*1000;\n", + "print('c=',c,'micro farad/ph');\n", + "\n", + "kva1=(pd/1000)/lpf1;\n", + "kva2=(pd/1000)/lpf2;\n", + "\n", + "dkva=kva1-kva2;\n", + "print('differences in kva demand=',dkva);\n", + "\n", + "loss=(lpf1/lpf2)*(lpf1/lpf2);\n", + "print('loss in cable =',loss);\n", + "\n", + "kvas=3*158.72;\n", + "\n", + "scl=3*3.95;\n", + "\n", + "tcost=10*kvas+0.15*scl*time;\n", + "print('cost saving=',tcost);\n", + "\n", + "tccost=cost*3*kvar;\n", + "\n", + "print('total three phase capacitor cost=',tccost,'$');\n", + "\n", + "duration=tccost/tcost;\n", + "print('capacitor cost will be recoverred in',duration,'months');\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## ch-13 page 340 pb-3" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('duty cycle=', 0.5)\n", + "('avg o/p voltage=', 60.0)\n", + "('avg o/p current=', 4.0)\n", + "('avg o/p power=', 240.0)\n", + "('L min=', 3.0, 'mhenry')\n" + ] + } + ], + "source": [ + "\n", + "from __future__ import division\n", + "\n", + "import math\n", + "\n", + "v=120;\n", + "i=2;\n", + "f=1000;\n", + "to=(0.5)/1000;\n", + "\n", + "T=1/f;\n", + "\n", + "dr=(to)/T;\n", + "print('duty cycle=',dr);\n", + "\n", + "vo=dr*v;\n", + "io=i/dr;\n", + "po=vo*io;\n", + "\n", + "print('avg o/p voltage=',vo);\n", + "print('avg o/p current=',io);\n", + "print('avg o/p power=',po);\n", + "\n", + "L=(dr*(v/10))/2;\n", + "\n", + "print('L min=',L,'mhenry');\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## ch-14 page 363 pb-4" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('V dc=', 339.4112549695428)\n", + "('I dc=', 5.892556509887896)\n", + "('fundamental ac side rms current =', 8.333333333333334)\n", + "('THD=', 0.8259394650941436)\n", + "('I ac(rms)=', 10.77677544021814)\n", + "('I dc(rms)=', 9.023118455759443)\n" + ] + } + ], + "source": [ + "\n", + "from __future__ import division\n", + "import math\n", + "\n", + "v=240;\n", + "f=60;\n", + "p=2000;\n", + "dpf=1;\n", + "k1=73.2;k2=36.6;k3=8.1;k4=5.7;\n", + "k5=4.1;k6=2.9;k7=0.8;k8=0.4;\n", + "h1=3;h2=5;h3=7;h4=9;h5=11;h6=13;h7=17;\n", + "\n", + "vdc=math.sqrt(2)*v;\n", + "\n", + "idc=p/vdc;\n", + "print('V dc=',vdc);\n", + "print('I dc=',idc);\n", + "pac=p/dpf;\n", + "\n", + "\n", + "is1=p/v;\n", + "\n", + "print('fundamental ac side rms current =',is1);\n", + "\n", + "k=(k1*k1)+k2*k2+k3*k3+k4*k4+k5*k5+k6*k6+k7*k7;\n", + "thd=(math.sqrt(k))/100;\n", + "print('THD=',thd);\n", + "\n", + "iac=is1*(math.sqrt(1+(0.82*0.82)));\n", + "\n", + "idcr=math.sqrt((iac*iac)-(idc*idc));\n", + "\n", + "print('I ac(rms)=',iac);\n", + "print('I dc(rms)=',idcr);\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "\n", + "\n", + "## ch-16 page 454 pb-6" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('fundamental load current =', 240.5626121623441)\n" + ] + } + ], + "source": [ + "\n", + "from __future__ import division\n", + "import math\n", + "\n", + "v=480;\n", + "k=1000;\n", + "p=200*k;\n", + "thd=600;\n", + "\n", + "lc=p/(math.sqrt(3)*v);\n", + "\n", + "print('fundamental load current =',lc);\n" + ] + } + ], + "metadata": { + "anaconda-cloud": {}, + "kernelspec": { + "display_name": "Python [default]", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.12" + } + }, + "nbformat": 4, + "nbformat_minor": 1 +} diff --git a/sample_notebooks/saikomalchanagam/AKmaini.ipynb b/sample_notebooks/saikomalchanagam/AKmaini.ipynb new file mode 100755 index 00000000..71b9c040 --- /dev/null +++ b/sample_notebooks/saikomalchanagam/AKmaini.ipynb @@ -0,0 +1,293 @@ +{ + "metadata": { + "name": "AKmaini" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": "Chapter 11: Satellites and Satellite Communications\n" + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 1, Pg No: 567" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n\n# Variable Declaration\nh = 150; # height of satellite from earth in km\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6370; # radius of earth in km\n\n# Calculations\nu = G*M\nV = math.sqrt(u/((Re + h)*10**3)) # orbital velocity\nV1 = V/1000; # orbital velocity in km/s\n\n# Result\nprint 'Orbital velocity = %3.3f'%V1,'km/s';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Orbital velocity = 7.821 km/s\n" + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 2, Pg No: 568" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\nAp_Pe_diff = 30000; # difference between apogee and perigee in Km\na = 16000; # semi major axis of orbit\n\n# Calculations\ne = Ap_Pe_diff/float(2*a); # Eccentricity\n\n# Result\nprint 'Eccentricity = %3.2f'%e;", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Eccentricity = 0.94\n" + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 3, Pg No:568" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Decalaration\na1 = 18000; # semi major axis of the elliptical orbits of satellite 1\na2 = 24000; # semi major axis of the elliptical orbits of satellite 2\n\n# Calculations\n#T = 2*%pi*sqrt(a^3/u);\n#let K = T2/T1;\nK = (float(a2)/a1)**(3/float(2)); # Ratio of orbital periods\n\n# Result\nprint 'The orbital period of satellite-2 is %3.2f' %K,' times the orbital period of satellite-1';\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "The orbital period of satellite-2 is 1.54 times the orbital period of satellite-1\n" + } + ], + "prompt_number": 14 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 4, Pg No:569" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\n\nh = 35800; # height of satellite orbit from earth in km\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6364; # radius of earth in km\ni = 2; # inclination angle\n\n# Calculations\nu = G*M\nr = Re+h\nVi = math.sqrt(u/r*10**3)* math.tan(i*math.pi/180); # magnitude of velocity impulse\nV = Vi/1000; # magnitude of velocity impulse in m/s\n\n#Result\nprint 'Magnitude of velocity impulse = %d' %V,' m/s';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Magnitude of velocity impulse = 107 m/s\n" + } + ], + "prompt_number": 20 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 5, Pg No: 571" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\nh = float(13622); # ht of circular orbit from earth's surface\nRe = 6378; # Radius of earth in km\n\n# Calculations\nR = Re+h; # Radius of circular orbit\npimax = 180 - (2*math.acos(Re/R))*(180/math.pi); # Maximum shadow angle\neclipmax_time = (pimax/360)*24; # maximum daily eclipse duration\n\n# Result\nprint ' Maximum shadow angle = %3.1f\u00b0' %pimax\nprint ' Maximum daily eclipse duration = %3.2f'%eclipmax_time,' hours';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": " Maximum shadow angle = 37.2\u00b0\n Maximum daily eclipse duration = 2.48 hours\n" + } + ], + "prompt_number": 22 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 6, Pg No:572" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n\n# Variable Declaration\n\nh = 35786; # ht of geo.stationary orbit above earth surface\nT = 365; # time in days\nr = 6378 # radius of earth in km\n\n# ie(t) = 23.4*sin(2*%pi*t/T)\n# for a circular orbit of 20000 km radius ,phi = 37.4\u00b0 ,Therefore, the time from first day of eclipse to equinox is given by substituting ie(t) = 37.4/2 = 18.7\u00b0\nphi = 37.4\nie = (phi/2)*(math.pi/180)\nk = 23.4*(math.pi/180)\nt = (365/(2*math.pi))*math.asin((ie/k)) \n# for geostationary orbit\nphimax = 180 - 2*(math.acos(r/(r+h)))*(180/math.pi)\nt_geo = (365/(2*math.pi))*math.asin((8.7*math.pi/180)/k)\n\n# Result\nprint 'Total time from first day of eclipse to last day of eclipse = %3.1f' %t,' days';\nprint 'Total time from first day of eclipse to last day of eclipse for geostationary orbit = %3.2f' %t_geo, 'days'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Total time from first day of eclipse to last day of eclipse = 53.8 days\nTotal time from first day of eclipse to last day of eclipse for geostationary orbit = 22.13 days\n" + } + ], + "prompt_number": 24 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 7, Pg No:600" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\nm = 100; # mass of satellite\nV = 8000; # orbital velocity in m/s\nRe = 6370; # radius of earth in Km\nH = 200; # satellite height above earth surface\n\n# Calculations\nCF = (m*V**2)/((Re+H)*10**3); #centrifugal force\n\n# Result\nprint 'Centrifugal Force = %d' %CF,' Newtons';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Centrifugal Force = 974 Newtons\n" + } + ], + "prompt_number": 25 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 8, Pg No:601" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\n\nApogee = 30000; # Apogee pt of satellite elliptical orbit\nPerige = 1000; # perigee pt of satellite elliptical orbit\n\n# Calculations\na = (Apogee + Perige)/2; # semi major axis\n\n# Result\nprint 'Semi-major axis = %d' %a,' Km';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Semi-major axis = 15500 Km\n" + } + ], + "prompt_number": 26 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 9, Pg No:603" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math\n\n# Variable Declaration\nfarth = 30000; # farthest point in satellite elliptic eccentric orbit\nclosest = 200; # closest point in satellite elliptic eccentric orbit\nRe = float(6370); # Radius of earth in km\n\n# Calculations\nApogee = farth + Re; # Apogee in km\nPerigee = closest + Re; # perigee in km\na = (Apogee + Perigee)/(2); # semi-major axis\ne = (Apogee - Perigee)/(2*a); # orbit eccentricity\n\n# Result\nprint 'Apogee = %d' %Apogee,' km';\nprint 'Perigee = %d' %Perigee,' km';\nprint 'Orbit eccentricity = %3.3f' %e;", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Apogee = 36370 km\nPerigee = 6570 km\nOrbit eccentricity = 0.694\n" + } + ], + "prompt_number": 29 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 10, Pg No:604" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\ne = 0.5; # orbit eccentricity\nae = 14000; # from fig. the distance from center of ellipse to the centre of earth\n\n# Calculations\na = ae/(e); # semi major axis\napogee = a*(1 + e); # Apogee in km\nperige = a*(1 - e); # perigee in km\n\n# Result\nprint 'Apogee = %d' %apogee,' km'\nprint 'Perigee = %d' %perige,' km'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Apogee = 42000 km\nPerigee = 14000 km\n" + } + ], + "prompt_number": 34 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 11, Pg No:604" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6370*10**3; # radius of earth in m\n\n# Calculations\nu = G*M\nVesc = math.sqrt(2*u/Re);\nVes = Vesc/1000; # escape velocity in km/s\n\n# Result\nprint 'Escape velocity = %3.1f' %Ves,' km/s';", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Escape velocity = 11.2 km/s\n" + } + ], + "prompt_number": 36 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 12, Pg No:605" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# variable Declartion\na = 25000*10**3; # semimajor axis in m from fig\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nh = 0\n\n# Calculations\nu = G*M;\nT = 2*math.pi*math.sqrt((a**3)/u)\nhr = T/3600 # conv. from sec to hrs and min\nt = T%3600 # conv. from sec to hrs and min\nmi = t/60 # conv. from sec to hrs and min\n\n# Result\nprint 'Orbital time period = %d' %hr,' Hours',' %d'%mi, 'minutes'", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Orbital time period = 10 Hours 55 minutes\n" + } + ], + "prompt_number": 41 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": "Example 13, Pg No:605" + }, + { + "cell_type": "code", + "collapsed": false, + "input": "import math;\n\n# Variable Declaration\napogee = float(35000); # farthest point in kms\nperigee = 500; # closest point in kms\nr = float(6360); # radius of earth in kms\nG = 6.67*10**-11 # gravitational constant\nM = 5.98*10**24; # mass of earth in kgs\n\n# calculations\n#funcprot(0)\napogee_dist = apogee + r # apogee distance in kms\nperigee_dist= perigee+r ; # perigee distance in kms\na = (apogee_dist + perigee_dist)/2; # semi-major axis of elliptical orbit\nT = (2*math.pi)*math.sqrt((a*10**3)**3/(G*M)); # orbital time period\nhr = T/3600 # conv. from sec to hrs and min\nt = (T%3600) # conv. from sec to hrs and min\nmi = t/60 # conv. from sec to hrs and min\nu = G*M\nVapogee = math.sqrt(u*((2/(apogee_dist*10**3)) - (1/(a*10**3))))/1000; # velocity at apogee point\nVperigee = math.sqrt((G*M)*((2/(perigee_dist*10**3)-(1/(a*10**3)))))/1000 # velocity at perigee point\n\n#Result\nprint 'Orbital Time Period = %d'%hr,' Hrs'' %d'%mi,' min'\nprint 'Velocity at apogee = %3.3f' %Vapogee,' Km/s'\nprint'Velocity at perigee = %3.3f' %Vperigee,' Km/s'\nprint'Note: Calculation mistake in textbook in finding velocity at apogee point'\n", + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": "Orbital Time Period = 10 Hrs 20 min\nVelocity at apogee = 1.656 Km/s\nVelocity at perigee = 9.987 Km/s\nNote: Calculation mistake in textbook in finding velocity at apogee point\n" + } + ], + "prompt_number": 57 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/saikomalchanagam/AKmaini_(1).ipynb b/sample_notebooks/saikomalchanagam/AKmaini_(1).ipynb deleted file mode 100755 index 71b9c040..00000000 --- a/sample_notebooks/saikomalchanagam/AKmaini_(1).ipynb +++ /dev/null @@ -1,293 +0,0 @@ -{ - "metadata": { - "name": "AKmaini" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": "Chapter 11: Satellites and Satellite Communications\n" - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 1, Pg No: 567" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n\n# Variable Declaration\nh = 150; # height of satellite from earth in km\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6370; # radius of earth in km\n\n# Calculations\nu = G*M\nV = math.sqrt(u/((Re + h)*10**3)) # orbital velocity\nV1 = V/1000; # orbital velocity in km/s\n\n# Result\nprint 'Orbital velocity = %3.3f'%V1,'km/s';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Orbital velocity = 7.821 km/s\n" - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 2, Pg No: 568" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\nAp_Pe_diff = 30000; # difference between apogee and perigee in Km\na = 16000; # semi major axis of orbit\n\n# Calculations\ne = Ap_Pe_diff/float(2*a); # Eccentricity\n\n# Result\nprint 'Eccentricity = %3.2f'%e;", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Eccentricity = 0.94\n" - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 3, Pg No:568" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Decalaration\na1 = 18000; # semi major axis of the elliptical orbits of satellite 1\na2 = 24000; # semi major axis of the elliptical orbits of satellite 2\n\n# Calculations\n#T = 2*%pi*sqrt(a^3/u);\n#let K = T2/T1;\nK = (float(a2)/a1)**(3/float(2)); # Ratio of orbital periods\n\n# Result\nprint 'The orbital period of satellite-2 is %3.2f' %K,' times the orbital period of satellite-1';\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "The orbital period of satellite-2 is 1.54 times the orbital period of satellite-1\n" - } - ], - "prompt_number": 14 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 4, Pg No:569" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\n\nh = 35800; # height of satellite orbit from earth in km\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6364; # radius of earth in km\ni = 2; # inclination angle\n\n# Calculations\nu = G*M\nr = Re+h\nVi = math.sqrt(u/r*10**3)* math.tan(i*math.pi/180); # magnitude of velocity impulse\nV = Vi/1000; # magnitude of velocity impulse in m/s\n\n#Result\nprint 'Magnitude of velocity impulse = %d' %V,' m/s';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Magnitude of velocity impulse = 107 m/s\n" - } - ], - "prompt_number": 20 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 5, Pg No: 571" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\nh = float(13622); # ht of circular orbit from earth's surface\nRe = 6378; # Radius of earth in km\n\n# Calculations\nR = Re+h; # Radius of circular orbit\npimax = 180 - (2*math.acos(Re/R))*(180/math.pi); # Maximum shadow angle\neclipmax_time = (pimax/360)*24; # maximum daily eclipse duration\n\n# Result\nprint ' Maximum shadow angle = %3.1f\u00b0' %pimax\nprint ' Maximum daily eclipse duration = %3.2f'%eclipmax_time,' hours';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": " Maximum shadow angle = 37.2\u00b0\n Maximum daily eclipse duration = 2.48 hours\n" - } - ], - "prompt_number": 22 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 6, Pg No:572" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n\n# Variable Declaration\n\nh = 35786; # ht of geo.stationary orbit above earth surface\nT = 365; # time in days\nr = 6378 # radius of earth in km\n\n# ie(t) = 23.4*sin(2*%pi*t/T)\n# for a circular orbit of 20000 km radius ,phi = 37.4\u00b0 ,Therefore, the time from first day of eclipse to equinox is given by substituting ie(t) = 37.4/2 = 18.7\u00b0\nphi = 37.4\nie = (phi/2)*(math.pi/180)\nk = 23.4*(math.pi/180)\nt = (365/(2*math.pi))*math.asin((ie/k)) \n# for geostationary orbit\nphimax = 180 - 2*(math.acos(r/(r+h)))*(180/math.pi)\nt_geo = (365/(2*math.pi))*math.asin((8.7*math.pi/180)/k)\n\n# Result\nprint 'Total time from first day of eclipse to last day of eclipse = %3.1f' %t,' days';\nprint 'Total time from first day of eclipse to last day of eclipse for geostationary orbit = %3.2f' %t_geo, 'days'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Total time from first day of eclipse to last day of eclipse = 53.8 days\nTotal time from first day of eclipse to last day of eclipse for geostationary orbit = 22.13 days\n" - } - ], - "prompt_number": 24 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 7, Pg No:600" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\nm = 100; # mass of satellite\nV = 8000; # orbital velocity in m/s\nRe = 6370; # radius of earth in Km\nH = 200; # satellite height above earth surface\n\n# Calculations\nCF = (m*V**2)/((Re+H)*10**3); #centrifugal force\n\n# Result\nprint 'Centrifugal Force = %d' %CF,' Newtons';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Centrifugal Force = 974 Newtons\n" - } - ], - "prompt_number": 25 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 8, Pg No:601" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\n\nApogee = 30000; # Apogee pt of satellite elliptical orbit\nPerige = 1000; # perigee pt of satellite elliptical orbit\n\n# Calculations\na = (Apogee + Perige)/2; # semi major axis\n\n# Result\nprint 'Semi-major axis = %d' %a,' Km';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Semi-major axis = 15500 Km\n" - } - ], - "prompt_number": 26 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 9, Pg No:603" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math\n\n# Variable Declaration\nfarth = 30000; # farthest point in satellite elliptic eccentric orbit\nclosest = 200; # closest point in satellite elliptic eccentric orbit\nRe = float(6370); # Radius of earth in km\n\n# Calculations\nApogee = farth + Re; # Apogee in km\nPerigee = closest + Re; # perigee in km\na = (Apogee + Perigee)/(2); # semi-major axis\ne = (Apogee - Perigee)/(2*a); # orbit eccentricity\n\n# Result\nprint 'Apogee = %d' %Apogee,' km';\nprint 'Perigee = %d' %Perigee,' km';\nprint 'Orbit eccentricity = %3.3f' %e;", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Apogee = 36370 km\nPerigee = 6570 km\nOrbit eccentricity = 0.694\n" - } - ], - "prompt_number": 29 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 10, Pg No:604" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\ne = 0.5; # orbit eccentricity\nae = 14000; # from fig. the distance from center of ellipse to the centre of earth\n\n# Calculations\na = ae/(e); # semi major axis\napogee = a*(1 + e); # Apogee in km\nperige = a*(1 - e); # perigee in km\n\n# Result\nprint 'Apogee = %d' %apogee,' km'\nprint 'Perigee = %d' %perige,' km'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Apogee = 42000 km\nPerigee = 14000 km\n" - } - ], - "prompt_number": 34 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 11, Pg No:604" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nRe = 6370*10**3; # radius of earth in m\n\n# Calculations\nu = G*M\nVesc = math.sqrt(2*u/Re);\nVes = Vesc/1000; # escape velocity in km/s\n\n# Result\nprint 'Escape velocity = %3.1f' %Ves,' km/s';", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Escape velocity = 11.2 km/s\n" - } - ], - "prompt_number": 36 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 12, Pg No:605" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# variable Declartion\na = 25000*10**3; # semimajor axis in m from fig\nG = 6.67*10**-11; # Gravitational constant\nM = 5.98*10**24; # mass of the earth in kg\nh = 0\n\n# Calculations\nu = G*M;\nT = 2*math.pi*math.sqrt((a**3)/u)\nhr = T/3600 # conv. from sec to hrs and min\nt = T%3600 # conv. from sec to hrs and min\nmi = t/60 # conv. from sec to hrs and min\n\n# Result\nprint 'Orbital time period = %d' %hr,' Hours',' %d'%mi, 'minutes'", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Orbital time period = 10 Hours 55 minutes\n" - } - ], - "prompt_number": 41 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": "Example 13, Pg No:605" - }, - { - "cell_type": "code", - "collapsed": false, - "input": "import math;\n\n# Variable Declaration\napogee = float(35000); # farthest point in kms\nperigee = 500; # closest point in kms\nr = float(6360); # radius of earth in kms\nG = 6.67*10**-11 # gravitational constant\nM = 5.98*10**24; # mass of earth in kgs\n\n# calculations\n#funcprot(0)\napogee_dist = apogee + r # apogee distance in kms\nperigee_dist= perigee+r ; # perigee distance in kms\na = (apogee_dist + perigee_dist)/2; # semi-major axis of elliptical orbit\nT = (2*math.pi)*math.sqrt((a*10**3)**3/(G*M)); # orbital time period\nhr = T/3600 # conv. from sec to hrs and min\nt = (T%3600) # conv. from sec to hrs and min\nmi = t/60 # conv. from sec to hrs and min\nu = G*M\nVapogee = math.sqrt(u*((2/(apogee_dist*10**3)) - (1/(a*10**3))))/1000; # velocity at apogee point\nVperigee = math.sqrt((G*M)*((2/(perigee_dist*10**3)-(1/(a*10**3)))))/1000 # velocity at perigee point\n\n#Result\nprint 'Orbital Time Period = %d'%hr,' Hrs'' %d'%mi,' min'\nprint 'Velocity at apogee = %3.3f' %Vapogee,' Km/s'\nprint'Velocity at perigee = %3.3f' %Vperigee,' Km/s'\nprint'Note: Calculation mistake in textbook in finding velocity at apogee point'\n", - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": "Orbital Time Period = 10 Hrs 20 min\nVelocity at apogee = 1.656 Km/s\nVelocity at perigee = 9.987 Km/s\nNote: Calculation mistake in textbook in finding velocity at apogee point\n" - } - ], - "prompt_number": 57 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/srinivasparupalli/CHAPTER_1.ipynb b/sample_notebooks/srinivasparupalli/CHAPTER_1.ipynb deleted file mode 100755 index 1f882de6..00000000 --- a/sample_notebooks/srinivasparupalli/CHAPTER_1.ipynb +++ /dev/null @@ -1,347 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:80f88a972947f3f07c0690a368a00c796fad1cccb9df59741b4a8c03cd1e434e" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 1- FUNDAMENTAL CONCEPTS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.1- PG NO:4" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.1#\n", - "#clears the screen#\n", - "#clears the existing variables#\n", - "print('the locker door (Y) can be opened using one key (A) which is with you and the other key (B) which is with the bank executive. When both the keys are used, the locker door opens, i.e. the locker door can be opened (Y=1) only when both the keys are applied(A=B=1).Thus, this can be expressed as an AND operation')\n", - "print('Y=A*B')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the locker door (Y) can be opened using one key (A) which is with you and the other key (B) which is with the bank executive. When both the keys are used, the locker door opens, i.e. the locker door can be opened (Y=1) only when both the keys are applied(A=B=1).Thus, this can be expressed as an AND operation\n", - "Y=A*B\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.3 - PG NO.6" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.3#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('Let the temperature and pressure be converted into electrical signals and T=1 if temperature exceeds the specified limit and P=1 if pressure exceeds the specified limit. If T=1 or P=1 or both T and P are 1 then the alarm is required to be activated, i.e., the signal applied to the alarm Y=1. This operation can be expressed as an or operation.')\n", - "print('Y=T or P')\n", - "print('Y=T+P')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Let the temperature and pressure be converted into electrical signals and T=1 if temperature exceeds the specified limit and P=1 if pressure exceeds the specified limit. If T=1 or P=1 or both T and P are 1 then the alarm is required to be activated, i.e., the signal applied to the alarm Y=1. This operation can be expressed as an or operation.\n", - "Y=T or P\n", - "Y=T+P\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.7.a - PG NO:10" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.7(a)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when one of the logic input of 2-input NAND gate is 0, then irrespective of the other input, the output comes out to be 1. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 0')\n", - "print('Y=1')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when one of the logic input of 2-input NAND gate is 0, then irrespective of the other input, the output comes out to be 1. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 0\n", - "Y=1\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.7.b - PG NO:11" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.7(b)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when one of the logic input of 2-input NAND gate is 1, then when A=1, Y=0 and if A=0, Y=1')\n", - "print('Y= ~A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when one of the logic input of 2-input NAND gate is 1, then when A=1, Y=0 and if A=0, Y=1\n", - "Y= ~A\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.9.a - PG NO:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.9(a)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when one of the logic input of 2-input NOR gate is 0, then when A=1, Y=0 and if A=0, Y=1')\n", - "print('Y= ~A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when one of the logic input of 2-input NOR gate is 0, then when A=1, Y=0 and if A=0, Y=1\n", - "Y= ~A\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.9.b - PG NO:12" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.9(b)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when one of the logic input of 2-input NOR gate is 1, then irrespective of the other input, the output comes out to be 0. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 1')\n", - "print('Y=0')\n", - "print('here the output of Y is 0 irrespective of input of A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when one of the logic input of 2-input NOR gate is 1, then irrespective of the other input, the output comes out to be 0. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 1\n", - "Y=0\n", - "here the output of Y is 0 irrespective of input of A\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.11.a - PG NO:14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.11(a)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('If we connect one input of EX-OR gate to 0 permanently, we observe that Y=A*0+A*0')\n", - "print('thus, Y=A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "If we connect one input of EX-OR gate to 0 permanently, we observe that Y=A*0+A*0\n", - "thus, Y=A\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.11.b- PG NO:14" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.11(b)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('If we connect one input of EX-OR gate to 1 permanently, we observe that Y=A*1+A*1')\n", - "print('thus, Y= ~A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "If we connect one input of EX-OR gate to 1 permanently, we observe that Y=A*1+A*1\n", - "thus, Y= ~A\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.13.a - PG NO:15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.13(a)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('If we connect one input of EX-NOR gate to 0 permanently, we observe that Y=A*0+A*0')\n", - "print('thus, Y= ~A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "If we connect one input of EX-NOR gate to 0 permanently, we observe that Y=A*0+A*0\n", - "thus, Y= ~A\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 1.13.b- PG NO:15" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#example 1.13(b)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('If we connect one input of EX-NOR gate to 1 permanently, we observe that Y=A*1+A*1')\n", - "print('thus, Y=A')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "If we connect one input of EX-NOR gate to 1 permanently, we observe that Y=A*1+A*1\n", - "thus, Y=A\n" - ] - } - ], - "prompt_number": 10 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/srinivasparupalli/CHAPTER_3.ipynb b/sample_notebooks/srinivasparupalli/CHAPTER_3.ipynb deleted file mode 100755 index b5416e8b..00000000 --- a/sample_notebooks/srinivasparupalli/CHAPTER_3.ipynb +++ /dev/null @@ -1,310 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:f24ed387c9c220910a22c3b53359904a6b96b4e1c0307b247f6eff7ab0a91f27" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "CHAPTER 3 - Semiconductor devices switching mode operation" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.3 -PG NO.88" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.88\n", - "#example 3.3#\n", - "#clears the screen#\n", - "#clears already existing varibales#\n", - "a=10.#\n", - "#input voltage (in volts)#\n", - "b=.7#\n", - "#transistor voltage(saturation voltage)#\n", - "c=5.#\n", - "#resistor b/w input voltage and the transistor#\n", - "d=10.#\n", - "#input voltage from collector side#\n", - "e=0.1#\n", - "#transistor voltage(saturation voltage from collector side)#\n", - "f=2.#\n", - "#resistor in kilo-ohm#\n", - "g=30.#\n", - "h=-10.#\n", - "#input voltage from emitter side#\n", - "I=(a-b)/c#\n", - "#base current of transistor from given figure#\n", - "print('the base current of given circuit is (in mA):')\n", - "print(I)\n", - "#base current is in mA#\n", - "K=(d-e)/f\n", - "#collector current of transistor from given figure#\n", - "print('the collector current of given circuit is (in mA):')\n", - "print(round(K))\n", - "#collector current in mA(saturation current)#\n", - "L=K/g\n", - "print('base current required for the transistor to be in saturation is (in mA):')\n", - "print(L)\n", - "#current in mA#\n", - "M=(h-b)/c\n", - "print('the base current is (in mA):')\n", - "print(M)\n", - "#base current in mA#" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "the base current of given circuit is (in mA):\n", - "1.86\n", - "the collector current of given circuit is (in mA):\n", - "5.0\n", - "base current required for the transistor to be in saturation is (in mA):\n", - "0.165\n", - "the base current is (in mA):\n", - "-2.14\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.4.a- PG NO.95" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no. 95\n", - "#example 3.4(a)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when the input voltage V(i)= -5V, the JFET is opening at point A, where I(D)=0 and V(0)=V(DD)=20V')\n", - "print('this corresponds to the switch in OFF state')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when the input voltage V(i)= -5V, the JFET is opening at point A, where I(D)=0 and V(0)=V(DD)=20V\n", - "this corresponds to the switch in OFF state\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.4.b- PG NO. 95" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no. 95\n", - "#example 3.4(b)#\n", - "#clears the screen#\n", - "#clears the command window#\n", - "print('when V(i)=0V, the JFET is operating at point B, where I(D)=3.8mA and V(0)=1V')\n", - "print('this corresponds to the switch in ON state')\n", - "#the answers have been taken directly from the figure#" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when V(i)=0V, the JFET is operating at point B, where I(D)=3.8mA and V(0)=1V\n", - "this corresponds to the switch in ON state\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.5.a - PG NO.96" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no. 96\n", - "#example 3.5(a)#\n", - "#clears the window#\n", - "#clears already existing variables#\n", - "print('when V(i)=0, the transistor is cutoff because the voltage between the gate and the source is below the threshold voltage. Correspondingly the output voltage V(0)=5V(point (N) as in figure)')\n", - "#answer according to the cuts of load line#" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when V(i)=0, the transistor is cutoff because the voltage between the gate and the source is below the threshold voltage. Correspondingly the output voltage V(0)=5V(point (N) as in figure)\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.5.b -PG NO.96" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page 96\n", - "#example 3.5(b)#\n", - "#clears the window#\n", - "#clears already existing variables#\n", - "print('when V(i)=5V, the transistor is operating at point M and V(0)=0')\n", - "print('this corresponds to ON state!')" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when V(i)=5V, the transistor is operating at point M and V(0)=0\n", - "this corresponds to ON state!\n" - ] - } - ], - "prompt_number": 5 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.7.a - PG NO. 97" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no. 97\n", - "#example 3.7(a)#\n", - "#clears the screen#\n", - "#clears existing variables#\n", - "print('when V(i)=0, the transistor T(1) is operating at point B')\n", - "t=5.#\n", - "#input voltage as given in question#\n", - "x=0.#\n", - "V=t-x#\n", - "#output voltage in volts#\n", - "print('here V(0)(in volts)=')\n", - "print(V)" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when V(i)=0, the transistor T(1) is operating at point B\n", - "here V(0)(in volts)=\n", - "5.0\n" - ] - } - ], - "prompt_number": 6 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "EXAMPLE 3.7.b - PG NO. 97" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no.97\n", - "#example 3.7(b)#\n", - "#clears the screen#\n", - "#clears already existing variables#\n", - "print('when V(i)=5V, the transistor T(1) is operating at point C')\n", - "V=0#\n", - "print('output voltage in volts=')\n", - "print(V)\n", - "#all the outcomes are as per the diagram#" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "when V(i)=5V, the transistor T(1) is operating at point C\n", - "output voltage in volts=\n", - "0\n" - ] - } - ], - "prompt_number": 8 - }, - { - "cell_type": "code", - "collapsed": false, - "input": [], - "language": "python", - "metadata": {}, - "outputs": [] - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_1.ipynb b/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_1.ipynb new file mode 100755 index 00000000..1f882de6 --- /dev/null +++ b/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_1.ipynb @@ -0,0 +1,347 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:80f88a972947f3f07c0690a368a00c796fad1cccb9df59741b4a8c03cd1e434e" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 1- FUNDAMENTAL CONCEPTS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.1- PG NO:4" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.1#\n", + "#clears the screen#\n", + "#clears the existing variables#\n", + "print('the locker door (Y) can be opened using one key (A) which is with you and the other key (B) which is with the bank executive. When both the keys are used, the locker door opens, i.e. the locker door can be opened (Y=1) only when both the keys are applied(A=B=1).Thus, this can be expressed as an AND operation')\n", + "print('Y=A*B')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the locker door (Y) can be opened using one key (A) which is with you and the other key (B) which is with the bank executive. When both the keys are used, the locker door opens, i.e. the locker door can be opened (Y=1) only when both the keys are applied(A=B=1).Thus, this can be expressed as an AND operation\n", + "Y=A*B\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.3 - PG NO.6" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.3#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('Let the temperature and pressure be converted into electrical signals and T=1 if temperature exceeds the specified limit and P=1 if pressure exceeds the specified limit. If T=1 or P=1 or both T and P are 1 then the alarm is required to be activated, i.e., the signal applied to the alarm Y=1. This operation can be expressed as an or operation.')\n", + "print('Y=T or P')\n", + "print('Y=T+P')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Let the temperature and pressure be converted into electrical signals and T=1 if temperature exceeds the specified limit and P=1 if pressure exceeds the specified limit. If T=1 or P=1 or both T and P are 1 then the alarm is required to be activated, i.e., the signal applied to the alarm Y=1. This operation can be expressed as an or operation.\n", + "Y=T or P\n", + "Y=T+P\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.7.a - PG NO:10" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.7(a)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when one of the logic input of 2-input NAND gate is 0, then irrespective of the other input, the output comes out to be 1. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 0')\n", + "print('Y=1')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when one of the logic input of 2-input NAND gate is 0, then irrespective of the other input, the output comes out to be 1. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 0\n", + "Y=1\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.7.b - PG NO:11" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.7(b)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when one of the logic input of 2-input NAND gate is 1, then when A=1, Y=0 and if A=0, Y=1')\n", + "print('Y= ~A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when one of the logic input of 2-input NAND gate is 1, then when A=1, Y=0 and if A=0, Y=1\n", + "Y= ~A\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.9.a - PG NO:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.9(a)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when one of the logic input of 2-input NOR gate is 0, then when A=1, Y=0 and if A=0, Y=1')\n", + "print('Y= ~A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when one of the logic input of 2-input NOR gate is 0, then when A=1, Y=0 and if A=0, Y=1\n", + "Y= ~A\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.9.b - PG NO:12" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.9(b)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when one of the logic input of 2-input NOR gate is 1, then irrespective of the other input, the output comes out to be 0. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 1')\n", + "print('Y=0')\n", + "print('here the output of Y is 0 irrespective of input of A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when one of the logic input of 2-input NOR gate is 1, then irrespective of the other input, the output comes out to be 0. In fact, a NAND gate is disabled or inhibited if one of its inputs is connected to logic 1\n", + "Y=0\n", + "here the output of Y is 0 irrespective of input of A\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.11.a - PG NO:14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.11(a)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('If we connect one input of EX-OR gate to 0 permanently, we observe that Y=A*0+A*0')\n", + "print('thus, Y=A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "If we connect one input of EX-OR gate to 0 permanently, we observe that Y=A*0+A*0\n", + "thus, Y=A\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.11.b- PG NO:14" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.11(b)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('If we connect one input of EX-OR gate to 1 permanently, we observe that Y=A*1+A*1')\n", + "print('thus, Y= ~A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "If we connect one input of EX-OR gate to 1 permanently, we observe that Y=A*1+A*1\n", + "thus, Y= ~A\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.13.a - PG NO:15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.13(a)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('If we connect one input of EX-NOR gate to 0 permanently, we observe that Y=A*0+A*0')\n", + "print('thus, Y= ~A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "If we connect one input of EX-NOR gate to 0 permanently, we observe that Y=A*0+A*0\n", + "thus, Y= ~A\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 1.13.b- PG NO:15" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#example 1.13(b)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('If we connect one input of EX-NOR gate to 1 permanently, we observe that Y=A*1+A*1')\n", + "print('thus, Y=A')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "If we connect one input of EX-NOR gate to 1 permanently, we observe that Y=A*1+A*1\n", + "thus, Y=A\n" + ] + } + ], + "prompt_number": 10 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_3.ipynb b/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_3.ipynb new file mode 100755 index 00000000..b5416e8b --- /dev/null +++ b/sample_notebooks/srinivasparupalli/srinivasparupalli_version_backup/CHAPTER_3.ipynb @@ -0,0 +1,310 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:f24ed387c9c220910a22c3b53359904a6b96b4e1c0307b247f6eff7ab0a91f27" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "CHAPTER 3 - Semiconductor devices switching mode operation" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.3 -PG NO.88" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.88\n", + "#example 3.3#\n", + "#clears the screen#\n", + "#clears already existing varibales#\n", + "a=10.#\n", + "#input voltage (in volts)#\n", + "b=.7#\n", + "#transistor voltage(saturation voltage)#\n", + "c=5.#\n", + "#resistor b/w input voltage and the transistor#\n", + "d=10.#\n", + "#input voltage from collector side#\n", + "e=0.1#\n", + "#transistor voltage(saturation voltage from collector side)#\n", + "f=2.#\n", + "#resistor in kilo-ohm#\n", + "g=30.#\n", + "h=-10.#\n", + "#input voltage from emitter side#\n", + "I=(a-b)/c#\n", + "#base current of transistor from given figure#\n", + "print('the base current of given circuit is (in mA):')\n", + "print(I)\n", + "#base current is in mA#\n", + "K=(d-e)/f\n", + "#collector current of transistor from given figure#\n", + "print('the collector current of given circuit is (in mA):')\n", + "print(round(K))\n", + "#collector current in mA(saturation current)#\n", + "L=K/g\n", + "print('base current required for the transistor to be in saturation is (in mA):')\n", + "print(L)\n", + "#current in mA#\n", + "M=(h-b)/c\n", + "print('the base current is (in mA):')\n", + "print(M)\n", + "#base current in mA#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "the base current of given circuit is (in mA):\n", + "1.86\n", + "the collector current of given circuit is (in mA):\n", + "5.0\n", + "base current required for the transistor to be in saturation is (in mA):\n", + "0.165\n", + "the base current is (in mA):\n", + "-2.14\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.4.a- PG NO.95" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no. 95\n", + "#example 3.4(a)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when the input voltage V(i)= -5V, the JFET is opening at point A, where I(D)=0 and V(0)=V(DD)=20V')\n", + "print('this corresponds to the switch in OFF state')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when the input voltage V(i)= -5V, the JFET is opening at point A, where I(D)=0 and V(0)=V(DD)=20V\n", + "this corresponds to the switch in OFF state\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.4.b- PG NO. 95" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no. 95\n", + "#example 3.4(b)#\n", + "#clears the screen#\n", + "#clears the command window#\n", + "print('when V(i)=0V, the JFET is operating at point B, where I(D)=3.8mA and V(0)=1V')\n", + "print('this corresponds to the switch in ON state')\n", + "#the answers have been taken directly from the figure#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when V(i)=0V, the JFET is operating at point B, where I(D)=3.8mA and V(0)=1V\n", + "this corresponds to the switch in ON state\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.5.a - PG NO.96" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no. 96\n", + "#example 3.5(a)#\n", + "#clears the window#\n", + "#clears already existing variables#\n", + "print('when V(i)=0, the transistor is cutoff because the voltage between the gate and the source is below the threshold voltage. Correspondingly the output voltage V(0)=5V(point (N) as in figure)')\n", + "#answer according to the cuts of load line#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when V(i)=0, the transistor is cutoff because the voltage between the gate and the source is below the threshold voltage. Correspondingly the output voltage V(0)=5V(point (N) as in figure)\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.5.b -PG NO.96" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page 96\n", + "#example 3.5(b)#\n", + "#clears the window#\n", + "#clears already existing variables#\n", + "print('when V(i)=5V, the transistor is operating at point M and V(0)=0')\n", + "print('this corresponds to ON state!')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when V(i)=5V, the transistor is operating at point M and V(0)=0\n", + "this corresponds to ON state!\n" + ] + } + ], + "prompt_number": 5 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.7.a - PG NO. 97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no. 97\n", + "#example 3.7(a)#\n", + "#clears the screen#\n", + "#clears existing variables#\n", + "print('when V(i)=0, the transistor T(1) is operating at point B')\n", + "t=5.#\n", + "#input voltage as given in question#\n", + "x=0.#\n", + "V=t-x#\n", + "#output voltage in volts#\n", + "print('here V(0)(in volts)=')\n", + "print(V)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when V(i)=0, the transistor T(1) is operating at point B\n", + "here V(0)(in volts)=\n", + "5.0\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "EXAMPLE 3.7.b - PG NO. 97" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no.97\n", + "#example 3.7(b)#\n", + "#clears the screen#\n", + "#clears already existing variables#\n", + "print('when V(i)=5V, the transistor T(1) is operating at point C')\n", + "V=0#\n", + "print('output voltage in volts=')\n", + "print(V)\n", + "#all the outcomes are as per the diagram#" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "when V(i)=5V, the transistor T(1) is operating at point C\n", + "output voltage in volts=\n", + "0\n" + ] + } + ], + "prompt_number": 8 + }, + { + "cell_type": "code", + "collapsed": false, + "input": [], + "language": "python", + "metadata": {}, + "outputs": [] + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/sriragap/CHAPTER_2.ipynb b/sample_notebooks/sriragap/CHAPTER_2.ipynb deleted file mode 100755 index 426e33a5..00000000 --- a/sample_notebooks/sriragap/CHAPTER_2.ipynb +++ /dev/null @@ -1,294 +0,0 @@ -{ - "metadata": { - "name": "", - "signature": "sha256:5bde2d708f0f6314a9ce2bbaebd8be7d8b932147d24c3a735ae61026c957a8a8" - }, - "nbformat": 3, - "nbformat_minor": 0, - "worksheets": [ - { - "cells": [ - { - "cell_type": "heading", - "level": 1, - "metadata": {}, - "source": [ - "Chapter 2-MICROPROCESSOR ARCHITECHTURE AND MICROCOMPUTER SYSTEMS" - ] - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E1-Pg 39" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "#page no 39\n", - "#example no 2.1\n", - "#MEMORY ADDRESS RANGE.\n", - "print ('A7-A0 are address lines for register select. \\n');\n", - "print ('A15-A8 are address lines for chip select. \\n \\n');\n", - "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", - "print (' 0 0 0 0 0 0 0 0 =00H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", - "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", - "print (' 0 0 0 0 0 0 0 0 =00H \\n'); #this selects the register 00.\n", - "print ('The above combination selects the memory address 0000H. \\n \\n');\n", - "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", - "print (' 0 0 0 0 0 0 0 0 =00H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", - "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", - "print (' 1 1 1 1 1 1 1 1 =FFH \\n'); #this selects the register FF.\n", - "print ('The above combination selects the memory address 00FFH. \\n \\n');\n", - "#thus this chip can select any memory location from 0000H to 00FFH.\n", - "#the memory addressed of the chip can be changed by modifying the hardware.For example if we remove the inverter on line A15.\n", - "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", - "print (' 1 0 0 0 0 0 0 0 =80H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", - "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", - "print (' 0 0 0 0 0 0 0 0 =00H \\n'); #this selects the register 00.\n", - "print ('The above combination selects the memory address 8000H. \\n \\n');\n", - "#The memory address range from above change will be 8000H to 80FFH.\n", - "#Thus a memory can be assigned address in various locations over the entire map of 0000H to FFFFH.\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "A7-A0 are address lines for register select. \n", - "\n", - "A15-A8 are address lines for chip select. \n", - " \n", - "\n", - "A15 A14 A13 A12 A11 A10 A9 A8 \n", - "\n", - " 0 0 0 0 0 0 0 0 =00H \n", - " \n", - "\n", - "A7 A6 A5 A4 A3 A2 A1 A0 \n", - "\n", - " 0 0 0 0 0 0 0 0 =00H \n", - "\n", - "The above combination selects the memory address 0000H. \n", - " \n", - "\n", - "A15 A14 A13 A12 A11 A10 A9 A8 \n", - "\n", - " 0 0 0 0 0 0 0 0 =00H \n", - " \n", - "\n", - "A7 A6 A5 A4 A3 A2 A1 A0 \n", - "\n", - " 1 1 1 1 1 1 1 1 =FFH \n", - "\n", - "The above combination selects the memory address 00FFH. \n", - " \n", - "\n", - "A15 A14 A13 A12 A11 A10 A9 A8 \n", - "\n", - " 1 0 0 0 0 0 0 0 =80H \n", - " \n", - "\n", - "A7 A6 A5 A4 A3 A2 A1 A0 \n", - "\n", - " 0 0 0 0 0 0 0 0 =00H \n", - "\n", - "The above combination selects the memory address 8000H. \n", - " \n", - "\n" - ] - } - ], - "prompt_number": 1 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E2-Pg 41" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##page no 41\n", - "##example no 2.2\n", - "##MEMORY ADDRESS RANGE.\n", - "print ('A9-A0 are address lines for register select. \\n');\n", - "print ('A15-A10 are address lines for chip select. \\n \\n');\n", - "print ('A15 A14 A13 A12 A11 A10 \\n');\n", - "print (' 0 0 0 0 0 0 \\n \\n'); ##chip select bits have to be active low always to select that chip.\n", - "print ('A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", - "print (' 0 0 0 0 0 0 0 0 0 0 \\n'); ##this selects the register \n", - "print ('The above combination selects the memory address 0000H. \\n \\n');\n", - "print ('A15 A14 A13 A12 A11 A10 \\n');\n", - "print (' 0 0 0 0 0 0 \\n \\n'); ##chip select bits have to be active low always to select that chip.\n", - "print ('A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", - "print (' 1 1 1 1 1 1 1 1 1 1 \\n'); ##this selects the register \n", - "print ('The above combination selects the memory address 03FFH. \\n \\n');\n", - "##thus this chip can select any memory location from 0000H to 03FFH.\n", - "##the memory addressed of the chip can be changed by modifying the hardware.Like we did in the previous example.\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "A9-A0 are address lines for register select. \n", - "\n", - "A15-A10 are address lines for chip select. \n", - " \n", - "\n", - "A15 A14 A13 A12 A11 A10 \n", - "\n", - " 0 0 0 0 0 0 \n", - " \n", - "\n", - "A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \n", - "\n", - " 0 0 0 0 0 0 0 0 0 0 \n", - "\n", - "The above combination selects the memory address 0000H. \n", - " \n", - "\n", - "A15 A14 A13 A12 A11 A10 \n", - "\n", - " 0 0 0 0 0 0 \n", - " \n", - "\n", - "A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \n", - "\n", - " 1 1 1 1 1 1 1 1 1 1 \n", - "\n", - "The above combination selects the memory address 03FFH. \n", - " \n", - "\n" - ] - } - ], - "prompt_number": 2 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E3-Pg 43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##page no 43\n", - "##example no 2.3\n", - "##CALCULATING ADDRESS LINES\n", - "##number of address lines are given by x\n", - "import math\n", - "x=(math.log(8192))/(math.log(2));\n", - "print ('Number of address lines= ')\n", - "print (x);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Number of address lines= \n", - "13.0\n" - ] - } - ], - "prompt_number": 3 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E4-Pg 43" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##page no 43\n", - "##example no 2.4\n", - "##CALCULATING NO OF CHIPS.\n", - "##chip 1024*1 has 1024(1k) registers & each register can store one bit with one data line. We need 8 data lines for byte size memory. Therefore 8 chips are necessary for 1k byte memory.For 1k byte memory we will need 64 chips. We can arrive at the same ans by dividing 8k byte by 1k*1 as follows:\n", - "import math\n", - "no=(8192*8)/(1024*1);\n", - "print ('No of chips= ');\n", - "print (no);\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "No of chips= \n", - "64\n" - ] - } - ], - "prompt_number": 4 - }, - { - "cell_type": "heading", - "level": 2, - "metadata": {}, - "source": [ - "Example E5-Pg 44" - ] - }, - { - "cell_type": "code", - "collapsed": false, - "input": [ - "##page no 44\n", - "##example no 2.5\n", - "##FETCHING AN INSTRUCTION.\n", - "print ('Memory Location 2005H= 4FH \\n');\n", - "print ('Address bus= 2005H \\n') ##program counter places the 16-bit address on the address bus.\n", - "print ('Control bus--> (MEMR) \\n'); ##control bus sends memory read control signal.\n", - "print ('Data bus= 4FH \\n'); ##instruction 4FH is fetched and transferred to instruction decoder.\n" - ], - "language": "python", - "metadata": {}, - "outputs": [ - { - "output_type": "stream", - "stream": "stdout", - "text": [ - "Memory Location 2005H= 4FH \n", - "\n", - "Address bus= 2005H \n", - "\n", - "Control bus--> (MEMR) \n", - "\n", - "Data bus= 4FH \n", - "\n" - ] - } - ], - "prompt_number": 5 - } - ], - "metadata": {} - } - ] -} \ No newline at end of file diff --git a/sample_notebooks/sriragap/sriragap_version_backup/CHAPTER_2.ipynb b/sample_notebooks/sriragap/sriragap_version_backup/CHAPTER_2.ipynb new file mode 100755 index 00000000..426e33a5 --- /dev/null +++ b/sample_notebooks/sriragap/sriragap_version_backup/CHAPTER_2.ipynb @@ -0,0 +1,294 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:5bde2d708f0f6314a9ce2bbaebd8be7d8b932147d24c3a735ae61026c957a8a8" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 2-MICROPROCESSOR ARCHITECHTURE AND MICROCOMPUTER SYSTEMS" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E1-Pg 39" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "#page no 39\n", + "#example no 2.1\n", + "#MEMORY ADDRESS RANGE.\n", + "print ('A7-A0 are address lines for register select. \\n');\n", + "print ('A15-A8 are address lines for chip select. \\n \\n');\n", + "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", + "print (' 0 0 0 0 0 0 0 0 =00H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", + "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", + "print (' 0 0 0 0 0 0 0 0 =00H \\n'); #this selects the register 00.\n", + "print ('The above combination selects the memory address 0000H. \\n \\n');\n", + "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", + "print (' 0 0 0 0 0 0 0 0 =00H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", + "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", + "print (' 1 1 1 1 1 1 1 1 =FFH \\n'); #this selects the register FF.\n", + "print ('The above combination selects the memory address 00FFH. \\n \\n');\n", + "#thus this chip can select any memory location from 0000H to 00FFH.\n", + "#the memory addressed of the chip can be changed by modifying the hardware.For example if we remove the inverter on line A15.\n", + "print ('A15 A14 A13 A12 A11 A10 A9 A8 \\n');\n", + "print (' 1 0 0 0 0 0 0 0 =80H \\n \\n'); #chip select bits have to be active low always to select that chip.\n", + "print ('A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", + "print (' 0 0 0 0 0 0 0 0 =00H \\n'); #this selects the register 00.\n", + "print ('The above combination selects the memory address 8000H. \\n \\n');\n", + "#The memory address range from above change will be 8000H to 80FFH.\n", + "#Thus a memory can be assigned address in various locations over the entire map of 0000H to FFFFH.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A7-A0 are address lines for register select. \n", + "\n", + "A15-A8 are address lines for chip select. \n", + " \n", + "\n", + "A15 A14 A13 A12 A11 A10 A9 A8 \n", + "\n", + " 0 0 0 0 0 0 0 0 =00H \n", + " \n", + "\n", + "A7 A6 A5 A4 A3 A2 A1 A0 \n", + "\n", + " 0 0 0 0 0 0 0 0 =00H \n", + "\n", + "The above combination selects the memory address 0000H. \n", + " \n", + "\n", + "A15 A14 A13 A12 A11 A10 A9 A8 \n", + "\n", + " 0 0 0 0 0 0 0 0 =00H \n", + " \n", + "\n", + "A7 A6 A5 A4 A3 A2 A1 A0 \n", + "\n", + " 1 1 1 1 1 1 1 1 =FFH \n", + "\n", + "The above combination selects the memory address 00FFH. \n", + " \n", + "\n", + "A15 A14 A13 A12 A11 A10 A9 A8 \n", + "\n", + " 1 0 0 0 0 0 0 0 =80H \n", + " \n", + "\n", + "A7 A6 A5 A4 A3 A2 A1 A0 \n", + "\n", + " 0 0 0 0 0 0 0 0 =00H \n", + "\n", + "The above combination selects the memory address 8000H. \n", + " \n", + "\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E2-Pg 41" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##page no 41\n", + "##example no 2.2\n", + "##MEMORY ADDRESS RANGE.\n", + "print ('A9-A0 are address lines for register select. \\n');\n", + "print ('A15-A10 are address lines for chip select. \\n \\n');\n", + "print ('A15 A14 A13 A12 A11 A10 \\n');\n", + "print (' 0 0 0 0 0 0 \\n \\n'); ##chip select bits have to be active low always to select that chip.\n", + "print ('A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", + "print (' 0 0 0 0 0 0 0 0 0 0 \\n'); ##this selects the register \n", + "print ('The above combination selects the memory address 0000H. \\n \\n');\n", + "print ('A15 A14 A13 A12 A11 A10 \\n');\n", + "print (' 0 0 0 0 0 0 \\n \\n'); ##chip select bits have to be active low always to select that chip.\n", + "print ('A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \\n');\n", + "print (' 1 1 1 1 1 1 1 1 1 1 \\n'); ##this selects the register \n", + "print ('The above combination selects the memory address 03FFH. \\n \\n');\n", + "##thus this chip can select any memory location from 0000H to 03FFH.\n", + "##the memory addressed of the chip can be changed by modifying the hardware.Like we did in the previous example.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "A9-A0 are address lines for register select. \n", + "\n", + "A15-A10 are address lines for chip select. \n", + " \n", + "\n", + "A15 A14 A13 A12 A11 A10 \n", + "\n", + " 0 0 0 0 0 0 \n", + " \n", + "\n", + "A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \n", + "\n", + " 0 0 0 0 0 0 0 0 0 0 \n", + "\n", + "The above combination selects the memory address 0000H. \n", + " \n", + "\n", + "A15 A14 A13 A12 A11 A10 \n", + "\n", + " 0 0 0 0 0 0 \n", + " \n", + "\n", + "A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 \n", + "\n", + " 1 1 1 1 1 1 1 1 1 1 \n", + "\n", + "The above combination selects the memory address 03FFH. \n", + " \n", + "\n" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E3-Pg 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##page no 43\n", + "##example no 2.3\n", + "##CALCULATING ADDRESS LINES\n", + "##number of address lines are given by x\n", + "import math\n", + "x=(math.log(8192))/(math.log(2));\n", + "print ('Number of address lines= ')\n", + "print (x);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Number of address lines= \n", + "13.0\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E4-Pg 43" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##page no 43\n", + "##example no 2.4\n", + "##CALCULATING NO OF CHIPS.\n", + "##chip 1024*1 has 1024(1k) registers & each register can store one bit with one data line. We need 8 data lines for byte size memory. Therefore 8 chips are necessary for 1k byte memory.For 1k byte memory we will need 64 chips. We can arrive at the same ans by dividing 8k byte by 1k*1 as follows:\n", + "import math\n", + "no=(8192*8)/(1024*1);\n", + "print ('No of chips= ');\n", + "print (no);\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "No of chips= \n", + "64\n" + ] + } + ], + "prompt_number": 4 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example E5-Pg 44" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "##page no 44\n", + "##example no 2.5\n", + "##FETCHING AN INSTRUCTION.\n", + "print ('Memory Location 2005H= 4FH \\n');\n", + "print ('Address bus= 2005H \\n') ##program counter places the 16-bit address on the address bus.\n", + "print ('Control bus--> (MEMR) \\n'); ##control bus sends memory read control signal.\n", + "print ('Data bus= 4FH \\n'); ##instruction 4FH is fetched and transferred to instruction decoder.\n" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Memory Location 2005H= 4FH \n", + "\n", + "Address bus= 2005H \n", + "\n", + "Control bus--> (MEMR) \n", + "\n", + "Data bus= 4FH \n", + "\n" + ] + } + ], + "prompt_number": 5 + } + ], + "metadata": {} + } + ] +} \ No newline at end of file diff --git a/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power.ipynb b/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power.ipynb new file mode 100755 index 00000000..379da0ca --- /dev/null +++ b/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power.ipynb @@ -0,0 +1,265 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5 Force Torque and Shaft power Measurement" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_1 pgno:204" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "x=(Sg*sig_f*(1+v))/(2*E)\n", + "('a voltmeter with a maximum range of mV is suitable for measurement', 94.9385766342288)\n", + "Round it off to get the suitable range voltmeter\n" + ] + } + ], + "source": [ + "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", + "#Caption : Load cell\n", + "# Example 1# Page 294\n", + "from math import sqrt\n", + "\n", + "Sg=2.; # Strain gage factor\n", + "Rg=120.; # Gage resistance\n", + "v=0.3 # poissons ratio\n", + "E=210*10**9; # for steel\n", + "Pd=1. #('enter the power dissipation capacity=:')\n", + "# Looking for a suitable voltage measuring system\n", + "sig_f=700*10**6 #('enter the fatigue strength=:')\n", + "P_max=10000. #('enter the maximum load=:')\n", + "# For a load cell of square cross-section d,\n", + "d=sqrt(P_max/sig_f);\n", + "Ei=sqrt(4*Rg*Pd) #input excitation to the bridge circuit\n", + "x=(Sg*sig_f*(1+v))/(2*E);\n", + "dEo_max=x*Ei*10**3;\n", + "print (\"x=(Sg*sig_f*(1+v))/(2*E)\")\n", + "print ('a voltmeter with a maximum range of mV is suitable for measurement',dEo_max)\n", + "print (\"Round it off to get the suitable range voltmeter\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_2 pgno:295" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('(dE/V)_max= d\\n ', 4285714.285714285)\n", + "Sensitivity of this load cell is nV/N/per unit excitation 42.8571428571\n" + ] + } + ], + "source": [ + "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", + "#Caption : Load cell\n", + "# Example 2# Page 295\n", + "\n", + "b=.2 #('enter the width of load cell=:')\n", + "h=.05 #('enter the thickness of load cell=:')\n", + "Sg=2.;\n", + "Rg=120.;\n", + "sig_f=150*10**6 #('enter the fatigue strength=:')\n", + "E=70.; #(in GPa) for aluminium\n", + "v=0.33; #poissons ratio\n", + "# Let dE/V_max be represented by W\n", + "W=Sg*sig_f/E;\n", + "print('(dE/V)_max= d\\n ',W)\n", + "P_max=100000. #('enter the value of maximum load=:')\n", + "l=sig_f*b*h**2/(6*P_max);\n", + "\n", + "S=(6*Sg*l)/(E*b*h**2);\n", + "print'Sensitivity of this load cell is nV/N/per unit excitation',S\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_3 pgno:296" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Sensitivity of this load cell is micro V/N\n", + "0.13\n", + "The maximum density that can be achieved without endangering the strain gage sensors is micro V/N\n", + "0.284815729903\n", + "The voltage ratio is mV/V 3.9\n" + ] + } + ], + "source": [ + "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", + "#Caption : Load cell\n", + "# Example 3# Page 296\n", + "from math import sqrt\n", + "Sg=2;\n", + "v=0.3; #poissons ratio\n", + "Ei=10. #('enter the excitation voltage=:')\n", + "A=5*10**-4 #('enter the area of load cell=:')\n", + "E=200.; #(in Gpa) Youngs modulus\n", + "# Let sensitivity Eo/P be represented by Se\n", + "Se=Sg*(1+v)*Ei/(2*A*E)*.001;\n", + "print'Sensitivity of this load cell is micro V/N\\n',Se\n", + "Rg=120. #given\n", + "Pd=1. #('enter the power dissipated in each gage=:')\n", + "Ei_max=sqrt(4*Rg*Pd)\n", + "Se_max=Sg*(1+v)*Ei_max/(2*A*E)*.001\n", + "print'The maximum density that can be achieved without endangering the strain gage sensors is micro V/N\\n',Se_max\n", + "# Let (Eo/Ei)_max be represented by Em\n", + "sig_f=600*10**6 #('enter the fatigue strength=:')\n", + "Em=Sg*sig_f*(1+v)/(2*E)*10**-6\n", + "print'The voltage ratio is mV/V',Em\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_4 pgno:302" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "('Relative displacement is d', 1.9999999999999997e-08)\n", + "wnc**2 is approx. 10**9. So,\n", + "Z is approx. 20nm(rms)\n", + "Actual force transmitted to the plate is d N 18.0260791198\n" + ] + } + ], + "source": [ + "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", + "#Caption : Piezoelectric Transducers\n", + "# Example 4# Page 302\n", + "from math import sqrt,pi\n", + "mc=0.04 #('enter the connector mass=:')\n", + "m=0.01 #('enter the seismic mass=:')\n", + "k=10**9 #('enter the stiffness of the sensing element=:')\n", + "Sf=.005 #('enter the sensitivity of the transducer=:')\n", + "Xi=100*10**-6 # ('enter the displacement amplitude of the shaker vibration=:')\n", + "Eo=.1 #('enter the reading of voltage recorder connected to the transducer=:')\n", + "wnc=sqrt(k/(m+mc));\n", + "R=20; #20N (rms)\n", + "Z=(1/(m+mc))*(1/wnc**2)*R;\n", + "print('Relative displacement is d',Z)\n", + "print(\"wnc**2 is approx. 10**9. So,\")\n", + "print(\"Z is approx. 20nm(rms)\")\n", + "f=100.; # given\n", + "\n", + "F=R-((2*pi*f)**2*(m+mc)*Xi);\n", + "print'Actual force transmitted to the plate is d N',F\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_5 pgno:308" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The load torque is d N-m 1636.24617374\n" + ] + } + ], + "source": [ + "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", + "#Caption : Torque measurement on rotating shaft\n", + "# Example 5# Page 308\n", + "Sg=2.;\n", + "Rg=120.;\n", + "G=80*10**9 #('enter the sheer modulus of elasticity=:')\n", + "D=0.05 #('enter the shaft diameter=:')\n", + "dR=0.1 # given\n", + "# we have to find the load torque\n", + "from math import pi\n", + "\n", + "y=2*dR/(Rg*Sg);\n", + "tou_xy=y*G;\n", + "j=pi*D**4;\n", + "T=tou_xy*2*j/(D*32);\n", + "print'The load torque is d N-m',T" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power_Measurement.ipynb b/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power_Measurement.ipynb deleted file mode 100755 index 379da0ca..00000000 --- a/sample_notebooks/vijayadurga/Chapter_5_Force_Torque_and_Shaft_power_Measurement.ipynb +++ /dev/null @@ -1,265 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 5 Force Torque and Shaft power Measurement" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_1 pgno:204" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "x=(Sg*sig_f*(1+v))/(2*E)\n", - "('a voltmeter with a maximum range of mV is suitable for measurement', 94.9385766342288)\n", - "Round it off to get the suitable range voltmeter\n" - ] - } - ], - "source": [ - "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", - "#Caption : Load cell\n", - "# Example 1# Page 294\n", - "from math import sqrt\n", - "\n", - "Sg=2.; # Strain gage factor\n", - "Rg=120.; # Gage resistance\n", - "v=0.3 # poissons ratio\n", - "E=210*10**9; # for steel\n", - "Pd=1. #('enter the power dissipation capacity=:')\n", - "# Looking for a suitable voltage measuring system\n", - "sig_f=700*10**6 #('enter the fatigue strength=:')\n", - "P_max=10000. #('enter the maximum load=:')\n", - "# For a load cell of square cross-section d,\n", - "d=sqrt(P_max/sig_f);\n", - "Ei=sqrt(4*Rg*Pd) #input excitation to the bridge circuit\n", - "x=(Sg*sig_f*(1+v))/(2*E);\n", - "dEo_max=x*Ei*10**3;\n", - "print (\"x=(Sg*sig_f*(1+v))/(2*E)\")\n", - "print ('a voltmeter with a maximum range of mV is suitable for measurement',dEo_max)\n", - "print (\"Round it off to get the suitable range voltmeter\")" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_2 pgno:295" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('(dE/V)_max= d\\n ', 4285714.285714285)\n", - "Sensitivity of this load cell is nV/N/per unit excitation 42.8571428571\n" - ] - } - ], - "source": [ - "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", - "#Caption : Load cell\n", - "# Example 2# Page 295\n", - "\n", - "b=.2 #('enter the width of load cell=:')\n", - "h=.05 #('enter the thickness of load cell=:')\n", - "Sg=2.;\n", - "Rg=120.;\n", - "sig_f=150*10**6 #('enter the fatigue strength=:')\n", - "E=70.; #(in GPa) for aluminium\n", - "v=0.33; #poissons ratio\n", - "# Let dE/V_max be represented by W\n", - "W=Sg*sig_f/E;\n", - "print('(dE/V)_max= d\\n ',W)\n", - "P_max=100000. #('enter the value of maximum load=:')\n", - "l=sig_f*b*h**2/(6*P_max);\n", - "\n", - "S=(6*Sg*l)/(E*b*h**2);\n", - "print'Sensitivity of this load cell is nV/N/per unit excitation',S\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_3 pgno:296" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Sensitivity of this load cell is micro V/N\n", - "0.13\n", - "The maximum density that can be achieved without endangering the strain gage sensors is micro V/N\n", - "0.284815729903\n", - "The voltage ratio is mV/V 3.9\n" - ] - } - ], - "source": [ - "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", - "#Caption : Load cell\n", - "# Example 3# Page 296\n", - "from math import sqrt\n", - "Sg=2;\n", - "v=0.3; #poissons ratio\n", - "Ei=10. #('enter the excitation voltage=:')\n", - "A=5*10**-4 #('enter the area of load cell=:')\n", - "E=200.; #(in Gpa) Youngs modulus\n", - "# Let sensitivity Eo/P be represented by Se\n", - "Se=Sg*(1+v)*Ei/(2*A*E)*.001;\n", - "print'Sensitivity of this load cell is micro V/N\\n',Se\n", - "Rg=120. #given\n", - "Pd=1. #('enter the power dissipated in each gage=:')\n", - "Ei_max=sqrt(4*Rg*Pd)\n", - "Se_max=Sg*(1+v)*Ei_max/(2*A*E)*.001\n", - "print'The maximum density that can be achieved without endangering the strain gage sensors is micro V/N\\n',Se_max\n", - "# Let (Eo/Ei)_max be represented by Em\n", - "sig_f=600*10**6 #('enter the fatigue strength=:')\n", - "Em=Sg*sig_f*(1+v)/(2*E)*10**-6\n", - "print'The voltage ratio is mV/V',Em\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_4 pgno:302" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "('Relative displacement is d', 1.9999999999999997e-08)\n", - "wnc**2 is approx. 10**9. So,\n", - "Z is approx. 20nm(rms)\n", - "Actual force transmitted to the plate is d N 18.0260791198\n" - ] - } - ], - "source": [ - "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", - "#Caption : Piezoelectric Transducers\n", - "# Example 4# Page 302\n", - "from math import sqrt,pi\n", - "mc=0.04 #('enter the connector mass=:')\n", - "m=0.01 #('enter the seismic mass=:')\n", - "k=10**9 #('enter the stiffness of the sensing element=:')\n", - "Sf=.005 #('enter the sensitivity of the transducer=:')\n", - "Xi=100*10**-6 # ('enter the displacement amplitude of the shaker vibration=:')\n", - "Eo=.1 #('enter the reading of voltage recorder connected to the transducer=:')\n", - "wnc=sqrt(k/(m+mc));\n", - "R=20; #20N (rms)\n", - "Z=(1/(m+mc))*(1/wnc**2)*R;\n", - "print('Relative displacement is d',Z)\n", - "print(\"wnc**2 is approx. 10**9. So,\")\n", - "print(\"Z is approx. 20nm(rms)\")\n", - "f=100.; # given\n", - "\n", - "F=R-((2*pi*f)**2*(m+mc)*Xi);\n", - "print'Actual force transmitted to the plate is d N',F\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_5 pgno:308" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The load torque is d N-m 1636.24617374\n" - ] - } - ], - "source": [ - "#CHAPTER 5_ Force,Torque and Shaft Power Measurement\n", - "#Caption : Torque measurement on rotating shaft\n", - "# Example 5# Page 308\n", - "Sg=2.;\n", - "Rg=120.;\n", - "G=80*10**9 #('enter the sheer modulus of elasticity=:')\n", - "D=0.05 #('enter the shaft diameter=:')\n", - "dR=0.1 # given\n", - "# we have to find the load torque\n", - "from math import pi\n", - "\n", - "y=2*dR/(Rg*Sg);\n", - "tou_xy=y*G;\n", - "j=pi*D**4;\n", - "T=tou_xy*2*j/(D*32);\n", - "print'The load torque is d N-m',T" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/vijayadurga/sample_(chapter.ipynb b/sample_notebooks/vijayadurga/sample_(chapter.ipynb new file mode 100755 index 00000000..f655751e --- /dev/null +++ b/sample_notebooks/vijayadurga/sample_(chapter.ipynb @@ -0,0 +1,410 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 3 Fundamentals of Fault Clearing and Switching Phenomena" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_1 pgno:24" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the transient current =A 1.56\n" + ] + } + ], + "source": [ + "from math import pi,exp\n", + "from math import atan,sin\n", + "from math import sqrt\n", + "R=10; \n", + "L=0.1; \n", + "f=50; \n", + "w=2*pi*f; \n", + "k=sqrt((R**2)+((w*L)**2));\n", + "angle=atan(w*L/R);\n", + "E=400 \n", + "A=E*sin(angle)/k;\n", + "i=A*exp((-R)*.02/L);\n", + "i=round(i*100)/100;\n", + "print\"the transient current =A\",i\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_2 pgno:26" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "current in amperes for part1=A\n", + "4.1\n", + "current in part 2& part 3= 0\n", + "\n", + "the DC component vanishes if e=V 141.4\n", + "\n", + "current at .5 cycles for t1=sec \n", + "current in the problem = A 0.01 1.50368424845\n", + "\n", + "current at 1.5 cycles for t2=sec \n", + "current in the problem = A 0.03 0.203501533662\n", + "\n", + "current at 5.5 cycles for t3=sec \n", + "current in the problem = A 0.11 6.82671592646e-05\n", + "the difference in result is due to erroneous value in textbook.\n" + ] + } + ], + "source": [ + "from math import sqrt,sin,atan,pi,exp\n", + "R=10; \n", + "L=0.1; \n", + "f=50; \n", + "w=2*pi*f; \n", + "k=sqrt((R**2)+((w*L)**2));\n", + "angle=atan(w*L/R); \n", + "E=100; \n", + "Em=sqrt(2)*E; \n", + "A=Em*sin(angle)/k;\n", + "i1=A; \n", + "Em=round(Em*10)/10;\n", + "i1=round(i1*10)/10;\n", + "print\"current in amperes for part1=A\\n\",i1\n", + "print\"current in part 2& part 3= 0\\n\"\n", + "print\"the DC component vanishes if e=V\",Em#the error is due to the erroneous values in the textbook\n", + "\n", + "t1=0.5*.02; \n", + "i2=A*exp((-R)*t1/L);\n", + "print\"\\ncurrent at .5 cycles for t1=sec \\ncurrent in the problem = A\",t1,i2\n", + "t2=1.5*.02;\n", + "i3=A*exp((-R)*t2/L);\n", + "print\"\\ncurrent at 1.5 cycles for t2=sec \\ncurrent in the problem = A\",t2,i3\n", + "t3=5.5*.02;\n", + "i4=A*exp((-R)*t3/L);\n", + "print\"\\ncurrent at 5.5 cycles for t3=sec \\ncurrent in the problem = A\",t3,i4\n", + "\n", + "\n", + "print\"the difference in result is due to erroneous value in textbook.\"\n", + " " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_3 pgno:28" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "frequency of oscillations=c/s 72400.0\n", + "\n", + "time of maximum restriking voltage=microsec 3.46\n", + "\n", + "maximum restriking voltage=V/microsecs 2430.0\n" + ] + } + ], + "source": [ + "from math import sqrt,e,pi\n", + "C=.003e-6 \n", + "L=1.6e-3 \n", + "y=sqrt(L*C);\n", + "y=round(y*1e7)/1e7;\n", + "f=(2*3.14*y)**-1; \n", + "f=round(f/100)*100;\n", + "i=7500;\n", + "E=i*2*3.15*L*50;\n", + "Em=1.414*E;\n", + "Em=round(Em/10)*10\n", + "t=y*pi/2;\n", + "t=t*1e6;\n", + "t=round(t*100)/100;\n", + "e=Em/y;\n", + "e=round((e)/1e6)*1e6;\n", + "e=round(e/1e7)*1e7\n", + "print\"frequency of oscillations=c/s\",f\n", + "print\"\\ntime of maximum restriking voltage=microsec\",t\n", + "print\"\\nmaximum restriking voltage=V/microsecs\",e/1e6\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_4 pgno:30" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "peak restriking voltage=kV 18.0\n", + "\n", + "frequency of oscillations=c/s 12637.7514913\n", + "\n", + "average rate of restriking voltage=kV/microsecs 0.455\n", + "\n", + "max restriking voltage=V/microsecs 714.0\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "R=5 \n", + "f=50\n", + "L=R/(2*pi*f);\n", + "V=11e3;\n", + "Vph=11/sqrt(3);\n", + "C=0.01e-6;\n", + "y=sqrt(L*C);\n", + "Em=sqrt(2)*Vph;\n", + "ep=2*Em;\n", + "ep=round(ep*10)/10;\n", + "y=round(y*1e7)/1e7;\n", + "t=y*pi;\n", + "t=round(t*1e7)/1e7\n", + "ea=ep/t;\n", + "ea=round(ea/1e3)*1e3\n", + "fn=(2*3.14*y)**-1;\n", + "Em=round(Em)\n", + "Emax=Em/y;\n", + "Emax=round(Emax/1000)*1e3;\n", + "print\"peak restriking voltage=kV\",ep\n", + "print\"\\nfrequency of oscillations=c/s\",fn\n", + "print\"\\naverage rate of restriking voltage=kV/microsecs\",ea/1e6\n", + "print\"\\nmax restriking voltage=V/microsecs\",Emax/1e3\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_5 pgno:31" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "average restriking voltage=V/microsecs 1220.0\n" + ] + } + ], + "source": [ + "from math import pi,sqrt\n", + "E=19.1*1e3;\n", + "L=10*1e-3;\n", + "C=.02*1e-6;\n", + "Em=sqrt(2)*E;\n", + "y=sqrt(L*C);\n", + "t=pi*y*1e6;\n", + "emax=2*Em;\n", + "eavg=emax/t;\n", + "eavg=round(eavg/10)*10\n", + "print\"average restriking voltage=V/microsecs\",eavg\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_6 pgno:33" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "average restriking voltage=kV/microsecs 4.8\n" + ] + } + ], + "source": [ + "from math import e,sqrt,acos,sin\n", + "V=78e3;\n", + "Vph=V/sqrt(3);\n", + "Em=2*Vph;\n", + "pf=0.4;\n", + "angle=acos(pf);\n", + "k1=sin(angle); \n", + "k1=round(k1*100)/100;\n", + "k2=.951;\n", + "k3=1;\n", + "k=k1*k2*k3;\n", + "k=round(k*1000)/1e3;\n", + "E=k*Em;\n", + "f=15000.; \n", + "t=1/(2*f);\n", + "t=round(t*1e6);\n", + "eavg=2*E/t;\n", + "eavg=round(eavg/100)*100;\n", + "print\"average restriking voltage=kV/microsecs\",eavg/1e3\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_7 pgno:35" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "average voltage in volts=V/microsecs 1430.0\n", + "frequency of oscillation =c/s 7143.0\n" + ] + } + ], + "source": [ + "Em=100e3\n", + "t=70e-6\n", + "Ea=Em/t/1e6\n", + "f=1/(2*t);\n", + "Ea=round(Ea/10)*10;\n", + "f=round(f);\n", + "print\"average voltage in volts=V/microsecs\",Ea\n", + "print\"frequency of oscillation =c/s\",f\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 3_8 pgno:37" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "damping resistance in ohms=kohms 12.25\n" + ] + } + ], + "source": [ + "from math import sqrt\n", + "L=6; \n", + "C=0.01e-6;\n", + "i=10;\n", + "v=i*sqrt(L/C);\n", + "R=.5*v/i;\n", + "R=round(R/10)*10;\n", + "print\"damping resistance in ohms=kohms\",R/1e3\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/vijayadurga/sample_(chapter_3).ipynb b/sample_notebooks/vijayadurga/sample_(chapter_3).ipynb deleted file mode 100755 index f655751e..00000000 --- a/sample_notebooks/vijayadurga/sample_(chapter_3).ipynb +++ /dev/null @@ -1,410 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 3 Fundamentals of Fault Clearing and Switching Phenomena" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_1 pgno:24" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the transient current =A 1.56\n" - ] - } - ], - "source": [ - "from math import pi,exp\n", - "from math import atan,sin\n", - "from math import sqrt\n", - "R=10; \n", - "L=0.1; \n", - "f=50; \n", - "w=2*pi*f; \n", - "k=sqrt((R**2)+((w*L)**2));\n", - "angle=atan(w*L/R);\n", - "E=400 \n", - "A=E*sin(angle)/k;\n", - "i=A*exp((-R)*.02/L);\n", - "i=round(i*100)/100;\n", - "print\"the transient current =A\",i\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_2 pgno:26" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "current in amperes for part1=A\n", - "4.1\n", - "current in part 2& part 3= 0\n", - "\n", - "the DC component vanishes if e=V 141.4\n", - "\n", - "current at .5 cycles for t1=sec \n", - "current in the problem = A 0.01 1.50368424845\n", - "\n", - "current at 1.5 cycles for t2=sec \n", - "current in the problem = A 0.03 0.203501533662\n", - "\n", - "current at 5.5 cycles for t3=sec \n", - "current in the problem = A 0.11 6.82671592646e-05\n", - "the difference in result is due to erroneous value in textbook.\n" - ] - } - ], - "source": [ - "from math import sqrt,sin,atan,pi,exp\n", - "R=10; \n", - "L=0.1; \n", - "f=50; \n", - "w=2*pi*f; \n", - "k=sqrt((R**2)+((w*L)**2));\n", - "angle=atan(w*L/R); \n", - "E=100; \n", - "Em=sqrt(2)*E; \n", - "A=Em*sin(angle)/k;\n", - "i1=A; \n", - "Em=round(Em*10)/10;\n", - "i1=round(i1*10)/10;\n", - "print\"current in amperes for part1=A\\n\",i1\n", - "print\"current in part 2& part 3= 0\\n\"\n", - "print\"the DC component vanishes if e=V\",Em#the error is due to the erroneous values in the textbook\n", - "\n", - "t1=0.5*.02; \n", - "i2=A*exp((-R)*t1/L);\n", - "print\"\\ncurrent at .5 cycles for t1=sec \\ncurrent in the problem = A\",t1,i2\n", - "t2=1.5*.02;\n", - "i3=A*exp((-R)*t2/L);\n", - "print\"\\ncurrent at 1.5 cycles for t2=sec \\ncurrent in the problem = A\",t2,i3\n", - "t3=5.5*.02;\n", - "i4=A*exp((-R)*t3/L);\n", - "print\"\\ncurrent at 5.5 cycles for t3=sec \\ncurrent in the problem = A\",t3,i4\n", - "\n", - "\n", - "print\"the difference in result is due to erroneous value in textbook.\"\n", - " " - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_3 pgno:28" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "frequency of oscillations=c/s 72400.0\n", - "\n", - "time of maximum restriking voltage=microsec 3.46\n", - "\n", - "maximum restriking voltage=V/microsecs 2430.0\n" - ] - } - ], - "source": [ - "from math import sqrt,e,pi\n", - "C=.003e-6 \n", - "L=1.6e-3 \n", - "y=sqrt(L*C);\n", - "y=round(y*1e7)/1e7;\n", - "f=(2*3.14*y)**-1; \n", - "f=round(f/100)*100;\n", - "i=7500;\n", - "E=i*2*3.15*L*50;\n", - "Em=1.414*E;\n", - "Em=round(Em/10)*10\n", - "t=y*pi/2;\n", - "t=t*1e6;\n", - "t=round(t*100)/100;\n", - "e=Em/y;\n", - "e=round((e)/1e6)*1e6;\n", - "e=round(e/1e7)*1e7\n", - "print\"frequency of oscillations=c/s\",f\n", - "print\"\\ntime of maximum restriking voltage=microsec\",t\n", - "print\"\\nmaximum restriking voltage=V/microsecs\",e/1e6\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_4 pgno:30" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "peak restriking voltage=kV 18.0\n", - "\n", - "frequency of oscillations=c/s 12637.7514913\n", - "\n", - "average rate of restriking voltage=kV/microsecs 0.455\n", - "\n", - "max restriking voltage=V/microsecs 714.0\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "R=5 \n", - "f=50\n", - "L=R/(2*pi*f);\n", - "V=11e3;\n", - "Vph=11/sqrt(3);\n", - "C=0.01e-6;\n", - "y=sqrt(L*C);\n", - "Em=sqrt(2)*Vph;\n", - "ep=2*Em;\n", - "ep=round(ep*10)/10;\n", - "y=round(y*1e7)/1e7;\n", - "t=y*pi;\n", - "t=round(t*1e7)/1e7\n", - "ea=ep/t;\n", - "ea=round(ea/1e3)*1e3\n", - "fn=(2*3.14*y)**-1;\n", - "Em=round(Em)\n", - "Emax=Em/y;\n", - "Emax=round(Emax/1000)*1e3;\n", - "print\"peak restriking voltage=kV\",ep\n", - "print\"\\nfrequency of oscillations=c/s\",fn\n", - "print\"\\naverage rate of restriking voltage=kV/microsecs\",ea/1e6\n", - "print\"\\nmax restriking voltage=V/microsecs\",Emax/1e3\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_5 pgno:31" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "average restriking voltage=V/microsecs 1220.0\n" - ] - } - ], - "source": [ - "from math import pi,sqrt\n", - "E=19.1*1e3;\n", - "L=10*1e-3;\n", - "C=.02*1e-6;\n", - "Em=sqrt(2)*E;\n", - "y=sqrt(L*C);\n", - "t=pi*y*1e6;\n", - "emax=2*Em;\n", - "eavg=emax/t;\n", - "eavg=round(eavg/10)*10\n", - "print\"average restriking voltage=V/microsecs\",eavg\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_6 pgno:33" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "average restriking voltage=kV/microsecs 4.8\n" - ] - } - ], - "source": [ - "from math import e,sqrt,acos,sin\n", - "V=78e3;\n", - "Vph=V/sqrt(3);\n", - "Em=2*Vph;\n", - "pf=0.4;\n", - "angle=acos(pf);\n", - "k1=sin(angle); \n", - "k1=round(k1*100)/100;\n", - "k2=.951;\n", - "k3=1;\n", - "k=k1*k2*k3;\n", - "k=round(k*1000)/1e3;\n", - "E=k*Em;\n", - "f=15000.; \n", - "t=1/(2*f);\n", - "t=round(t*1e6);\n", - "eavg=2*E/t;\n", - "eavg=round(eavg/100)*100;\n", - "print\"average restriking voltage=kV/microsecs\",eavg/1e3\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_7 pgno:35" - ] - }, - { - "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "average voltage in volts=V/microsecs 1430.0\n", - "frequency of oscillation =c/s 7143.0\n" - ] - } - ], - "source": [ - "Em=100e3\n", - "t=70e-6\n", - "Ea=Em/t/1e6\n", - "f=1/(2*t);\n", - "Ea=round(Ea/10)*10;\n", - "f=round(f);\n", - "print\"average voltage in volts=V/microsecs\",Ea\n", - "print\"frequency of oscillation =c/s\",f\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 3_8 pgno:37" - ] - }, - { - "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "damping resistance in ohms=kohms 12.25\n" - ] - } - ], - "source": [ - "from math import sqrt\n", - "L=6; \n", - "C=0.01e-6;\n", - "i=10;\n", - "v=i*sqrt(L/C);\n", - "R=.5*v/i;\n", - "R=round(R/10)*10;\n", - "print\"damping resistance in ohms=kohms\",R/1e3\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/yashwanth kumarmada/Chapter_5.ipynb b/sample_notebooks/yashwanth kumarmada/Chapter_5.ipynb new file mode 100755 index 00000000..e5562a27 --- /dev/null +++ b/sample_notebooks/yashwanth kumarmada/Chapter_5.ipynb @@ -0,0 +1,272 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Chapter 5 Laser" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_1 pgno:242" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 1 # \n", + "\n", + "\n", + " Number of oscillation corresponding to coherent length is \n", + " Coherent time is sec. 50000.0 9.81666666667e-11\n" + ] + } + ], + "source": [ + "# Given that\n", + "l = 2.945e-2 # coherent length of sodium light\n", + "lamda = 5890 # wavelength of light used in angstrom\n", + "c = 3e8 # speed of light\n", + "# Sample Problem 1 on page no. 242\n", + "print(\"\\n # PROBLEM 1 # \\n\")\n", + "n = l/(lamda*1e-10) # number of oscillation corresponding to coherent length\n", + "t = l/c # coherent time\n", + "print\"\\n Number of oscillation corresponding to coherent length is \\n Coherent time is sec.\",n,t\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_2 pgno:242" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 2 # \n", + "\n", + "\n", + " Angular spread is rad. \n", + " Areal spread is m^2. 0.00016 4096000000.0\n" + ] + } + ], + "source": [ + "\n", + "# Given that\n", + "l = 4e5 # Distance of moon in km\n", + "lamda = 8e-7 # wavelength of light used\n", + "a = 5e-3 # Aperture of laser\n", + "c = 3e8 # speed of light\n", + "# Sample Problem 2 on page no. 242\n", + "print\"\\n # PROBLEM 2 # \\n\"\n", + "theta = lamda/a # Angular of spread \n", + "Areal_spread = (l*1000*theta)**2 # Areal spread\n", + "print\"\\n Angular spread is rad. \\n Areal spread is m^2.\",theta,Areal_spread\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_3 pgno:242" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 3 # \n", + "\n", + "\n", + " Number of oscillation corresponding to coherent length is \n", + " Coherent time is sec. 50000.0 9.81666666667e-11\n" + ] + } + ], + "source": [ + "\n", + "# Given that\n", + "l = 2.945e-2 # coherent length of sodium light\n", + "lamda = 5890 # wavelength of light used\n", + "c = 3e8 # speed of light\n", + "# Sample Problem 3 on page no. 242\n", + "print\"\\n # PROBLEM 3 # \\n\"\n", + "n = l/(lamda *1e-10) # number of oscillation corresponding to coherent length\n", + "t = l/c # coherent time\n", + "print\"\\n Number of oscillation corresponding to coherent length is \\n Coherent time is sec.\",n,t\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_4 pgno:243" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 4 # \n", + "\n", + "\n", + " Energy difference is eV. 0.365641494412\n" + ] + } + ], + "source": [ + "\n", + "# Given that\n", + "k = 12400 # constant\n", + "lamda = 3.3913 # wavelength IR radiation\n", + "\n", + "# Sample Problem 4 on page no. 243\n", + "print\"\\n # PROBLEM 4 # \\n\"\n", + "E = k/(lamda*1e4) # Energy difference\n", + "print\"\\n Energy difference is eV.\",E\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_5 pgno:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 5 # \n", + "\n", + "\n", + " Energy of one photon is eV. \n", + " Total energy is J 1 4.8\n" + ] + } + ], + "source": [ + "\n", + "k = 12400 # constant\n", + "lamda = 6943 # wavelength of radiation in angstrom\n", + "n = 3e19 # Total number of ions\n", + "# Sample Problem 5 on page no. 243\n", + "print\"\\n # PROBLEM 5 # \\n\"\n", + "E = k/(lamda) # Energy difference\n", + "E_total = E*n*1.6e-19 # Total Energy emitted \n", + "print\"\\n Energy of one photon is eV. \\n Total energy is J\",E,E_total\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Example 5_6 pgno:244" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " # PROBLEM 6 # \n", + "\n", + "\n", + " Required length of cavity is cm. 10.010896\n" + ] + } + ], + "source": [ + "\n", + "# Given that\n", + "h_w = 2e-3 # half width of gain profile of laser in nm\n", + "mu = 1 # refractive index\n", + "lamda = 6328 # wavelength of light used in angstrom\n", + "# Sample Problem 6 on page no. 244\n", + "print\"\\n # PROBLEM 6 # \\n\"\n", + "L = (lamda*1e-10)**2/(2*mu*h_w*1e-9) # Length of cavity \n", + "print\"\\n Required length of cavity is cm.\",L*100\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/yashwanth kumarmada/Chapter_5_Laser.ipynb b/sample_notebooks/yashwanth kumarmada/Chapter_5_Laser.ipynb deleted file mode 100755 index e5562a27..00000000 --- a/sample_notebooks/yashwanth kumarmada/Chapter_5_Laser.ipynb +++ /dev/null @@ -1,272 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "# Chapter 5 Laser" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_1 pgno:242" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 1 # \n", - "\n", - "\n", - " Number of oscillation corresponding to coherent length is \n", - " Coherent time is sec. 50000.0 9.81666666667e-11\n" - ] - } - ], - "source": [ - "# Given that\n", - "l = 2.945e-2 # coherent length of sodium light\n", - "lamda = 5890 # wavelength of light used in angstrom\n", - "c = 3e8 # speed of light\n", - "# Sample Problem 1 on page no. 242\n", - "print(\"\\n # PROBLEM 1 # \\n\")\n", - "n = l/(lamda*1e-10) # number of oscillation corresponding to coherent length\n", - "t = l/c # coherent time\n", - "print\"\\n Number of oscillation corresponding to coherent length is \\n Coherent time is sec.\",n,t\n", - "\n", - "\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_2 pgno:242" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 2 # \n", - "\n", - "\n", - " Angular spread is rad. \n", - " Areal spread is m^2. 0.00016 4096000000.0\n" - ] - } - ], - "source": [ - "\n", - "# Given that\n", - "l = 4e5 # Distance of moon in km\n", - "lamda = 8e-7 # wavelength of light used\n", - "a = 5e-3 # Aperture of laser\n", - "c = 3e8 # speed of light\n", - "# Sample Problem 2 on page no. 242\n", - "print\"\\n # PROBLEM 2 # \\n\"\n", - "theta = lamda/a # Angular of spread \n", - "Areal_spread = (l*1000*theta)**2 # Areal spread\n", - "print\"\\n Angular spread is rad. \\n Areal spread is m^2.\",theta,Areal_spread\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_3 pgno:242" - ] - }, - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 3 # \n", - "\n", - "\n", - " Number of oscillation corresponding to coherent length is \n", - " Coherent time is sec. 50000.0 9.81666666667e-11\n" - ] - } - ], - "source": [ - "\n", - "# Given that\n", - "l = 2.945e-2 # coherent length of sodium light\n", - "lamda = 5890 # wavelength of light used\n", - "c = 3e8 # speed of light\n", - "# Sample Problem 3 on page no. 242\n", - "print\"\\n # PROBLEM 3 # \\n\"\n", - "n = l/(lamda *1e-10) # number of oscillation corresponding to coherent length\n", - "t = l/c # coherent time\n", - "print\"\\n Number of oscillation corresponding to coherent length is \\n Coherent time is sec.\",n,t\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_4 pgno:243" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 4 # \n", - "\n", - "\n", - " Energy difference is eV. 0.365641494412\n" - ] - } - ], - "source": [ - "\n", - "# Given that\n", - "k = 12400 # constant\n", - "lamda = 3.3913 # wavelength IR radiation\n", - "\n", - "# Sample Problem 4 on page no. 243\n", - "print\"\\n # PROBLEM 4 # \\n\"\n", - "E = k/(lamda*1e4) # Energy difference\n", - "print\"\\n Energy difference is eV.\",E\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_5 pgno:" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 5 # \n", - "\n", - "\n", - " Energy of one photon is eV. \n", - " Total energy is J 1 4.8\n" - ] - } - ], - "source": [ - "\n", - "k = 12400 # constant\n", - "lamda = 6943 # wavelength of radiation in angstrom\n", - "n = 3e19 # Total number of ions\n", - "# Sample Problem 5 on page no. 243\n", - "print\"\\n # PROBLEM 5 # \\n\"\n", - "E = k/(lamda) # Energy difference\n", - "E_total = E*n*1.6e-19 # Total Energy emitted \n", - "print\"\\n Energy of one photon is eV. \\n Total energy is J\",E,E_total\n" - ] - }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Example 5_6 pgno:244" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - " # PROBLEM 6 # \n", - "\n", - "\n", - " Required length of cavity is cm. 10.010896\n" - ] - } - ], - "source": [ - "\n", - "# Given that\n", - "h_w = 2e-3 # half width of gain profile of laser in nm\n", - "mu = 1 # refractive index\n", - "lamda = 6328 # wavelength of light used in angstrom\n", - "# Sample Problem 6 on page no. 244\n", - "print\"\\n # PROBLEM 6 # \\n\"\n", - "L = (lamda*1e-10)**2/(2*mu*h_w*1e-9) # Length of cavity \n", - "print\"\\n Required length of cavity is cm.\",L*100\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} diff --git a/sample_notebooks/yashwanth kumarmada/sample.ipynb b/sample_notebooks/yashwanth kumarmada/sample.ipynb new file mode 100755 index 00000000..24fbec2e --- /dev/null +++ b/sample_notebooks/yashwanth kumarmada/sample.ipynb @@ -0,0 +1,414 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "#CHAPTER 2" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "the weight is 128.8\n" + ] + } + ], + "source": [ + "##Example2_1\n", + "# Aim:To Find Weight of Body\n", + "# Given:\n", + "# Mass of the Body:\n", + "m=4; #slugs\n", + "\n", + "# Solutions:\n", + "# we know acceleration due to gravity,\n", + "g=32.2; #ft/s**2\n", + "W=(m*g);\n", + "\n", + "# Results:\n", + "print \"the weight is\",W\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + " The specific weight of Body is lb/ft**3. 71.7\n" + ] + } + ], + "source": [ + "##Example2_2\n", + "# Aim:To find the specific weight of a body\n", + "# Given:\n", + "# Weigth of the Body:\n", + "W=129; #lb\n", + "# Volume of the Body:\n", + "V=1.8; #ft**3\n", + "\n", + "# Solution:\n", + "# we know specific weight,\n", + "# gamma=(Weigth of the Body/Volume of the Body)\n", + "gamma1=(W/V); #lb/ft^3\n", + "# rounding off the above answer\n", + "gamma1=round(gamma1)+(round((gamma1-round(gamma1))*10)/10); #lb/ft^3\n", + " \n", + "# Results:\n", + "print \" Results: \"\n", + "print \" The specific weight of Body is lb/ft**3.\",gamma1\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Results: \n", + "The specific gravity of air 0.00120512820513\n" + ] + } + ], + "source": [ + "##Example2_3\n", + "# Aim:To find the specific gravity of air at 68 degF\n", + "# Given:\n", + "# specific weight of air at 68 degF:\n", + "gamma_air=0.0752; #lb/ft**3\n", + "\n", + "\n", + "# Solution:\n", + "# we know,\n", + "# specific gravity of air=(specific weight of air/specific weight of water)\n", + "# also we know,specific weight of water at 68 degF,\n", + "gamma_water=62.4; #lb/ft**3\n", + "SG_air=gamma_air/gamma_water;\n", + "\n", + "# Results:\n", + "print \"Results: \"\n", + "print \"The specific gravity of air \",SG_air \n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Results: \n", + "The Density of Body is slugs/ft**3. 2.22222222222\n", + "The Density of Body is slugs/ft**3. 2.22360248447\n" + ] + } + ], + "source": [ + "##Example2_4\n", + "# Aim:To find Density of body of Example 2-1 and 2-2\n", + "# Given:\n", + "# mass of the Body:\n", + "m=4; #slugs\n", + "# Volume of the Body:\n", + "V=1.8; #ft**3\n", + "\n", + "# Solution:\n", + "# we know density,\n", + "# rho1=(mass of the Body/Volume of the Body)\n", + "rho1=(m/V); #slugs/ft**3\n", + "# also density,rho2=(specific weight/acceleration due to gravity)\n", + "g=32.2; #ft/s**2\n", + "gamma1=71.6; #lb/ft**3\n", + "rho2=(gamma1/g); #slugs/ft**3\n", + "\n", + "# Results:\n", + "print \"Results: \"\n", + "print \"The Density of Body is slugs/ft**3.\",rho1\n", + "print \"The Density of Body is slugs/ft**3.\",rho2\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + " The pressure on skin diver is % psi. 25.992\n" + ] + } + ], + "source": [ + "##Example2_5\n", + "# Aim:To find pressure on the skin diver\n", + "# Given:\n", + "# Depth of Water Body:\n", + "H=60; #ft\n", + "\n", + "# Solution:\n", + "# specific Weight of water,\n", + "gamma1=0.0361; #lb/in**3 \n", + "# Conversion: \n", + "# 1 feet = 12 inches\n", + "# 1 lb/in**2 = 1 psi \n", + "# we know pressure,\n", + "# p=(specific weight of liquid * liquid column height)\n", + "p=(gamma1*H*12); #psi\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \" The pressure on skin diver is % psi.\",p\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + " The Height of water column is ft. 33.7977839335\n" + ] + } + ], + "source": [ + "##Example2_6\n", + "# Aim:To find tube height of a Barometer\n", + "# Given:\n", + "# liquid used is Water instead of Mercury.\n", + "\n", + "# Solution:\n", + "# specific Weight of water,\n", + "gamma1=0.0361; #lb/in**3 \n", + "# We also knows Atmospheric Pressure,\n", + "p=14.7; #psi\n", + "# Conversion: \n", + "# 1 feet = 12 inches\n", + "# 1 lb/in**2 = 1 psi \n", + "# we know pressure,\n", + "# p=(specific weight of liquid * liquid column height)\n", + "# Therefore,\n", + "H=(p/gamma1); #in\n", + "# He=Height in Feet.\n", + "He=H*0.083; #ft\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \" The Height of water column is ft.\",He\n" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + " The Absolute Pressure is psi. 9.7\n" + ] + } + ], + "source": [ + "##Example2_7\n", + "# Aim:To convert given pressure into absolute pressure\n", + "# Given:\n", + "# Gage Pressure:\n", + "Pg=-5; #psi\n", + "\n", + "# Solution:\n", + "# Atmospheric Pressure,\n", + "Po=14.7; #psi \n", + "# Absolute Pressure(Pa) =Gage Pressure + Atmospheric Pressure\n", + "Pa=Pg+Po;\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \" The Absolute Pressure is psi.\",Pa\n" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + "The Absolute Pressure is psi. 40.7\n" + ] + } + ], + "source": [ + "##Example2_8\n", + "# Aim:To find absolute pressure on skin diver of Example 2-5\n", + "# Given:\n", + "# Gage Pressure:\n", + "Pg=26; #psi\n", + "\n", + "# Solution:\n", + "# Atmospheric Pressure,\n", + "Po=14.7; #psi \n", + "# Absolute Pressure(Pa) =Gage Pressure + Atmospheric Pressure\n", + "Pa=Pg+Po; #psi\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \"The Absolute Pressure is psi.\",Pa\n" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + "The specific weights is N/m**3. 8792\n", + " The answer in the program is different than that in textbook. It may be due to no.s of significant digit in data and calculation\n" + ] + } + ], + "source": [ + "##Example2_9\n", + "# Aim:To Determine specific weights in N/m**3\n", + "# Given:\n", + "# specific weight:\n", + "gamma1=56; #lb/ft**3\n", + "\n", + "\n", + "# Solution:\n", + "# We know,\n", + "# 1 N/m**3 = 157 lb/ft**3\n", + "gamma2=157*gamma1; #N/m**3\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \"The specific weights is N/m**3.\",gamma2\n", + "print \" The answer in the program is different than that in textbook. It may be due to no.s of significant digit in data and calculation\"\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Results: \n", + " The temp at which Fahrenheit and Celsius values are equal is deg. -40.0\n" + ] + } + ], + "source": [ + "##Example2_10\n", + "# Aim:To find Temperature at which Fahrenheit and Celsius values are equal \n", + "# Given:\n", + "# T(degF) = T(degC) #Eqn - 1\n", + "\n", + "# Solution:\n", + "# We know that,\n", + "# T(degF)=((1.8*T(degC))+32) #Eqn - 2 \n", + "# From Eqn 1 and 2\n", + "# ((1.8*T(degC))+32)= T(degC)\n", + "# (1-1.8)*T(degC)=32\n", + "# -0.8*T(degC)=32\n", + "TdegC=-32/0.8;\n", + "\n", + "# Results:\n", + "print \" Results: \"\n", + "print \" The temp at which Fahrenheit and Celsius values are equal is deg.\",TdegC\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 2", + "language": "python", + "name": "python2" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 2 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython2", + "version": "2.7.9" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} diff --git a/sample_notebooks/yashwanth kumarmada/sample_notes.ipynb b/sample_notebooks/yashwanth kumarmada/sample_notes.ipynb deleted file mode 100755 index 24fbec2e..00000000 --- a/sample_notebooks/yashwanth kumarmada/sample_notes.ipynb +++ /dev/null @@ -1,414 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "#CHAPTER 2" - ] - }, - { - "cell_type": "code", - "execution_count": 4, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "the weight is 128.8\n" - ] - } - ], - "source": [ - "##Example2_1\n", - "# Aim:To Find Weight of Body\n", - "# Given:\n", - "# Mass of the Body:\n", - "m=4; #slugs\n", - "\n", - "# Solutions:\n", - "# we know acceleration due to gravity,\n", - "g=32.2; #ft/s**2\n", - "W=(m*g);\n", - "\n", - "# Results:\n", - "print \"the weight is\",W\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - " The specific weight of Body is lb/ft**3. 71.7\n" - ] - } - ], - "source": [ - "##Example2_2\n", - "# Aim:To find the specific weight of a body\n", - "# Given:\n", - "# Weigth of the Body:\n", - "W=129; #lb\n", - "# Volume of the Body:\n", - "V=1.8; #ft**3\n", - "\n", - "# Solution:\n", - "# we know specific weight,\n", - "# gamma=(Weigth of the Body/Volume of the Body)\n", - "gamma1=(W/V); #lb/ft^3\n", - "# rounding off the above answer\n", - "gamma1=round(gamma1)+(round((gamma1-round(gamma1))*10)/10); #lb/ft^3\n", - " \n", - "# Results:\n", - "print \" Results: \"\n", - "print \" The specific weight of Body is lb/ft**3.\",gamma1\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Results: \n", - "The specific gravity of air 0.00120512820513\n" - ] - } - ], - "source": [ - "##Example2_3\n", - "# Aim:To find the specific gravity of air at 68 degF\n", - "# Given:\n", - "# specific weight of air at 68 degF:\n", - "gamma_air=0.0752; #lb/ft**3\n", - "\n", - "\n", - "# Solution:\n", - "# we know,\n", - "# specific gravity of air=(specific weight of air/specific weight of water)\n", - "# also we know,specific weight of water at 68 degF,\n", - "gamma_water=62.4; #lb/ft**3\n", - "SG_air=gamma_air/gamma_water;\n", - "\n", - "# Results:\n", - "print \"Results: \"\n", - "print \"The specific gravity of air \",SG_air \n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Results: \n", - "The Density of Body is slugs/ft**3. 2.22222222222\n", - "The Density of Body is slugs/ft**3. 2.22360248447\n" - ] - } - ], - "source": [ - "##Example2_4\n", - "# Aim:To find Density of body of Example 2-1 and 2-2\n", - "# Given:\n", - "# mass of the Body:\n", - "m=4; #slugs\n", - "# Volume of the Body:\n", - "V=1.8; #ft**3\n", - "\n", - "# Solution:\n", - "# we know density,\n", - "# rho1=(mass of the Body/Volume of the Body)\n", - "rho1=(m/V); #slugs/ft**3\n", - "# also density,rho2=(specific weight/acceleration due to gravity)\n", - "g=32.2; #ft/s**2\n", - "gamma1=71.6; #lb/ft**3\n", - "rho2=(gamma1/g); #slugs/ft**3\n", - "\n", - "# Results:\n", - "print \"Results: \"\n", - "print \"The Density of Body is slugs/ft**3.\",rho1\n", - "print \"The Density of Body is slugs/ft**3.\",rho2\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - " The pressure on skin diver is % psi. 25.992\n" - ] - } - ], - "source": [ - "##Example2_5\n", - "# Aim:To find pressure on the skin diver\n", - "# Given:\n", - "# Depth of Water Body:\n", - "H=60; #ft\n", - "\n", - "# Solution:\n", - "# specific Weight of water,\n", - "gamma1=0.0361; #lb/in**3 \n", - "# Conversion: \n", - "# 1 feet = 12 inches\n", - "# 1 lb/in**2 = 1 psi \n", - "# we know pressure,\n", - "# p=(specific weight of liquid * liquid column height)\n", - "p=(gamma1*H*12); #psi\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \" The pressure on skin diver is % psi.\",p\n", - "\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - " The Height of water column is ft. 33.7977839335\n" - ] - } - ], - "source": [ - "##Example2_6\n", - "# Aim:To find tube height of a Barometer\n", - "# Given:\n", - "# liquid used is Water instead of Mercury.\n", - "\n", - "# Solution:\n", - "# specific Weight of water,\n", - "gamma1=0.0361; #lb/in**3 \n", - "# We also knows Atmospheric Pressure,\n", - "p=14.7; #psi\n", - "# Conversion: \n", - "# 1 feet = 12 inches\n", - "# 1 lb/in**2 = 1 psi \n", - "# we know pressure,\n", - "# p=(specific weight of liquid * liquid column height)\n", - "# Therefore,\n", - "H=(p/gamma1); #in\n", - "# He=Height in Feet.\n", - "He=H*0.083; #ft\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \" The Height of water column is ft.\",He\n" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - " The Absolute Pressure is psi. 9.7\n" - ] - } - ], - "source": [ - "##Example2_7\n", - "# Aim:To convert given pressure into absolute pressure\n", - "# Given:\n", - "# Gage Pressure:\n", - "Pg=-5; #psi\n", - "\n", - "# Solution:\n", - "# Atmospheric Pressure,\n", - "Po=14.7; #psi \n", - "# Absolute Pressure(Pa) =Gage Pressure + Atmospheric Pressure\n", - "Pa=Pg+Po;\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \" The Absolute Pressure is psi.\",Pa\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - "The Absolute Pressure is psi. 40.7\n" - ] - } - ], - "source": [ - "##Example2_8\n", - "# Aim:To find absolute pressure on skin diver of Example 2-5\n", - "# Given:\n", - "# Gage Pressure:\n", - "Pg=26; #psi\n", - "\n", - "# Solution:\n", - "# Atmospheric Pressure,\n", - "Po=14.7; #psi \n", - "# Absolute Pressure(Pa) =Gage Pressure + Atmospheric Pressure\n", - "Pa=Pg+Po; #psi\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \"The Absolute Pressure is psi.\",Pa\n" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - "The specific weights is N/m**3. 8792\n", - " The answer in the program is different than that in textbook. It may be due to no.s of significant digit in data and calculation\n" - ] - } - ], - "source": [ - "##Example2_9\n", - "# Aim:To Determine specific weights in N/m**3\n", - "# Given:\n", - "# specific weight:\n", - "gamma1=56; #lb/ft**3\n", - "\n", - "\n", - "# Solution:\n", - "# We know,\n", - "# 1 N/m**3 = 157 lb/ft**3\n", - "gamma2=157*gamma1; #N/m**3\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \"The specific weights is N/m**3.\",gamma2\n", - "print \" The answer in the program is different than that in textbook. It may be due to no.s of significant digit in data and calculation\"\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - " Results: \n", - " The temp at which Fahrenheit and Celsius values are equal is deg. -40.0\n" - ] - } - ], - "source": [ - "##Example2_10\n", - "# Aim:To find Temperature at which Fahrenheit and Celsius values are equal \n", - "# Given:\n", - "# T(degF) = T(degC) #Eqn - 1\n", - "\n", - "# Solution:\n", - "# We know that,\n", - "# T(degF)=((1.8*T(degC))+32) #Eqn - 2 \n", - "# From Eqn 1 and 2\n", - "# ((1.8*T(degC))+32)= T(degC)\n", - "# (1-1.8)*T(degC)=32\n", - "# -0.8*T(degC)=32\n", - "TdegC=-32/0.8;\n", - "\n", - "# Results:\n", - "print \" Results: \"\n", - "print \" The temp at which Fahrenheit and Celsius values are equal is deg.\",TdegC\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 2", - "language": "python", - "name": "python2" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 2 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.9" - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} -- cgit